diff --git a/ArchiSteamFarm/Helpers/Json/GuidJsonConverter.cs b/ArchiSteamFarm/Helpers/Json/GuidJsonConverter.cs index bd44b2dd0..42571e8b0 100644 --- a/ArchiSteamFarm/Helpers/Json/GuidJsonConverter.cs +++ b/ArchiSteamFarm/Helpers/Json/GuidJsonConverter.cs @@ -24,6 +24,7 @@ using System; using System.Text.Json; using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace ArchiSteamFarm.Helpers.Json; @@ -32,9 +33,8 @@ namespace ArchiSteamFarm.Helpers.Json; /// TODO: This class exists purely because STJ can't deserialize Guid in other formats than default, at least for now /// https://github.com/dotnet/runtime/issues/30692 /// -internal sealed class GuidJsonConverter : JsonConverter { - internal static readonly GuidJsonConverter Shared = new(); - +[PublicAPI] +public sealed class GuidJsonConverter : JsonConverter { public override Guid Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { if (reader.TryGetGuid(out Guid result)) { // Great, we can work with it diff --git a/ArchiSteamFarm/Helpers/Json/JsonUtilities.cs b/ArchiSteamFarm/Helpers/Json/JsonUtilities.cs index 89ef5dfba..c92be8479 100644 --- a/ArchiSteamFarm/Helpers/Json/JsonUtilities.cs +++ b/ArchiSteamFarm/Helpers/Json/JsonUtilities.cs @@ -113,7 +113,6 @@ public static class JsonUtilities { private static JsonSerializerOptions CreateDefaultJsonSerializerOptions(bool writeIndented = false) => new() { AllowTrailingCommas = true, - Converters = { GuidJsonConverter.Shared }, PropertyNamingPolicy = null, ReadCommentHandling = JsonCommentHandling.Skip, TypeInfoResolver = new DefaultJsonTypeInfoResolver { Modifiers = { ApplyCustomModifiers } }, diff --git a/ArchiSteamFarm/IPC/ArchiKestrel.cs b/ArchiSteamFarm/IPC/ArchiKestrel.cs index 0d21afa02..8bc1f224b 100644 --- a/ArchiSteamFarm/IPC/ArchiKestrel.cs +++ b/ArchiSteamFarm/IPC/ArchiKestrel.cs @@ -31,7 +31,6 @@ using System.Net; using System.Reflection; using System.Text.Json; using System.Text.Json.Nodes; -using System.Text.Json.Serialization; using System.Threading.Tasks; using ArchiSteamFarm.Core; using ArchiSteamFarm.Helpers.Json; @@ -388,10 +387,6 @@ internal static class ArchiKestrel { static options => { JsonSerializerOptions jsonSerializerOptions = Debugging.IsUserDebugging ? JsonUtilities.IndentedJsonSerialierOptions : JsonUtilities.DefaultJsonSerialierOptions; - foreach (JsonConverter converter in jsonSerializerOptions.Converters) { - options.JsonSerializerOptions.Converters.Add(converter); - } - options.JsonSerializerOptions.PropertyNamingPolicy = jsonSerializerOptions.PropertyNamingPolicy; options.JsonSerializerOptions.TypeInfoResolver = jsonSerializerOptions.TypeInfoResolver; options.JsonSerializerOptions.WriteIndented = jsonSerializerOptions.WriteIndented; diff --git a/ArchiSteamFarm/Steam/Data/InventoryDescription.cs b/ArchiSteamFarm/Steam/Data/InventoryDescription.cs index 4760d924a..eb660468e 100644 --- a/ArchiSteamFarm/Steam/Data/InventoryDescription.cs +++ b/ArchiSteamFarm/Steam/Data/InventoryDescription.cs @@ -64,17 +64,17 @@ public sealed class InventoryDescription { private init => Body.classid = value; } + [JsonConverter(typeof(BooleanNumberConverter))] [JsonInclude] [JsonPropertyName("commodity")] - [JsonConverter(typeof(BooleanNumberConverter))] public bool Commodity { get => Body.commodity; private init => Body.commodity = value; } + [JsonConverter(typeof(BooleanNumberConverter))] [JsonInclude] [JsonPropertyName("currency")] - [JsonConverter(typeof(BooleanNumberConverter))] public bool Currency { get => Body.currency; private init => Body.currency = value; @@ -127,10 +127,10 @@ public sealed class InventoryDescription { private init => Body.instanceid = value; } + [JsonConverter(typeof(BooleanNumberConverter))] [JsonInclude] [JsonPropertyName("marketable")] [JsonRequired] - [JsonConverter(typeof(BooleanNumberConverter))] public bool Marketable { get => Body.marketable; private init => Body.marketable = value; @@ -301,10 +301,10 @@ public sealed class InventoryDescription { } } + [JsonConverter(typeof(BooleanNumberConverter))] [JsonInclude] [JsonPropertyName("tradable")] [JsonRequired] - [JsonConverter(typeof(BooleanNumberConverter))] internal bool Tradable { get => Body.tradable; private init => Body.tradable = value; diff --git a/ArchiSteamFarm/Steam/Data/InventoryResponse.cs b/ArchiSteamFarm/Steam/Data/InventoryResponse.cs index 9abdfab9d..027742813 100644 --- a/ArchiSteamFarm/Steam/Data/InventoryResponse.cs +++ b/ArchiSteamFarm/Steam/Data/InventoryResponse.cs @@ -51,9 +51,9 @@ internal sealed class InventoryResponse : OptionalResultResponse { [JsonPropertyName("last_assetid")] internal ulong LastAssetID { get; private init; } + [JsonConverter(typeof(BooleanNumberConverter))] [JsonInclude] [JsonPropertyName("more_items")] - [JsonConverter(typeof(BooleanNumberConverter))] internal bool MoreItems { get; private init; } [JsonInclude] diff --git a/ArchiSteamFarm/Storage/GlobalConfig.cs b/ArchiSteamFarm/Storage/GlobalConfig.cs index c8361d7d1..145f65acb 100644 --- a/ArchiSteamFarm/Storage/GlobalConfig.cs +++ b/ArchiSteamFarm/Storage/GlobalConfig.cs @@ -263,6 +263,7 @@ public sealed class GlobalConfig { [JsonInclude] public ArchiCryptoHelper.EHashingMethod IPCPasswordFormat { get; private init; } = DefaultIPCPasswordFormat; + [JsonConverter(typeof(GuidJsonConverter))] [JsonInclude] public Guid? LicenseID { get; private init; } = DefaultLicenseID;