diff --git a/src/libs/SoundCloud/Generated/SoundCloud.JsonConverters.AllOf2.g.cs b/src/libs/SoundCloud/Generated/SoundCloud.JsonConverters.AllOf2.g.cs index b365445..c4e4938 100644 --- a/src/libs/SoundCloud/Generated/SoundCloud.JsonConverters.AllOf2.g.cs +++ b/src/libs/SoundCloud/Generated/SoundCloud.JsonConverters.AllOf2.g.cs @@ -14,118 +14,36 @@ public class AllOfJsonConverter : global::System.Text.Json.Serialization options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); - using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) + + T1? value1 = default; + try { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T1).Name}"); + value1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - var __score0 = 0; + catch (global::System.Text.Json.JsonException) { - var __ti = typeInfoResolver.GetTypeInfo(typeof(T1), options); - if (__ti != null && __ti.Kind == global::System.Text.Json.Serialization.Metadata.JsonTypeInfoKind.Object) - { - foreach (var __prop in __ti.Properties) - { - if (__jsonProps.Contains(__prop.Name)) __score0++; - } - } } - var __score1 = 0; + catch (global::System.InvalidOperationException) { - var __ti = typeInfoResolver.GetTypeInfo(typeof(T2), options); - if (__ti != null && __ti.Kind == global::System.Text.Json.Serialization.Metadata.JsonTypeInfoKind.Object) - { - foreach (var __prop in __ti.Properties) - { - if (__jsonProps.Contains(__prop.Name)) __score1++; - } - } } - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - T1? value1 = default; T2? value2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T1).Name}"); - value1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - - else if (__bestIndex == 1) - { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T2).Name}"); - value2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T2).Name}"); + value2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (value1 == null && value2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T1).Name}"); - value1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (value1 == null && value2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T2).Name}"); - value2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::SoundCloud.AllOf( value1, @@ -144,18 +62,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsValue1) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T1).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value1!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.Value1!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsValue2) + if (value.IsValue2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.Value2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/SoundCloud/Generated/SoundCloud.JsonConverters.TooManyRequests.g.cs b/src/libs/SoundCloud/Generated/SoundCloud.JsonConverters.TooManyRequests.g.cs index 05b7480..3636f53 100644 --- a/src/libs/SoundCloud/Generated/SoundCloud.JsonConverters.TooManyRequests.g.cs +++ b/src/libs/SoundCloud/Generated/SoundCloud.JsonConverters.TooManyRequests.g.cs @@ -17,100 +17,34 @@ public class TooManyRequestsJsonConverter : global::System.Text.Json.Serializati using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::SoundCloud.Error? error = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::SoundCloud.Error), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::SoundCloud.Error).Name}"); + error = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("code")) __score0++; - if (__jsonProps.Contains("error")) __score0++; - if (__jsonProps.Contains("errors")) __score0++; - if (__jsonProps.Contains("link")) __score0++; - if (__jsonProps.Contains("message")) __score0++; - if (__jsonProps.Contains("status")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("spam_warning_urn")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::SoundCloud.Error? error = default; global::SoundCloud.TooManyRequestsVariant2? tooManyRequestsVariant2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::SoundCloud.Error), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::SoundCloud.Error).Name}"); - error = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::SoundCloud.TooManyRequestsVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::SoundCloud.TooManyRequestsVariant2).Name}"); - tooManyRequestsVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::SoundCloud.TooManyRequestsVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::SoundCloud.TooManyRequestsVariant2).Name}"); + tooManyRequestsVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (error == null && tooManyRequestsVariant2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::SoundCloud.Error), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::SoundCloud.Error).Name}"); - error = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (error == null && tooManyRequestsVariant2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::SoundCloud.TooManyRequestsVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::SoundCloud.TooManyRequestsVariant2).Name}"); - tooManyRequestsVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::SoundCloud.TooManyRequests( error, @@ -129,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsError) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::SoundCloud.Error), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::SoundCloud.Error).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.Error!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.Error!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsTooManyRequestsVariant2) + if (value.IsTooManyRequestsVariant2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::SoundCloud.TooManyRequestsVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::SoundCloud.TooManyRequestsVariant2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.TooManyRequestsVariant2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.TooManyRequestsVariant2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/SoundCloud/Generated/SoundCloud.JsonSerializerContext.g.cs b/src/libs/SoundCloud/Generated/SoundCloud.JsonSerializerContext.g.cs index 0e30005..2919455 100644 --- a/src/libs/SoundCloud/Generated/SoundCloud.JsonSerializerContext.g.cs +++ b/src/libs/SoundCloud/Generated/SoundCloud.JsonSerializerContext.g.cs @@ -216,6 +216,7 @@ namespace SoundCloud typeof(global::SoundCloud.JsonConverters.UnixTimestampJsonConverter), })] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::SoundCloud.JsonSerializerContextTypes))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List), TypeInfoPropertyName = "SystemCollectionsGeneric_ObjectList")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::SoundCloud.OAuthToken))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::SoundCloud.OAuthTokenGrantType), TypeInfoPropertyName = "OAuthTokenGrantType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(string))] diff --git a/src/libs/SoundCloud/Generated/SoundCloud.JsonSerializerContextTypes.g.cs b/src/libs/SoundCloud/Generated/SoundCloud.JsonSerializerContextTypes.g.cs index d6e25e3..3511432 100644 --- a/src/libs/SoundCloud/Generated/SoundCloud.JsonSerializerContextTypes.g.cs +++ b/src/libs/SoundCloud/Generated/SoundCloud.JsonSerializerContextTypes.g.cs @@ -20,6 +20,11 @@ public sealed partial class JsonSerializerContextTypes /// public global::System.Collections.Generic.Dictionary? StringObjectDictionary { get; set; } + /// + /// Runtime object lists used by dynamic JSON payloads such as tool arguments. + /// + public global::System.Collections.Generic.List? ObjectList { get; set; } + /// /// ///