diff --git a/CSharpToJsonSchema.sln b/CSharpToJsonSchema.sln index 9c3eb17..dc76490 100755 --- a/CSharpToJsonSchema.sln +++ b/CSharpToJsonSchema.sln @@ -1,7 +1,6 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30204.135 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35506.116 d17.12 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E793AF18-4371-4EBD-96FC-195EB1798855}" ProjectSection(SolutionItems) = preProject @@ -25,9 +24,9 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{2D8B78DE-7269-417B-9D0B-8981FA513ACB}" ProjectSection(SolutionItems) = preProject .github\workflows\auto-merge.yml = .github\workflows\auto-merge.yml + .github\dependabot.yml = .github\dependabot.yml .github\workflows\dotnet.yml = .github\workflows\dotnet.yml .github\workflows\pull-request.yml = .github\workflows\pull-request.yml - .github\dependabot.yml = .github\dependabot.yml EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpToJsonSchema", "src\libs\CSharpToJsonSchema\CSharpToJsonSchema.csproj", "{93367DED-6C55-4267-923A-4412D03376FB}" @@ -80,10 +79,14 @@ Global {6167F915-83EB-42F9-929B-AD4719A55811}.Debug|Any CPU.Build.0 = Debug|Any CPU {6167F915-83EB-42F9-929B-AD4719A55811}.Release|Any CPU.ActiveCfg = Release|Any CPU {6167F915-83EB-42F9-929B-AD4719A55811}.Release|Any CPU.Build.0 = Release|Any CPU - {1942E3E5-F151-4C90-BECE-140AAD8C66DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1942E3E5-F151-4C90-BECE-140AAD8C66DE}.Debug|Any CPU.Build.0 = Debug|Any CPU {DC07C90E-A58C-44B3-82D2-E2EB8F777B92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DC07C90E-A58C-44B3-82D2-E2EB8F777B92}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DC07C90E-A58C-44B3-82D2-E2EB8F777B92}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DC07C90E-A58C-44B3-82D2-E2EB8F777B92}.Release|Any CPU.Build.0 = Release|Any CPU + {1942E3E5-F151-4C90-BECE-140AAD8C66DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1942E3E5-F151-4C90-BECE-140AAD8C66DE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1942E3E5-F151-4C90-BECE-140AAD8C66DE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1942E3E5-F151-4C90-BECE-140AAD8C66DE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/libs/CSharpToJsonSchema.Generators/Conversion/ToModels.cs b/src/libs/CSharpToJsonSchema.Generators/Conversion/ToModels.cs index f3b8a37..bbfa68a 100644 --- a/src/libs/CSharpToJsonSchema.Generators/Conversion/ToModels.cs +++ b/src/libs/CSharpToJsonSchema.Generators/Conversion/ToModels.cs @@ -136,6 +136,7 @@ public static InterfaceData PrepareMethodData( return string.Join(".", commonParts); } + private static OpenApiSchema ToParameterData(ITypeSymbol typeSymbol, string? name = null, string? description = null, bool isRequired = true) { diff --git a/src/libs/CSharpToJsonSchema.Generators/Sources.Method.MeaiTools.cs b/src/libs/CSharpToJsonSchema.Generators/Sources.Method.MeaiTools.cs index e785c8f..dc0b11b 100644 --- a/src/libs/CSharpToJsonSchema.Generators/Sources.Method.MeaiTools.cs +++ b/src/libs/CSharpToJsonSchema.Generators/Sources.Method.MeaiTools.cs @@ -30,7 +30,7 @@ public partial class {extensionsClassName} foreach (var tool in tools) {{ var call = calls[tool.Name]; - lst.Add(new global::CSharpToJsonSchema.MeaiFunction(tool, call)); + lst.Add(new global::CSharpToJsonSchema.MeaiFunction(tool, call, global::{@interface.Namespace}.{extensionsClassName}JsonSerializerContext.Default.Options)); }} return lst; }} @@ -59,7 +59,7 @@ public partial class {extensionsClassName} foreach (var tool in tools) {{ var call = calls[tool.Name]; - lst.Add(new global::CSharpToJsonSchema.MeaiFunction(tool, call)); + lst.Add(new global::CSharpToJsonSchema.MeaiFunction(tool, call, global::{@interface.Namespace}.{extensionsClassName}JsonSerializerContext.Default.Options)); }} return lst; }} diff --git a/src/libs/CSharpToJsonSchema/MeaiFunction.cs b/src/libs/CSharpToJsonSchema/MeaiFunction.cs index b8bfe10..a55d546 100644 --- a/src/libs/CSharpToJsonSchema/MeaiFunction.cs +++ b/src/libs/CSharpToJsonSchema/MeaiFunction.cs @@ -1,6 +1,8 @@ using System.Collections.ObjectModel; using System.Text.Json; using System.Text.Json.Nodes; +using System.Text.Json.Serialization; +using System.Text.Json.Serialization.Metadata; using Microsoft.Extensions.AI; namespace CSharpToJsonSchema; @@ -29,6 +31,8 @@ public partial class MeaiFunction : AIFunction /// Gets the description of the tool. /// public override string Description => _tool.Description; + + private JsonSerializerOptions? _options; /// /// Gets additional properties associated with the tool. @@ -40,7 +44,7 @@ public partial class MeaiFunction : AIFunction /// /// The tool associated with this function. /// The function to execute the tool with input arguments. - public MeaiFunction(Tool tool, Func> call) + public MeaiFunction(Tool tool, Func> call, JsonSerializerOptions? options = null) { this._tool = tool; this._call = call; @@ -53,8 +57,31 @@ public MeaiFunction(Tool tool, Func> cal { tool.AdditionalProperties.Add("Strict", true); } + + _options = options; } + + + private JsonSerializerOptions InitializeReflectionOptions() + { + #pragma warning disable IL2026, IL3050 // Reflection is used only when enabled + if(!JsonSerializer.IsReflectionEnabledByDefault) + throw new InvalidOperationException("JsonSerializer.IsReflectionEnabledByDefault is false, please pass in a JsonSerializerOptions instance."); + + _options = new JsonSerializerOptions() + { + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + PropertyNameCaseInsensitive = true, + Converters = { new JsonStringEnumConverter() }, + TypeInfoResolver = new DefaultJsonTypeInfoResolver() + }; + return _options; + #pragma warning restore IL2026, IL3050 // Reflection is used only when enabled + } + + /// /// Invokes the tool with the given arguments asynchronously. /// @@ -76,7 +103,7 @@ public MeaiFunction(Tool tool, Func> cal /// /// The arguments to be converted into a JSON string. /// A JSON string representation of the arguments. - private string GetArgsString(IEnumerable> arguments) + protected virtual string GetArgsString(IEnumerable> arguments) { var jsonObject = new JsonObject(); @@ -93,6 +120,43 @@ private string GetArgsString(IEnumerable> argument } else if (args.Value is JsonNode node) { + jsonObject[args.Key] = node; + } + else if (args.Value is JsonValue val) + { + jsonObject[args.Key] = val; + } + else if( args.Value is JsonObject obj) + { + jsonObject[args.Key] = obj; + } + else if (args.Value is JsonArray arr) + { + jsonObject[args.Key] = arr; + } + else + { + var type = args.Value?.GetType(); + // if(type.IsPrimitive) + // { + // jsonObject[args.Key] = JsonValue.Create(args.Value); + // } + // else + // { + if (_options == null) + { + #pragma warning disable IL2026, IL3050 // Reflection is used only when enabled + //Fallback to Reflection + //This will break the AOT, Hoping for the best, IChatClient implementation only send JSON classes + //Or Developer is using the code generator + _options = InitializeReflectionOptions(); + #pragma warning disable IL2026, IL3050 // Reflection is used only when enabled + } + var typeInfo = _options.GetTypeInfo(type); + + var str = JsonSerializer.Serialize(args.Value, typeInfo); + jsonObject[args.Key] = JsonNode.Parse(str); + //} } } diff --git a/src/libs/CSharpToJsonSchema/TypeToSchemaHelpers.cs b/src/libs/CSharpToJsonSchema/TypeToSchemaHelpers.cs index 193a806..9b12d0e 100644 --- a/src/libs/CSharpToJsonSchema/TypeToSchemaHelpers.cs +++ b/src/libs/CSharpToJsonSchema/TypeToSchemaHelpers.cs @@ -52,7 +52,7 @@ public static OpenApiSchema AsJsonSchema( JsonSerializerOptions? options = null) { type = type ?? throw new ArgumentNullException(nameof(type)); -#pragma warning disable IL2026 +#pragma warning disable IL2026, IL3050 var node = new JsonSerializerOptions { TypeInfoResolver = jsonTypeInfoResolver ?? new DefaultJsonTypeInfoResolver(), @@ -61,7 +61,7 @@ public static OpenApiSchema AsJsonSchema( TransformSchemaNode = (context, node) => node, TreatNullObliviousAsNonNullable = true, }); -#pragma warning restore IL2026 +#pragma warning restore IL2026, IL3050 var schema = Create(type, strict); if (schema.Type == "object") { diff --git a/src/tests/CSharpToJsonSchema.MeaiTests/CSharpToJsonSchema.MeaiTests.csproj b/src/tests/CSharpToJsonSchema.MeaiTests/CSharpToJsonSchema.MeaiTests.csproj index d7afcce..2c1f6e0 100644 --- a/src/tests/CSharpToJsonSchema.MeaiTests/CSharpToJsonSchema.MeaiTests.csproj +++ b/src/tests/CSharpToJsonSchema.MeaiTests/CSharpToJsonSchema.MeaiTests.csproj @@ -9,6 +9,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + all diff --git a/src/tests/CSharpToJsonSchema.MeaiTests/Meai_Tests.cs b/src/tests/CSharpToJsonSchema.MeaiTests/Meai_Tests.cs index e8113f1..c621a2f 100644 --- a/src/tests/CSharpToJsonSchema.MeaiTests/Meai_Tests.cs +++ b/src/tests/CSharpToJsonSchema.MeaiTests/Meai_Tests.cs @@ -1,5 +1,6 @@ using System.ClientModel; using CSharpToJsonSchema.MeaiTests.Services; +using GenerativeAI.Microsoft; using Microsoft.Extensions.AI; using OpenAI; using OpenAI.Models; @@ -34,7 +35,6 @@ public async Task ShouldInvokeTheFunctions() .Be(true); Console.WriteLine(response.Text); - } //[TestMethod] @@ -47,9 +47,10 @@ public async Task ShouldInvokeTheBookService() var client = new OpenAIClient(new ApiKeyCredential(key)); - Microsoft.Extensions.AI.OpenAIChatClient openAiClient = new OpenAIChatClient(client.GetChatClient("gpt-4o-mini")); + //Microsoft.Extensions.AI.OpenAIChatClient openAiClient = new OpenAIChatClient(client.GetChatClient("gpt-4o-mini")); - var chatClient = new Microsoft.Extensions.AI.FunctionInvokingChatClient(openAiClient); + var chatClient = new GenerativeAIChatClient(Environment.GetEnvironmentVariable("GOOGLE_API_KEY",EnvironmentVariableTarget.User)); + //var chatClient = new Microsoft.Extensions.AI.FunctionInvokingChatClient(openAiClient); var chatOptions = new ChatOptions(); var service = new BookStoreService(); @@ -63,6 +64,5 @@ public async Task ShouldInvokeTheBookService() .Be(true); Console.WriteLine(response.Text); - } } \ No newline at end of file diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/SnapshotTests.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/SnapshotTests.cs index 2d1c132..0fee3a0 100755 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/SnapshotTests.cs +++ b/src/tests/CSharpToJsonSchema.SnapshotTests/SnapshotTests.cs @@ -3,11 +3,11 @@ namespace CSharpToJsonSchema.SnapshotTests; [TestClass] public class ToolTests : VerifyBase { - // [TestMethod] - // public Task MethodFunction() - // { - // return this.CheckSourceAsync(H.Resources.MethodFunctionTools_cs.AsString()); - // } + [TestMethod] + public Task MethodFunction() + { + return this.CheckSourceAsync(H.Resources.MethodFunctionTools_cs.AsString()); + } [TestMethod] public Task Weather() diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.PropertyNames.g.received.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.PropertyNames.g.received.cs deleted file mode 100644 index c663807..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.PropertyNames.g.received.cs +++ /dev/null @@ -1,16 +0,0 @@ -//HintName: ToolsJsonSerializerContext.PropertyNames.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class ToolsJsonSerializerContext - { - private static readonly global::System.Text.Json.JsonEncodedText PropName_input = global::System.Text.Json.JsonEncodedText.Encode("input"); - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.PropertyNames.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.PropertyNames.g.verified.cs deleted file mode 100644 index 5f28270..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.PropertyNames.g.verified.cs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_NoReturnAsyncArgs.g.received.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_NoReturnAsyncArgs.g.received.cs deleted file mode 100644 index c3dbe2c..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_NoReturnAsyncArgs.g.received.cs +++ /dev/null @@ -1,96 +0,0 @@ -//HintName: ToolsJsonSerializerContext.SampleFunctionTool_NoReturnAsyncArgs.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class ToolsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _SampleFunctionTool_NoReturnAsyncArgs; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo SampleFunctionTool_NoReturnAsyncArgs - #nullable enable annotations - { - get => _SampleFunctionTool_NoReturnAsyncArgs ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_NoReturnAsyncArgs)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_SampleFunctionTool_NoReturnAsyncArgs(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues - { - ObjectCreator = () => new global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_NoReturnAsyncArgs(), - ObjectWithParameterizedConstructorCreator = null, - PropertyMetadataInitializer = _ => SampleFunctionTool_NoReturnAsyncArgsPropInit(options), - ConstructorParameterMetadataInitializer = null, - ConstructorAttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_NoReturnAsyncArgs).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty(), modifiers: null), - SerializeHandler = SampleFunctionTool_NoReturnAsyncArgsSerializeHandler, - }; - - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(options, objectInfo); - jsonTypeInfo.NumberHandling = null; - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - - private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] SampleFunctionTool_NoReturnAsyncArgsPropInit(global::System.Text.Json.JsonSerializerOptions options) - { - var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[1]; - - var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_NoReturnAsyncArgs), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_NoReturnAsyncArgs)obj).Input, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_NoReturnAsyncArgs)obj).Input = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Input", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_NoReturnAsyncArgs).GetProperty("Input", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty(), null), - }; - - properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info0); - - return properties; - } - - // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance - // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk. - private void SampleFunctionTool_NoReturnAsyncArgsSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_NoReturnAsyncArgs? value) - { - if (value is null) - { - writer.WriteNullValue(); - return; - } - - writer.WriteStartObject(); - - string __value_Input = ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_NoReturnAsyncArgs)value).Input; - if (__value_Input is not null) - { - writer.WriteString(PropName_input, __value_Input); - } - - writer.WriteEndObject(); - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_NoReturnAsyncArgs.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_NoReturnAsyncArgs.g.verified.cs deleted file mode 100644 index 5f28270..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_NoReturnAsyncArgs.g.verified.cs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_NoReturnAsyncArgs.g.received.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_NoReturnAsyncArgs.g.received.cs deleted file mode 100644 index 549a50c..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_NoReturnAsyncArgs.g.received.cs +++ /dev/null @@ -1,96 +0,0 @@ -//HintName: ToolsJsonSerializerContext.SampleFunctionTool_Static_NoReturnAsyncArgs.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class ToolsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _SampleFunctionTool_Static_NoReturnAsyncArgs; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo SampleFunctionTool_Static_NoReturnAsyncArgs - #nullable enable annotations - { - get => _SampleFunctionTool_Static_NoReturnAsyncArgs ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_NoReturnAsyncArgs)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_SampleFunctionTool_Static_NoReturnAsyncArgs(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues - { - ObjectCreator = () => new global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_NoReturnAsyncArgs(), - ObjectWithParameterizedConstructorCreator = null, - PropertyMetadataInitializer = _ => SampleFunctionTool_Static_NoReturnAsyncArgsPropInit(options), - ConstructorParameterMetadataInitializer = null, - ConstructorAttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_NoReturnAsyncArgs).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty(), modifiers: null), - SerializeHandler = SampleFunctionTool_Static_NoReturnAsyncArgsSerializeHandler, - }; - - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(options, objectInfo); - jsonTypeInfo.NumberHandling = null; - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - - private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] SampleFunctionTool_Static_NoReturnAsyncArgsPropInit(global::System.Text.Json.JsonSerializerOptions options) - { - var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[1]; - - var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_NoReturnAsyncArgs), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_NoReturnAsyncArgs)obj).Input, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_NoReturnAsyncArgs)obj).Input = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Input", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_NoReturnAsyncArgs).GetProperty("Input", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty(), null), - }; - - properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info0); - - return properties; - } - - // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance - // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk. - private void SampleFunctionTool_Static_NoReturnAsyncArgsSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_NoReturnAsyncArgs? value) - { - if (value is null) - { - writer.WriteNullValue(); - return; - } - - writer.WriteStartObject(); - - string __value_Input = ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_NoReturnAsyncArgs)value).Input; - if (__value_Input is not null) - { - writer.WriteString(PropName_input, __value_Input); - } - - writer.WriteEndObject(); - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_NoReturnAsyncArgs.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_NoReturnAsyncArgs.g.verified.cs deleted file mode 100644 index 5f28270..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_NoReturnAsyncArgs.g.verified.cs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_StringArgs.g.received.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_StringArgs.g.received.cs deleted file mode 100644 index 0bcbc30..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_StringArgs.g.received.cs +++ /dev/null @@ -1,96 +0,0 @@ -//HintName: ToolsJsonSerializerContext.SampleFunctionTool_Static_StringArgs.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class ToolsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _SampleFunctionTool_Static_StringArgs; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo SampleFunctionTool_Static_StringArgs - #nullable enable annotations - { - get => _SampleFunctionTool_Static_StringArgs ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_StringArgs)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_SampleFunctionTool_Static_StringArgs(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues - { - ObjectCreator = () => new global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_StringArgs(), - ObjectWithParameterizedConstructorCreator = null, - PropertyMetadataInitializer = _ => SampleFunctionTool_Static_StringArgsPropInit(options), - ConstructorParameterMetadataInitializer = null, - ConstructorAttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_StringArgs).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty(), modifiers: null), - SerializeHandler = SampleFunctionTool_Static_StringArgsSerializeHandler, - }; - - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(options, objectInfo); - jsonTypeInfo.NumberHandling = null; - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - - private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] SampleFunctionTool_Static_StringArgsPropInit(global::System.Text.Json.JsonSerializerOptions options) - { - var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[1]; - - var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_StringArgs), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_StringArgs)obj).Input, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_StringArgs)obj).Input = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Input", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_StringArgs).GetProperty("Input", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty(), null), - }; - - properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info0); - - return properties; - } - - // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance - // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk. - private void SampleFunctionTool_Static_StringArgsSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_StringArgs? value) - { - if (value is null) - { - writer.WriteNullValue(); - return; - } - - writer.WriteStartObject(); - - string __value_Input = ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_StringArgs)value).Input; - if (__value_Input is not null) - { - writer.WriteString(PropName_input, __value_Input); - } - - writer.WriteEndObject(); - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_StringArgs.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_StringArgs.g.verified.cs deleted file mode 100644 index 5f28270..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_StringArgs.g.verified.cs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_StringAsyncArgs.g.received.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_StringAsyncArgs.g.received.cs deleted file mode 100644 index cb6d762..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_StringAsyncArgs.g.received.cs +++ /dev/null @@ -1,96 +0,0 @@ -//HintName: ToolsJsonSerializerContext.SampleFunctionTool_Static_StringAsyncArgs.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class ToolsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _SampleFunctionTool_Static_StringAsyncArgs; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo SampleFunctionTool_Static_StringAsyncArgs - #nullable enable annotations - { - get => _SampleFunctionTool_Static_StringAsyncArgs ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_StringAsyncArgs)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_SampleFunctionTool_Static_StringAsyncArgs(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues - { - ObjectCreator = () => new global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_StringAsyncArgs(), - ObjectWithParameterizedConstructorCreator = null, - PropertyMetadataInitializer = _ => SampleFunctionTool_Static_StringAsyncArgsPropInit(options), - ConstructorParameterMetadataInitializer = null, - ConstructorAttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_StringAsyncArgs).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty(), modifiers: null), - SerializeHandler = SampleFunctionTool_Static_StringAsyncArgsSerializeHandler, - }; - - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(options, objectInfo); - jsonTypeInfo.NumberHandling = null; - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - - private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] SampleFunctionTool_Static_StringAsyncArgsPropInit(global::System.Text.Json.JsonSerializerOptions options) - { - var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[1]; - - var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_StringAsyncArgs), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_StringAsyncArgs)obj).Input, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_StringAsyncArgs)obj).Input = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Input", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_StringAsyncArgs).GetProperty("Input", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty(), null), - }; - - properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info0); - - return properties; - } - - // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance - // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk. - private void SampleFunctionTool_Static_StringAsyncArgsSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_StringAsyncArgs? value) - { - if (value is null) - { - writer.WriteNullValue(); - return; - } - - writer.WriteStartObject(); - - string __value_Input = ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_StringAsyncArgs)value).Input; - if (__value_Input is not null) - { - writer.WriteString(PropName_input, __value_Input); - } - - writer.WriteEndObject(); - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_StringAsyncArgs.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_StringAsyncArgs.g.verified.cs deleted file mode 100644 index 5f28270..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_StringAsyncArgs.g.verified.cs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_VoidArgs.g.received.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_VoidArgs.g.received.cs deleted file mode 100644 index c6d5189..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_VoidArgs.g.received.cs +++ /dev/null @@ -1,96 +0,0 @@ -//HintName: ToolsJsonSerializerContext.SampleFunctionTool_Static_VoidArgs.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class ToolsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _SampleFunctionTool_Static_VoidArgs; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo SampleFunctionTool_Static_VoidArgs - #nullable enable annotations - { - get => _SampleFunctionTool_Static_VoidArgs ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_VoidArgs)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_SampleFunctionTool_Static_VoidArgs(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues - { - ObjectCreator = () => new global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_VoidArgs(), - ObjectWithParameterizedConstructorCreator = null, - PropertyMetadataInitializer = _ => SampleFunctionTool_Static_VoidArgsPropInit(options), - ConstructorParameterMetadataInitializer = null, - ConstructorAttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_VoidArgs).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty(), modifiers: null), - SerializeHandler = SampleFunctionTool_Static_VoidArgsSerializeHandler, - }; - - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(options, objectInfo); - jsonTypeInfo.NumberHandling = null; - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - - private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] SampleFunctionTool_Static_VoidArgsPropInit(global::System.Text.Json.JsonSerializerOptions options) - { - var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[1]; - - var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_VoidArgs), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_VoidArgs)obj).Input, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_VoidArgs)obj).Input = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Input", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_VoidArgs).GetProperty("Input", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty(), null), - }; - - properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info0); - - return properties; - } - - // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance - // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk. - private void SampleFunctionTool_Static_VoidArgsSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_VoidArgs? value) - { - if (value is null) - { - writer.WriteNullValue(); - return; - } - - writer.WriteStartObject(); - - string __value_Input = ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_Static_VoidArgs)value).Input; - if (__value_Input is not null) - { - writer.WriteString(PropName_input, __value_Input); - } - - writer.WriteEndObject(); - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_VoidArgs.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_VoidArgs.g.verified.cs deleted file mode 100644 index 5f28270..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_Static_VoidArgs.g.verified.cs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_StringArgs.g.received.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_StringArgs.g.received.cs deleted file mode 100644 index 6cf889f..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_StringArgs.g.received.cs +++ /dev/null @@ -1,96 +0,0 @@ -//HintName: ToolsJsonSerializerContext.SampleFunctionTool_StringArgs.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class ToolsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _SampleFunctionTool_StringArgs; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo SampleFunctionTool_StringArgs - #nullable enable annotations - { - get => _SampleFunctionTool_StringArgs ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_StringArgs)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_SampleFunctionTool_StringArgs(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues - { - ObjectCreator = () => new global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_StringArgs(), - ObjectWithParameterizedConstructorCreator = null, - PropertyMetadataInitializer = _ => SampleFunctionTool_StringArgsPropInit(options), - ConstructorParameterMetadataInitializer = null, - ConstructorAttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_StringArgs).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty(), modifiers: null), - SerializeHandler = SampleFunctionTool_StringArgsSerializeHandler, - }; - - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(options, objectInfo); - jsonTypeInfo.NumberHandling = null; - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - - private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] SampleFunctionTool_StringArgsPropInit(global::System.Text.Json.JsonSerializerOptions options) - { - var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[1]; - - var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_StringArgs), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_StringArgs)obj).Input, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_StringArgs)obj).Input = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Input", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_StringArgs).GetProperty("Input", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty(), null), - }; - - properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info0); - - return properties; - } - - // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance - // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk. - private void SampleFunctionTool_StringArgsSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_StringArgs? value) - { - if (value is null) - { - writer.WriteNullValue(); - return; - } - - writer.WriteStartObject(); - - string __value_Input = ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_StringArgs)value).Input; - if (__value_Input is not null) - { - writer.WriteString(PropName_input, __value_Input); - } - - writer.WriteEndObject(); - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_StringArgs.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_StringArgs.g.verified.cs deleted file mode 100644 index 5f28270..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_StringArgs.g.verified.cs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_StringAsyncArgs.g.received.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_StringAsyncArgs.g.received.cs deleted file mode 100644 index 85f49f9..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_StringAsyncArgs.g.received.cs +++ /dev/null @@ -1,96 +0,0 @@ -//HintName: ToolsJsonSerializerContext.SampleFunctionTool_StringAsyncArgs.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class ToolsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _SampleFunctionTool_StringAsyncArgs; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo SampleFunctionTool_StringAsyncArgs - #nullable enable annotations - { - get => _SampleFunctionTool_StringAsyncArgs ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_StringAsyncArgs)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_SampleFunctionTool_StringAsyncArgs(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues - { - ObjectCreator = () => new global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_StringAsyncArgs(), - ObjectWithParameterizedConstructorCreator = null, - PropertyMetadataInitializer = _ => SampleFunctionTool_StringAsyncArgsPropInit(options), - ConstructorParameterMetadataInitializer = null, - ConstructorAttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_StringAsyncArgs).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty(), modifiers: null), - SerializeHandler = SampleFunctionTool_StringAsyncArgsSerializeHandler, - }; - - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(options, objectInfo); - jsonTypeInfo.NumberHandling = null; - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - - private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] SampleFunctionTool_StringAsyncArgsPropInit(global::System.Text.Json.JsonSerializerOptions options) - { - var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[1]; - - var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_StringAsyncArgs), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_StringAsyncArgs)obj).Input, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_StringAsyncArgs)obj).Input = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Input", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_StringAsyncArgs).GetProperty("Input", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty(), null), - }; - - properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info0); - - return properties; - } - - // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance - // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk. - private void SampleFunctionTool_StringAsyncArgsSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_StringAsyncArgs? value) - { - if (value is null) - { - writer.WriteNullValue(); - return; - } - - writer.WriteStartObject(); - - string __value_Input = ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_StringAsyncArgs)value).Input; - if (__value_Input is not null) - { - writer.WriteString(PropName_input, __value_Input); - } - - writer.WriteEndObject(); - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_StringAsyncArgs.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_StringAsyncArgs.g.verified.cs deleted file mode 100644 index 5f28270..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_StringAsyncArgs.g.verified.cs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_VoidArgs.g.received.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_VoidArgs.g.received.cs deleted file mode 100644 index d1985fd..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_VoidArgs.g.received.cs +++ /dev/null @@ -1,96 +0,0 @@ -//HintName: ToolsJsonSerializerContext.SampleFunctionTool_VoidArgs.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class ToolsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _SampleFunctionTool_VoidArgs; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo SampleFunctionTool_VoidArgs - #nullable enable annotations - { - get => _SampleFunctionTool_VoidArgs ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_VoidArgs)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_SampleFunctionTool_VoidArgs(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues - { - ObjectCreator = () => new global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_VoidArgs(), - ObjectWithParameterizedConstructorCreator = null, - PropertyMetadataInitializer = _ => SampleFunctionTool_VoidArgsPropInit(options), - ConstructorParameterMetadataInitializer = null, - ConstructorAttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_VoidArgs).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty(), modifiers: null), - SerializeHandler = SampleFunctionTool_VoidArgsSerializeHandler, - }; - - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(options, objectInfo); - jsonTypeInfo.NumberHandling = null; - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - - private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] SampleFunctionTool_VoidArgsPropInit(global::System.Text.Json.JsonSerializerOptions options) - { - var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[1]; - - var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_VoidArgs), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_VoidArgs)obj).Input, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_VoidArgs)obj).Input = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Input", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_VoidArgs).GetProperty("Input", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty(), null), - }; - - properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info0); - - return properties; - } - - // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance - // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk. - private void SampleFunctionTool_VoidArgsSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_VoidArgs? value) - { - if (value is null) - { - writer.WriteNullValue(); - return; - } - - writer.WriteStartObject(); - - string __value_Input = ((global::CSharpToJsonSchema.IntegrationTests.SampleFunctionTool_VoidArgs)value).Input; - if (__value_Input is not null) - { - writer.WriteString(PropName_input, __value_Input); - } - - writer.WriteEndObject(); - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_VoidArgs.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_VoidArgs.g.verified.cs deleted file mode 100644 index 5f28270..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.SampleFunctionTool_VoidArgs.g.verified.cs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.String.g.received.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.String.g.received.cs deleted file mode 100644 index 3a229f3..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.String.g.received.cs +++ /dev/null @@ -1,37 +0,0 @@ -//HintName: ToolsJsonSerializerContext.String.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class ToolsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _String; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo String - #nullable enable annotations - { - get => _String ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(string)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_String(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.StringConverter); - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.String.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.String.g.verified.cs deleted file mode 100644 index 5f28270..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.MethodFunction#ToolsJsonSerializerContext.String.g.verified.cs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Boolean.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Boolean.g.verified.cs deleted file mode 100644 index c12002c..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Boolean.g.verified.cs +++ /dev/null @@ -1,37 +0,0 @@ -//HintName: IVariousTypesTools.Boolean.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class VariousTypesToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _Boolean; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Boolean - #nullable enable annotations - { - get => _Boolean ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(bool)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_Boolean(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.BooleanConverter); - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Calls.generated.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Calls.generated.verified.cs deleted file mode 100644 index 8fc213e..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Calls.generated.verified.cs +++ /dev/null @@ -1,383 +0,0 @@ -//HintName: IVariousTypesTools.Calls.generated.cs -#nullable enable - -namespace CSharpToJsonSchema.IntegrationTests -{ - public class GetCurrentWeather3Args - { - - [global::System.ComponentModel.Description("")] - public long Parameter1 { get; set; } - [global::System.ComponentModel.Description("")] - public int Parameter2 { get; set; } - [global::System.ComponentModel.Description("")] - public double Parameter3 { get; set; } - [global::System.ComponentModel.Description("")] - public float Parameter4 { get; set; } - [global::System.ComponentModel.Description("")] - public bool Parameter5 { get; set; } - [global::System.ComponentModel.Description("")] - public System.DateTime DateTime { get; set; } - [global::System.ComponentModel.Description("")] - public System.DateOnly Date { get; set; } - } - - public class SetValueArgs - { - - [global::System.ComponentModel.Description("")] - public int Value { get; set; } - } - - public class GetValueArgs - { - - - } - - public class SetValueAsyncArgs - { - - [global::System.ComponentModel.Description("")] - public int Value { get; set; } - } - - public class GetValueAsyncArgs - { - - - } - - public static partial class VariousTypesToolsExtensions - { - public static global::System.Collections.Generic.IReadOnlyDictionary>> AsCalls(this IVariousTypesTools service) - { - return new global::System.Collections.Generic.Dictionary>> - { - ["GetCurrentWeather3"] = (json, _) => - { - return global::System.Threading.Tasks.Task.FromResult(service.CallGetCurrentWeather3(json)); - }, - - ["GetValue"] = (json, _) => - { - return global::System.Threading.Tasks.Task.FromResult(service.CallGetValue(json)); - }, - ["SetValue"] = (json, _) => - { - service.CallSetValue(json); - - return global::System.Threading.Tasks.Task.FromResult(string.Empty); - }, - ["GetValueAsync"] = async (json, cancellationToken) => - { - return await service.CallGetValueAsync(json, cancellationToken); - }, - ["SetValueAsync"] = async (json, cancellationToken) => - { - await service.CallSetValueAsync(json, cancellationToken); - - return string.Empty; - }, - }; - } - - #pragma warning disable IL2026, IL3050 - public static GetCurrentWeather3Args AsGetCurrentWeather3Args( - this IVariousTypesTools functions, - string json) - { - #if NET6_0_OR_GREATER - if(global::System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault) - { - - return global::System.Text.Json.JsonSerializer.Deserialize(json, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = {{ new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }} - }) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - - } - else - { - return global::System.Text.Json.JsonSerializer.Deserialize(json, global::CSharpToJsonSchema.IntegrationTests.VariousTypesToolsExtensionsJsonSerializerContext.Default.GetCurrentWeather3Args) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - } - #else - return - global::System.Text.Json.JsonSerializer.Deserialize(json, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = {{ new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }} - }) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - #endif - } - #pragma warning restore IL2026, IL3050 - - #pragma warning disable IL2026, IL3050 - public static SetValueArgs AsSetValueArgs( - this IVariousTypesTools functions, - string json) - { - #if NET6_0_OR_GREATER - if(global::System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault) - { - - return global::System.Text.Json.JsonSerializer.Deserialize(json, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = {{ new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }} - }) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - - } - else - { - return global::System.Text.Json.JsonSerializer.Deserialize(json, global::CSharpToJsonSchema.IntegrationTests.VariousTypesToolsExtensionsJsonSerializerContext.Default.SetValueArgs) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - } - #else - return - global::System.Text.Json.JsonSerializer.Deserialize(json, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = {{ new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }} - }) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - #endif - } - #pragma warning restore IL2026, IL3050 - - #pragma warning disable IL2026, IL3050 - public static GetValueArgs AsGetValueArgs( - this IVariousTypesTools functions, - string json) - { - #if NET6_0_OR_GREATER - if(global::System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault) - { - - return global::System.Text.Json.JsonSerializer.Deserialize(json, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = {{ new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }} - }) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - - } - else - { - return global::System.Text.Json.JsonSerializer.Deserialize(json, global::CSharpToJsonSchema.IntegrationTests.VariousTypesToolsExtensionsJsonSerializerContext.Default.GetValueArgs) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - } - #else - return - global::System.Text.Json.JsonSerializer.Deserialize(json, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = {{ new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }} - }) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - #endif - } - #pragma warning restore IL2026, IL3050 - - #pragma warning disable IL2026, IL3050 - public static SetValueAsyncArgs AsSetValueAsyncArgs( - this IVariousTypesTools functions, - string json) - { - #if NET6_0_OR_GREATER - if(global::System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault) - { - - return global::System.Text.Json.JsonSerializer.Deserialize(json, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = {{ new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }} - }) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - - } - else - { - return global::System.Text.Json.JsonSerializer.Deserialize(json, global::CSharpToJsonSchema.IntegrationTests.VariousTypesToolsExtensionsJsonSerializerContext.Default.SetValueAsyncArgs) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - } - #else - return - global::System.Text.Json.JsonSerializer.Deserialize(json, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = {{ new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }} - }) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - #endif - } - #pragma warning restore IL2026, IL3050 - - #pragma warning disable IL2026, IL3050 - public static GetValueAsyncArgs AsGetValueAsyncArgs( - this IVariousTypesTools functions, - string json) - { - #if NET6_0_OR_GREATER - if(global::System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault) - { - - return global::System.Text.Json.JsonSerializer.Deserialize(json, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = {{ new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }} - }) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - - } - else - { - return global::System.Text.Json.JsonSerializer.Deserialize(json, global::CSharpToJsonSchema.IntegrationTests.VariousTypesToolsExtensionsJsonSerializerContext.Default.GetValueAsyncArgs) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - } - #else - return - global::System.Text.Json.JsonSerializer.Deserialize(json, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = {{ new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }} - }) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - #endif - } - #pragma warning restore IL2026, IL3050 - - #pragma warning disable IL2026, IL3050 - public static string CallGetCurrentWeather3(this IVariousTypesTools functions, string json) - { - var args = functions.AsGetCurrentWeather3Args(json); - var jsonResult = functions.GetCurrentWeather3(args.Parameter1, args.Parameter2, args.Parameter3, args.Parameter4, args.Parameter5, args.DateTime, args.Date); - - #if NET6_0_OR_GREATER - if(global::System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault) - { - - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = { new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }, - }); - - } - else - { - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, global::CSharpToJsonSchema.IntegrationTests.VariousTypesToolsExtensionsJsonSerializerContext.Default.GetTypeInfo(jsonResult.GetType())); - } - #else - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = { new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }, - }); - #endif - } - #pragma warning restore IL2026, IL3050 - - #pragma warning disable IL2026, IL3050 - public static string CallGetValue(this IVariousTypesTools functions, string json) - { - var args = functions.AsGetValueArgs(json); - var jsonResult = functions.GetValue(); - - #if NET6_0_OR_GREATER - if(global::System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault) - { - - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = { new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }, - }); - - } - else - { - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, global::CSharpToJsonSchema.IntegrationTests.VariousTypesToolsExtensionsJsonSerializerContext.Default.GetTypeInfo(jsonResult.GetType())); - } - #else - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = { new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }, - }); - #endif - } - #pragma warning restore IL2026, IL3050 - public static void CallSetValue(this IVariousTypesTools functions, string json) - { - var args = functions.AsSetValueArgs(json); - functions.SetValue(args.Value); - } - - #pragma warning disable IL2026, IL3050 - public static async global::System.Threading.Tasks.Task CallGetValueAsync( - this IVariousTypesTools functions, - string json, - global::System.Threading.CancellationToken cancellationToken = default) - { - var args = functions.AsGetValueAsyncArgs(json); - var jsonResult = await functions.GetValueAsync(cancellationToken); - - #if NET6_0_OR_GREATER - if(global::System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault) - { - - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = { new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }, - }); - } - else - { - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, global::CSharpToJsonSchema.IntegrationTests.VariousTypesToolsExtensionsJsonSerializerContext.Default.GetTypeInfo(jsonResult.GetType())); - } - #else - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = { new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }, - }); - #endif - - } - #pragma warning restore IL2026, IL3050 - - public static async global::System.Threading.Tasks.Task CallSetValueAsync( - this IVariousTypesTools functions, - string json, - global::System.Threading.CancellationToken cancellationToken = default) - { - var args = functions.AsSetValueAsyncArgs(json); - await functions.SetValueAsync(args.Value, cancellationToken); - - return string.Empty; - } - - public static async global::System.Threading.Tasks.Task CallAsync( - this IVariousTypesTools service, - string functionName, - string argumentsAsJson, - global::System.Threading.CancellationToken cancellationToken = default) - { - var calls = service.AsCalls(); - var func = calls[functionName]; - - return await func(argumentsAsJson, cancellationToken); - } - } - - public partial class VariousTypesToolsExtensionsJsonSerializerContext: global::System.Text.Json.Serialization.JsonSerializerContext - { - } -} \ No newline at end of file diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.DateOnly.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.DateOnly.g.verified.cs deleted file mode 100644 index b10c67b..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.DateOnly.g.verified.cs +++ /dev/null @@ -1,37 +0,0 @@ -//HintName: IVariousTypesTools.DateOnly.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class VariousTypesToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _DateOnly; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo DateOnly - #nullable enable annotations - { - get => _DateOnly ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::System.DateOnly)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_DateOnly(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.DateOnlyConverter); - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.DateTime.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.DateTime.g.verified.cs deleted file mode 100644 index 23a8cf3..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.DateTime.g.verified.cs +++ /dev/null @@ -1,37 +0,0 @@ -//HintName: IVariousTypesTools.DateTime.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class VariousTypesToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _DateTime; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo DateTime - #nullable enable annotations - { - get => _DateTime ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::System.DateTime)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_DateTime(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.DateTimeConverter); - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Double.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Double.g.verified.cs deleted file mode 100644 index 0e044a3..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Double.g.verified.cs +++ /dev/null @@ -1,37 +0,0 @@ -//HintName: IVariousTypesTools.Double.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class VariousTypesToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _Double; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Double - #nullable enable annotations - { - get => _Double ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(double)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_Double(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.DoubleConverter); - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.GetCurrentWeather3Args.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.GetCurrentWeather3Args.g.verified.cs deleted file mode 100644 index 0bf5111..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.GetCurrentWeather3Args.g.verified.cs +++ /dev/null @@ -1,219 +0,0 @@ -//HintName: IVariousTypesTools.GetCurrentWeather3Args.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class VariousTypesToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _GetCurrentWeather3Args; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo GetCurrentWeather3Args - #nullable enable annotations - { - get => _GetCurrentWeather3Args ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_GetCurrentWeather3Args(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues - { - ObjectCreator = () => new global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args(), - ObjectWithParameterizedConstructorCreator = null, - PropertyMetadataInitializer = _ => GetCurrentWeather3ArgsPropInit(options), - ConstructorParameterMetadataInitializer = null, - ConstructorAttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty(), modifiers: null), - SerializeHandler = GetCurrentWeather3ArgsSerializeHandler, - }; - - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(options, objectInfo); - jsonTypeInfo.NumberHandling = null; - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - - private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] GetCurrentWeather3ArgsPropInit(global::System.Text.Json.JsonSerializerOptions options) - { - var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[7]; - - var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)obj).Parameter1, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)obj).Parameter1 = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Parameter1", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args).GetProperty("Parameter1", InstanceMemberBindingFlags, null, typeof(long), global::System.Array.Empty(), null), - }; - - properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info0); - - var info1 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)obj).Parameter2, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)obj).Parameter2 = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Parameter2", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args).GetProperty("Parameter2", InstanceMemberBindingFlags, null, typeof(int), global::System.Array.Empty(), null), - }; - - properties[1] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info1); - - var info2 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)obj).Parameter3, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)obj).Parameter3 = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Parameter3", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args).GetProperty("Parameter3", InstanceMemberBindingFlags, null, typeof(double), global::System.Array.Empty(), null), - }; - - properties[2] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info2); - - var info3 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)obj).Parameter4, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)obj).Parameter4 = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Parameter4", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args).GetProperty("Parameter4", InstanceMemberBindingFlags, null, typeof(float), global::System.Array.Empty(), null), - }; - - properties[3] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info3); - - var info4 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)obj).Parameter5, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)obj).Parameter5 = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Parameter5", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args).GetProperty("Parameter5", InstanceMemberBindingFlags, null, typeof(bool), global::System.Array.Empty(), null), - }; - - properties[4] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info4); - - var info5 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)obj).DateTime, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)obj).DateTime = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "DateTime", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args).GetProperty("DateTime", InstanceMemberBindingFlags, null, typeof(global::System.DateTime), global::System.Array.Empty(), null), - }; - - properties[5] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info5); - - var info6 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)obj).Date, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)obj).Date = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Date", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args).GetProperty("Date", InstanceMemberBindingFlags, null, typeof(global::System.DateOnly), global::System.Array.Empty(), null), - }; - - properties[6] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info6); - - return properties; - } - - // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance - // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk. - private void GetCurrentWeather3ArgsSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args? value) - { - if (value is null) - { - writer.WriteNullValue(); - return; - } - - writer.WriteStartObject(); - - writer.WriteNumber(PropName_parameter1, ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)value).Parameter1); - writer.WriteNumber(PropName_parameter2, ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)value).Parameter2); - writer.WriteNumber(PropName_parameter3, ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)value).Parameter3); - writer.WriteNumber(PropName_parameter4, ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)value).Parameter4); - writer.WriteBoolean(PropName_parameter5, ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)value).Parameter5); - writer.WriteString(PropName_dateTime, ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)value).DateTime); - writer.WritePropertyName(PropName_date); - global::System.Text.Json.JsonSerializer.Serialize(writer, ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)value).Date, DateOnly); - - writer.WriteEndObject(); - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.GetJsonTypeInfo.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.GetJsonTypeInfo.g.verified.cs deleted file mode 100644 index 1edd614..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.GetJsonTypeInfo.g.verified.cs +++ /dev/null @@ -1,74 +0,0 @@ -//HintName: IVariousTypesTools.GetJsonTypeInfo.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class VariousTypesToolsExtensionsJsonSerializerContext : global::System.Text.Json.Serialization.Metadata.IJsonTypeInfoResolver - { - /// - public override global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? GetTypeInfo(global::System.Type type) - { - Options.TryGetTypeInfo(type, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? typeInfo); - return typeInfo; - } - - global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? global::System.Text.Json.Serialization.Metadata.IJsonTypeInfoResolver.GetTypeInfo(global::System.Type type, global::System.Text.Json.JsonSerializerOptions options) - { - if (type == typeof(bool)) - { - return Create_Boolean(options); - } - if (type == typeof(double)) - { - return Create_Double(options); - } - if (type == typeof(float)) - { - return Create_Single(options); - } - if (type == typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather3Args)) - { - return Create_GetCurrentWeather3Args(options); - } - if (type == typeof(global::CSharpToJsonSchema.IntegrationTests.GetValueArgs)) - { - return Create_GetValueArgs(options); - } - if (type == typeof(global::CSharpToJsonSchema.IntegrationTests.GetValueAsyncArgs)) - { - return Create_GetValueAsyncArgs(options); - } - if (type == typeof(global::CSharpToJsonSchema.IntegrationTests.SetValueArgs)) - { - return Create_SetValueArgs(options); - } - if (type == typeof(global::CSharpToJsonSchema.IntegrationTests.SetValueAsyncArgs)) - { - return Create_SetValueAsyncArgs(options); - } - if (type == typeof(global::System.DateOnly)) - { - return Create_DateOnly(options); - } - if (type == typeof(global::System.DateTime)) - { - return Create_DateTime(options); - } - if (type == typeof(int)) - { - return Create_Int32(options); - } - if (type == typeof(long)) - { - return Create_Int64(options); - } - return null; - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.GetValueArgs.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.GetValueArgs.g.verified.cs deleted file mode 100644 index 32bb28a..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.GetValueArgs.g.verified.cs +++ /dev/null @@ -1,71 +0,0 @@ -//HintName: IVariousTypesTools.GetValueArgs.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class VariousTypesToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _GetValueArgs; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo GetValueArgs - #nullable enable annotations - { - get => _GetValueArgs ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.GetValueArgs)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_GetValueArgs(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues - { - ObjectCreator = () => new global::CSharpToJsonSchema.IntegrationTests.GetValueArgs(), - ObjectWithParameterizedConstructorCreator = null, - PropertyMetadataInitializer = _ => GetValueArgsPropInit(options), - ConstructorParameterMetadataInitializer = null, - ConstructorAttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetValueArgs).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty(), modifiers: null), - SerializeHandler = GetValueArgsSerializeHandler, - }; - - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(options, objectInfo); - jsonTypeInfo.NumberHandling = null; - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - - private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] GetValueArgsPropInit(global::System.Text.Json.JsonSerializerOptions options) - { - var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[0]; - - return properties; - } - - // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance - // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk. - private void GetValueArgsSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::CSharpToJsonSchema.IntegrationTests.GetValueArgs? value) - { - if (value is null) - { - writer.WriteNullValue(); - return; - } - - writer.WriteStartObject(); - - - writer.WriteEndObject(); - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.GetValueAsyncArgs.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.GetValueAsyncArgs.g.verified.cs deleted file mode 100644 index 54c8114..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.GetValueAsyncArgs.g.verified.cs +++ /dev/null @@ -1,71 +0,0 @@ -//HintName: IVariousTypesTools.GetValueAsyncArgs.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class VariousTypesToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _GetValueAsyncArgs; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo GetValueAsyncArgs - #nullable enable annotations - { - get => _GetValueAsyncArgs ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.GetValueAsyncArgs)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_GetValueAsyncArgs(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues - { - ObjectCreator = () => new global::CSharpToJsonSchema.IntegrationTests.GetValueAsyncArgs(), - ObjectWithParameterizedConstructorCreator = null, - PropertyMetadataInitializer = _ => GetValueAsyncArgsPropInit(options), - ConstructorParameterMetadataInitializer = null, - ConstructorAttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetValueAsyncArgs).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty(), modifiers: null), - SerializeHandler = GetValueAsyncArgsSerializeHandler, - }; - - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(options, objectInfo); - jsonTypeInfo.NumberHandling = null; - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - - private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] GetValueAsyncArgsPropInit(global::System.Text.Json.JsonSerializerOptions options) - { - var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[0]; - - return properties; - } - - // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance - // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk. - private void GetValueAsyncArgsSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::CSharpToJsonSchema.IntegrationTests.GetValueAsyncArgs? value) - { - if (value is null) - { - writer.WriteNullValue(); - return; - } - - writer.WriteStartObject(); - - - writer.WriteEndObject(); - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Int32.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Int32.g.verified.cs deleted file mode 100644 index 91818c8..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Int32.g.verified.cs +++ /dev/null @@ -1,37 +0,0 @@ -//HintName: IVariousTypesTools.Int32.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class VariousTypesToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _Int32; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Int32 - #nullable enable annotations - { - get => _Int32 ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(int)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_Int32(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.Int32Converter); - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Int64.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Int64.g.verified.cs deleted file mode 100644 index 2263c42..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Int64.g.verified.cs +++ /dev/null @@ -1,37 +0,0 @@ -//HintName: IVariousTypesTools.Int64.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class VariousTypesToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _Int64; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Int64 - #nullable enable annotations - { - get => _Int64 ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(long)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_Int64(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.Int64Converter); - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.PropertyNames.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.PropertyNames.g.verified.cs deleted file mode 100644 index d34ba5a..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.PropertyNames.g.verified.cs +++ /dev/null @@ -1,23 +0,0 @@ -//HintName: IVariousTypesTools.PropertyNames.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class VariousTypesToolsExtensionsJsonSerializerContext - { - private static readonly global::System.Text.Json.JsonEncodedText PropName_parameter1 = global::System.Text.Json.JsonEncodedText.Encode("parameter1"); - private static readonly global::System.Text.Json.JsonEncodedText PropName_parameter2 = global::System.Text.Json.JsonEncodedText.Encode("parameter2"); - private static readonly global::System.Text.Json.JsonEncodedText PropName_parameter3 = global::System.Text.Json.JsonEncodedText.Encode("parameter3"); - private static readonly global::System.Text.Json.JsonEncodedText PropName_parameter4 = global::System.Text.Json.JsonEncodedText.Encode("parameter4"); - private static readonly global::System.Text.Json.JsonEncodedText PropName_parameter5 = global::System.Text.Json.JsonEncodedText.Encode("parameter5"); - private static readonly global::System.Text.Json.JsonEncodedText PropName_dateTime = global::System.Text.Json.JsonEncodedText.Encode("dateTime"); - private static readonly global::System.Text.Json.JsonEncodedText PropName_date = global::System.Text.Json.JsonEncodedText.Encode("date"); - private static readonly global::System.Text.Json.JsonEncodedText PropName_value = global::System.Text.Json.JsonEncodedText.Encode("value"); - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.SetValueArgs.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.SetValueArgs.g.verified.cs deleted file mode 100644 index d83f8a2..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.SetValueArgs.g.verified.cs +++ /dev/null @@ -1,92 +0,0 @@ -//HintName: IVariousTypesTools.SetValueArgs.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class VariousTypesToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _SetValueArgs; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo SetValueArgs - #nullable enable annotations - { - get => _SetValueArgs ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.SetValueArgs)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_SetValueArgs(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues - { - ObjectCreator = () => new global::CSharpToJsonSchema.IntegrationTests.SetValueArgs(), - ObjectWithParameterizedConstructorCreator = null, - PropertyMetadataInitializer = _ => SetValueArgsPropInit(options), - ConstructorParameterMetadataInitializer = null, - ConstructorAttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.SetValueArgs).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty(), modifiers: null), - SerializeHandler = SetValueArgsSerializeHandler, - }; - - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(options, objectInfo); - jsonTypeInfo.NumberHandling = null; - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - - private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] SetValueArgsPropInit(global::System.Text.Json.JsonSerializerOptions options) - { - var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[1]; - - var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.SetValueArgs), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.SetValueArgs)obj).Value, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.SetValueArgs)obj).Value = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Value", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.SetValueArgs).GetProperty("Value", InstanceMemberBindingFlags, null, typeof(int), global::System.Array.Empty(), null), - }; - - properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info0); - - return properties; - } - - // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance - // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk. - private void SetValueArgsSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::CSharpToJsonSchema.IntegrationTests.SetValueArgs? value) - { - if (value is null) - { - writer.WriteNullValue(); - return; - } - - writer.WriteStartObject(); - - writer.WriteNumber(PropName_value, ((global::CSharpToJsonSchema.IntegrationTests.SetValueArgs)value).Value); - - writer.WriteEndObject(); - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.SetValueAsyncArgs.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.SetValueAsyncArgs.g.verified.cs deleted file mode 100644 index 26a1458..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.SetValueAsyncArgs.g.verified.cs +++ /dev/null @@ -1,92 +0,0 @@ -//HintName: IVariousTypesTools.SetValueAsyncArgs.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class VariousTypesToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _SetValueAsyncArgs; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo SetValueAsyncArgs - #nullable enable annotations - { - get => _SetValueAsyncArgs ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.SetValueAsyncArgs)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_SetValueAsyncArgs(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues - { - ObjectCreator = () => new global::CSharpToJsonSchema.IntegrationTests.SetValueAsyncArgs(), - ObjectWithParameterizedConstructorCreator = null, - PropertyMetadataInitializer = _ => SetValueAsyncArgsPropInit(options), - ConstructorParameterMetadataInitializer = null, - ConstructorAttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.SetValueAsyncArgs).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty(), modifiers: null), - SerializeHandler = SetValueAsyncArgsSerializeHandler, - }; - - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(options, objectInfo); - jsonTypeInfo.NumberHandling = null; - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - - private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] SetValueAsyncArgsPropInit(global::System.Text.Json.JsonSerializerOptions options) - { - var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[1]; - - var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.SetValueAsyncArgs), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.SetValueAsyncArgs)obj).Value, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.SetValueAsyncArgs)obj).Value = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Value", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.SetValueAsyncArgs).GetProperty("Value", InstanceMemberBindingFlags, null, typeof(int), global::System.Array.Empty(), null), - }; - - properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info0); - - return properties; - } - - // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance - // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk. - private void SetValueAsyncArgsSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::CSharpToJsonSchema.IntegrationTests.SetValueAsyncArgs? value) - { - if (value is null) - { - writer.WriteNullValue(); - return; - } - - writer.WriteStartObject(); - - writer.WriteNumber(PropName_value, ((global::CSharpToJsonSchema.IntegrationTests.SetValueAsyncArgs)value).Value); - - writer.WriteEndObject(); - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Single.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Single.g.verified.cs deleted file mode 100644 index 60b90d8..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Single.g.verified.cs +++ /dev/null @@ -1,37 +0,0 @@ -//HintName: IVariousTypesTools.Single.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class VariousTypesToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _Single; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Single - #nullable enable annotations - { - get => _Single ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(float)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_Single(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.SingleConverter); - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Tools.generated.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Tools.generated.verified.cs deleted file mode 100644 index b50de61..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.Tools.generated.verified.cs +++ /dev/null @@ -1,55 +0,0 @@ -//HintName: IVariousTypesTools.Tools.generated.cs - -#nullable enable - -namespace CSharpToJsonSchema.IntegrationTests -{ - public static partial class VariousTypesToolsExtensions - { - public static global::System.Collections.Generic.IList AsTools(this IVariousTypesTools functions) - { - return new global::System.Collections.Generic.List - { - new global::CSharpToJsonSchema.Tool - { - Name = "GetCurrentWeather3", - Description = "Get the current weather in a given location", - Strict = false, - Parameters = global::CSharpToJsonSchema.SchemaBuilder.ConvertToSchema(global::CSharpToJsonSchema.IntegrationTests.VariousTypesToolsExtensionsJsonSerializerContext.Default.GetCurrentWeather3Args,"{\"mainFunction_Desc\":\"Get the current weather in a given location\"}"), - }, - - new global::CSharpToJsonSchema.Tool - { - Name = "SetValue", - Description = "Sets the value", - Strict = false, - Parameters = global::CSharpToJsonSchema.SchemaBuilder.ConvertToSchema(global::CSharpToJsonSchema.IntegrationTests.VariousTypesToolsExtensionsJsonSerializerContext.Default.SetValueArgs,"{\"mainFunction_Desc\":\"Sets the value\"}"), - }, - - new global::CSharpToJsonSchema.Tool - { - Name = "GetValue", - Description = "Gets the value", - Strict = false, - Parameters = global::CSharpToJsonSchema.SchemaBuilder.ConvertToSchema(global::CSharpToJsonSchema.IntegrationTests.VariousTypesToolsExtensionsJsonSerializerContext.Default.GetValueArgs,"{\"mainFunction_Desc\":\"Gets the value\"}"), - }, - - new global::CSharpToJsonSchema.Tool - { - Name = "SetValueAsync", - Description = "Sets the value", - Strict = false, - Parameters = global::CSharpToJsonSchema.SchemaBuilder.ConvertToSchema(global::CSharpToJsonSchema.IntegrationTests.VariousTypesToolsExtensionsJsonSerializerContext.Default.SetValueAsyncArgs,"{\"mainFunction_Desc\":\"Sets the value\"}"), - }, - - new global::CSharpToJsonSchema.Tool - { - Name = "GetValueAsync", - Description = "Gets the value", - Strict = false, - Parameters = global::CSharpToJsonSchema.SchemaBuilder.ConvertToSchema(global::CSharpToJsonSchema.IntegrationTests.VariousTypesToolsExtensionsJsonSerializerContext.Default.GetValueAsyncArgs,"{\"mainFunction_Desc\":\"Gets the value\"}"), - }, - }; - } - } -} \ No newline at end of file diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.g.verified.cs deleted file mode 100644 index 5032b6d..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes#IVariousTypesTools.g.verified.cs +++ /dev/null @@ -1,111 +0,0 @@ -//HintName: IVariousTypesTools.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("CSharpToJsonSchema.Generators", "3.0.0.0")] - public partial class VariousTypesToolsExtensionsJsonSerializerContext - { - private readonly static global::System.Text.Json.JsonSerializerOptions s_defaultOptions = new(global::System.Text.Json.JsonSerializerDefaults.Web) - { - AllowOutOfOrderMetadataProperties = true, - AllowTrailingCommas = false, - DefaultBufferSize = 1024, - DefaultIgnoreCondition = global::System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull, - RespectNullableAnnotations = true, - RespectRequiredConstructorParameters = false, - IgnoreReadOnlyFields = false, - IgnoreReadOnlyProperties = false, - IncludeFields = false, - MaxDepth = 64, - NewLine = "\n", - NumberHandling = global::System.Text.Json.Serialization.JsonNumberHandling.Strict, - PreferredObjectCreationHandling = global::System.Text.Json.Serialization.JsonObjectCreationHandling.Replace, - PropertyNameCaseInsensitive = true, - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - ReadCommentHandling = global::System.Text.Json.JsonCommentHandling.Disallow, - UnknownTypeHandling = global::System.Text.Json.Serialization.JsonUnknownTypeHandling.JsonElement, - UnmappedMemberHandling = global::System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip, - WriteIndented = false, - IndentCharacter = ' ', - IndentSize = 2, - }; - - private const global::System.Reflection.BindingFlags InstanceMemberBindingFlags = - global::System.Reflection.BindingFlags.Instance | - global::System.Reflection.BindingFlags.Public | - global::System.Reflection.BindingFlags.NonPublic; - - /// - /// The default associated with a default instance. - /// - public static global::CSharpToJsonSchema.IntegrationTests.VariousTypesToolsExtensionsJsonSerializerContext Default { get; } = new global::CSharpToJsonSchema.IntegrationTests.VariousTypesToolsExtensionsJsonSerializerContext(new global::System.Text.Json.JsonSerializerOptions(s_defaultOptions)); - - /// - /// The source-generated options associated with this context. - /// - protected override global::System.Text.Json.JsonSerializerOptions? GeneratedSerializerOptions { get; } = s_defaultOptions; - - /// - public VariousTypesToolsExtensionsJsonSerializerContext() : base(null) - { - } - - /// - public VariousTypesToolsExtensionsJsonSerializerContext(global::System.Text.Json.JsonSerializerOptions options) : base(options) - { - } - - private static bool TryGetTypeInfoForRuntimeCustomConverter(global::System.Text.Json.JsonSerializerOptions options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo) - { - global::System.Text.Json.Serialization.JsonConverter? converter = GetRuntimeConverterForType(typeof(TJsonMetadataType), options); - if (converter != null) - { - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(options, converter); - return true; - } - - jsonTypeInfo = null; - return false; - } - - private static global::System.Text.Json.Serialization.JsonConverter? GetRuntimeConverterForType(global::System.Type type, global::System.Text.Json.JsonSerializerOptions options) - { - for (int i = 0; i < options.Converters.Count; i++) - { - global::System.Text.Json.Serialization.JsonConverter? converter = options.Converters[i]; - if (converter?.CanConvert(type) == true) - { - return ExpandConverter(type, converter, options, validateCanConvert: false); - } - } - - return null; - } - - private static global::System.Text.Json.Serialization.JsonConverter ExpandConverter(global::System.Type type, global::System.Text.Json.Serialization.JsonConverter converter, global::System.Text.Json.JsonSerializerOptions options, bool validateCanConvert = true) - { - if (validateCanConvert && !converter.CanConvert(type)) - { - throw new global::System.InvalidOperationException(string.Format("The converter '{0}' is not compatible with the type '{1}'.", converter.GetType(), type)); - } - - if (converter is global::System.Text.Json.Serialization.JsonConverterFactory factory) - { - converter = factory.CreateConverter(type, options); - if (converter is null || converter is global::System.Text.Json.Serialization.JsonConverterFactory) - { - throw new global::System.InvalidOperationException(string.Format("The converter '{0}' cannot return null or a JsonConverterFactory instance.", factory.GetType())); - } - } - - return converter; - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes_Diagnostics.verified.txt b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes_Diagnostics.verified.txt deleted file mode 100644 index ad47dbb..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.VariousTypes_Diagnostics.verified.txt +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.Calls.generated.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.Calls.generated.verified.cs deleted file mode 100644 index b8f0f13..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.Calls.generated.verified.cs +++ /dev/null @@ -1,195 +0,0 @@ -//HintName: IWeatherTools.Calls.generated.cs -#nullable enable - -namespace CSharpToJsonSchema.IntegrationTests -{ - public class GetCurrentWeatherArgs - { - - [global::System.ComponentModel.Description("The city and state, e.g. San Francisco, CA")] - public string? Location { get; set; } = string.Empty; - [global::System.ComponentModel.Description("")] - public CSharpToJsonSchema.IntegrationTests.Unit Unit { get; set; } - } - - public class GetCurrentWeatherAsyncArgs - { - - [global::System.ComponentModel.Description("The city and state, e.g. San Francisco, CA")] - public string? Location { get; set; } = string.Empty; - [global::System.ComponentModel.Description("")] - public CSharpToJsonSchema.IntegrationTests.Unit Unit { get; set; } - } - - public static partial class WeatherToolsExtensions - { - public static global::System.Collections.Generic.IReadOnlyDictionary>> AsCalls(this IWeatherTools service) - { - return new global::System.Collections.Generic.Dictionary>> - { - ["GetCurrentWeather"] = (json, _) => - { - return global::System.Threading.Tasks.Task.FromResult(service.CallGetCurrentWeather(json)); - }, - - ["GetCurrentWeatherAsync"] = async (json, cancellationToken) => - { - return await service.CallGetCurrentWeatherAsync(json, cancellationToken); - }, - - }; - } - - #pragma warning disable IL2026, IL3050 - public static GetCurrentWeatherArgs AsGetCurrentWeatherArgs( - this IWeatherTools functions, - string json) - { - #if NET6_0_OR_GREATER - if(global::System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault) - { - - return global::System.Text.Json.JsonSerializer.Deserialize(json, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = {{ new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }} - }) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - - } - else - { - return global::System.Text.Json.JsonSerializer.Deserialize(json, global::CSharpToJsonSchema.IntegrationTests.WeatherToolsExtensionsJsonSerializerContext.Default.GetCurrentWeatherArgs) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - } - #else - return - global::System.Text.Json.JsonSerializer.Deserialize(json, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = {{ new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }} - }) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - #endif - } - #pragma warning restore IL2026, IL3050 - - #pragma warning disable IL2026, IL3050 - public static GetCurrentWeatherAsyncArgs AsGetCurrentWeatherAsyncArgs( - this IWeatherTools functions, - string json) - { - #if NET6_0_OR_GREATER - if(global::System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault) - { - - return global::System.Text.Json.JsonSerializer.Deserialize(json, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = {{ new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }} - }) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - - } - else - { - return global::System.Text.Json.JsonSerializer.Deserialize(json, global::CSharpToJsonSchema.IntegrationTests.WeatherToolsExtensionsJsonSerializerContext.Default.GetCurrentWeatherAsyncArgs) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - } - #else - return - global::System.Text.Json.JsonSerializer.Deserialize(json, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = {{ new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }} - }) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - #endif - } - #pragma warning restore IL2026, IL3050 - - #pragma warning disable IL2026, IL3050 - public static string CallGetCurrentWeather(this IWeatherTools functions, string json) - { - var args = functions.AsGetCurrentWeatherArgs(json); - var jsonResult = functions.GetCurrentWeather(args.Location, args.Unit); - - #if NET6_0_OR_GREATER - if(global::System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault) - { - - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = { new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }, - }); - - } - else - { - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, global::CSharpToJsonSchema.IntegrationTests.WeatherToolsExtensionsJsonSerializerContext.Default.GetTypeInfo(jsonResult.GetType())); - } - #else - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = { new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }, - }); - #endif - } - #pragma warning restore IL2026, IL3050 - - - #pragma warning disable IL2026, IL3050 - public static async global::System.Threading.Tasks.Task CallGetCurrentWeatherAsync( - this IWeatherTools functions, - string json, - global::System.Threading.CancellationToken cancellationToken = default) - { - var args = functions.AsGetCurrentWeatherAsyncArgs(json); - var jsonResult = await functions.GetCurrentWeatherAsync(args.Location, args.Unit, cancellationToken); - - #if NET6_0_OR_GREATER - if(global::System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault) - { - - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = { new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }, - }); - } - else - { - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, global::CSharpToJsonSchema.IntegrationTests.WeatherToolsExtensionsJsonSerializerContext.Default.GetTypeInfo(jsonResult.GetType())); - } - #else - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = { new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }, - }); - #endif - - } - #pragma warning restore IL2026, IL3050 - - - - public static async global::System.Threading.Tasks.Task CallAsync( - this IWeatherTools service, - string functionName, - string argumentsAsJson, - global::System.Threading.CancellationToken cancellationToken = default) - { - var calls = service.AsCalls(); - var func = calls[functionName]; - - return await func(argumentsAsJson, cancellationToken); - } - } - - public partial class WeatherToolsExtensionsJsonSerializerContext: global::System.Text.Json.Serialization.JsonSerializerContext - { - } -} \ No newline at end of file diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.Double.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.Double.g.verified.cs deleted file mode 100644 index 2347275..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.Double.g.verified.cs +++ /dev/null @@ -1,37 +0,0 @@ -//HintName: IWeatherTools.Double.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class WeatherToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _Double; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Double - #nullable enable annotations - { - get => _Double ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(double)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_Double(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.DoubleConverter); - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.GetCurrentWeatherArgs.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.GetCurrentWeatherArgs.g.verified.cs deleted file mode 100644 index ddadc1f..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.GetCurrentWeatherArgs.g.verified.cs +++ /dev/null @@ -1,118 +0,0 @@ -//HintName: IWeatherTools.GetCurrentWeatherArgs.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class WeatherToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _GetCurrentWeatherArgs; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo GetCurrentWeatherArgs - #nullable enable annotations - { - get => _GetCurrentWeatherArgs ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherArgs)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_GetCurrentWeatherArgs(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues - { - ObjectCreator = () => new global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherArgs(), - ObjectWithParameterizedConstructorCreator = null, - PropertyMetadataInitializer = _ => GetCurrentWeatherArgsPropInit(options), - ConstructorParameterMetadataInitializer = null, - ConstructorAttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherArgs).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty(), modifiers: null), - SerializeHandler = GetCurrentWeatherArgsSerializeHandler, - }; - - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(options, objectInfo); - jsonTypeInfo.NumberHandling = null; - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - - private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] GetCurrentWeatherArgsPropInit(global::System.Text.Json.JsonSerializerOptions options) - { - var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[2]; - - var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherArgs), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherArgs)obj).Location, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherArgs)obj).Location = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Location", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherArgs).GetProperty("Location", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty(), null), - }; - - properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info0); - - var info1 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherArgs), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherArgs)obj).Unit, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherArgs)obj).Unit = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Unit", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherArgs).GetProperty("Unit", InstanceMemberBindingFlags, null, typeof(global::CSharpToJsonSchema.IntegrationTests.Unit), global::System.Array.Empty(), null), - }; - - properties[1] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info1); - - return properties; - } - - // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance - // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk. - private void GetCurrentWeatherArgsSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherArgs? value) - { - if (value is null) - { - writer.WriteNullValue(); - return; - } - - writer.WriteStartObject(); - - string __value_Location = ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherArgs)value).Location; - if (__value_Location is not null) - { - writer.WriteString(PropName_location, __value_Location); - } - writer.WritePropertyName(PropName_unit); - global::System.Text.Json.JsonSerializer.Serialize(writer, ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherArgs)value).Unit, Unit); - - writer.WriteEndObject(); - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.GetCurrentWeatherAsyncArgs.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.GetCurrentWeatherAsyncArgs.g.verified.cs deleted file mode 100644 index 0ed9822..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.GetCurrentWeatherAsyncArgs.g.verified.cs +++ /dev/null @@ -1,118 +0,0 @@ -//HintName: IWeatherTools.GetCurrentWeatherAsyncArgs.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class WeatherToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _GetCurrentWeatherAsyncArgs; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo GetCurrentWeatherAsyncArgs - #nullable enable annotations - { - get => _GetCurrentWeatherAsyncArgs ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsyncArgs)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_GetCurrentWeatherAsyncArgs(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues - { - ObjectCreator = () => new global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsyncArgs(), - ObjectWithParameterizedConstructorCreator = null, - PropertyMetadataInitializer = _ => GetCurrentWeatherAsyncArgsPropInit(options), - ConstructorParameterMetadataInitializer = null, - ConstructorAttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsyncArgs).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty(), modifiers: null), - SerializeHandler = GetCurrentWeatherAsyncArgsSerializeHandler, - }; - - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(options, objectInfo); - jsonTypeInfo.NumberHandling = null; - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - - private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] GetCurrentWeatherAsyncArgsPropInit(global::System.Text.Json.JsonSerializerOptions options) - { - var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[2]; - - var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsyncArgs), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsyncArgs)obj).Location, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsyncArgs)obj).Location = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Location", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsyncArgs).GetProperty("Location", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty(), null), - }; - - properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info0); - - var info1 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsyncArgs), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsyncArgs)obj).Unit, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsyncArgs)obj).Unit = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Unit", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsyncArgs).GetProperty("Unit", InstanceMemberBindingFlags, null, typeof(global::CSharpToJsonSchema.IntegrationTests.Unit), global::System.Array.Empty(), null), - }; - - properties[1] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info1); - - return properties; - } - - // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance - // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk. - private void GetCurrentWeatherAsyncArgsSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsyncArgs? value) - { - if (value is null) - { - writer.WriteNullValue(); - return; - } - - writer.WriteStartObject(); - - string __value_Location = ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsyncArgs)value).Location; - if (__value_Location is not null) - { - writer.WriteString(PropName_location, __value_Location); - } - writer.WritePropertyName(PropName_unit); - global::System.Text.Json.JsonSerializer.Serialize(writer, ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsyncArgs)value).Unit, Unit); - - writer.WriteEndObject(); - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.GetJsonTypeInfo.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.GetJsonTypeInfo.g.verified.cs deleted file mode 100644 index 6e04e4e..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.GetJsonTypeInfo.g.verified.cs +++ /dev/null @@ -1,50 +0,0 @@ -//HintName: IWeatherTools.GetJsonTypeInfo.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class WeatherToolsExtensionsJsonSerializerContext : global::System.Text.Json.Serialization.Metadata.IJsonTypeInfoResolver - { - /// - public override global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? GetTypeInfo(global::System.Type type) - { - Options.TryGetTypeInfo(type, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? typeInfo); - return typeInfo; - } - - global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? global::System.Text.Json.Serialization.Metadata.IJsonTypeInfoResolver.GetTypeInfo(global::System.Type type, global::System.Text.Json.JsonSerializerOptions options) - { - if (type == typeof(double)) - { - return Create_Double(options); - } - if (type == typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherArgs)) - { - return Create_GetCurrentWeatherArgs(options); - } - if (type == typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsyncArgs)) - { - return Create_GetCurrentWeatherAsyncArgs(options); - } - if (type == typeof(global::CSharpToJsonSchema.IntegrationTests.Unit)) - { - return Create_Unit(options); - } - if (type == typeof(global::CSharpToJsonSchema.IntegrationTests.Weather)) - { - return Create_Weather(options); - } - if (type == typeof(string)) - { - return Create_String(options); - } - return null; - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.PropertyNames.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.PropertyNames.g.verified.cs deleted file mode 100644 index f05a09c..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.PropertyNames.g.verified.cs +++ /dev/null @@ -1,19 +0,0 @@ -//HintName: IWeatherTools.PropertyNames.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class WeatherToolsExtensionsJsonSerializerContext - { - private static readonly global::System.Text.Json.JsonEncodedText PropName_location = global::System.Text.Json.JsonEncodedText.Encode("location"); - private static readonly global::System.Text.Json.JsonEncodedText PropName_unit = global::System.Text.Json.JsonEncodedText.Encode("unit"); - private static readonly global::System.Text.Json.JsonEncodedText PropName_temperature = global::System.Text.Json.JsonEncodedText.Encode("temperature"); - private static readonly global::System.Text.Json.JsonEncodedText PropName_description = global::System.Text.Json.JsonEncodedText.Encode("description"); - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.String.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.String.g.verified.cs deleted file mode 100644 index 56f2b3d..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.String.g.verified.cs +++ /dev/null @@ -1,37 +0,0 @@ -//HintName: IWeatherTools.String.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class WeatherToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _String; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo String - #nullable enable annotations - { - get => _String ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(string)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_String(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.StringConverter); - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.Tools.generated.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.Tools.generated.verified.cs deleted file mode 100644 index 28dd9ef..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.Tools.generated.verified.cs +++ /dev/null @@ -1,31 +0,0 @@ -//HintName: IWeatherTools.Tools.generated.cs - -#nullable enable - -namespace CSharpToJsonSchema.IntegrationTests -{ - public static partial class WeatherToolsExtensions - { - public static global::System.Collections.Generic.IList AsTools(this IWeatherTools functions) - { - return new global::System.Collections.Generic.List - { - new global::CSharpToJsonSchema.Tool - { - Name = "GetCurrentWeather", - Description = "Get the current weather in a given location", - Strict = false, - Parameters = global::CSharpToJsonSchema.SchemaBuilder.ConvertToSchema(global::CSharpToJsonSchema.IntegrationTests.WeatherToolsExtensionsJsonSerializerContext.Default.GetCurrentWeatherArgs,"{\"mainFunction_Desc\":\"Get the current weather in a given location\"}"), - }, - - new global::CSharpToJsonSchema.Tool - { - Name = "GetCurrentWeatherAsync", - Description = "Get the current weather in a given location", - Strict = false, - Parameters = global::CSharpToJsonSchema.SchemaBuilder.ConvertToSchema(global::CSharpToJsonSchema.IntegrationTests.WeatherToolsExtensionsJsonSerializerContext.Default.GetCurrentWeatherAsyncArgs,"{\"mainFunction_Desc\":\"Get the current weather in a given location\"}"), - }, - }; - } - } -} \ No newline at end of file diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.Unit.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.Unit.g.verified.cs deleted file mode 100644 index 7850732..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.Unit.g.verified.cs +++ /dev/null @@ -1,38 +0,0 @@ -//HintName: IWeatherTools.Unit.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class WeatherToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _Unit; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Unit - #nullable enable annotations - { - get => _Unit ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.Unit)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_Unit(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - global::System.Text.Json.Serialization.JsonConverter converter = ExpandConverter(typeof(global::CSharpToJsonSchema.IntegrationTests.Unit), new global::System.Text.Json.Serialization.JsonStringEnumConverter(), options); - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo (options, converter); - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.Weather.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.Weather.g.verified.cs deleted file mode 100644 index 830d339..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.Weather.g.verified.cs +++ /dev/null @@ -1,164 +0,0 @@ -//HintName: IWeatherTools.Weather.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class WeatherToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _Weather; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Weather - #nullable enable annotations - { - get => _Weather ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.Weather)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_Weather(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues - { - ObjectCreator = () => new global::CSharpToJsonSchema.IntegrationTests.Weather(), - ObjectWithParameterizedConstructorCreator = null, - PropertyMetadataInitializer = _ => WeatherPropInit(options), - ConstructorParameterMetadataInitializer = null, - ConstructorAttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.Weather).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty(), modifiers: null), - SerializeHandler = WeatherSerializeHandler, - }; - - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(options, objectInfo); - jsonTypeInfo.NumberHandling = null; - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - - private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] WeatherPropInit(global::System.Text.Json.JsonSerializerOptions options) - { - var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[4]; - - var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.Weather), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.Weather)obj).Location, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.Weather)obj).Location = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Location", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.Weather).GetProperty("Location", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty(), null), - }; - - properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info0); - - var info1 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.Weather), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.Weather)obj).Temperature, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.Weather)obj).Temperature = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Temperature", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.Weather).GetProperty("Temperature", InstanceMemberBindingFlags, null, typeof(double), global::System.Array.Empty(), null), - }; - - properties[1] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info1); - - var info2 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.Weather), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.Weather)obj).Unit, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.Weather)obj).Unit = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Unit", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.Weather).GetProperty("Unit", InstanceMemberBindingFlags, null, typeof(global::CSharpToJsonSchema.IntegrationTests.Unit), global::System.Array.Empty(), null), - }; - - properties[2] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info2); - - var info3 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.Weather), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.Weather)obj).Description, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.Weather)obj).Description = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Description", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.Weather).GetProperty("Description", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty(), null), - }; - - properties[3] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info3); - - return properties; - } - - // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance - // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk. - private void WeatherSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::CSharpToJsonSchema.IntegrationTests.Weather? value) - { - if (value is null) - { - writer.WriteNullValue(); - return; - } - - writer.WriteStartObject(); - - string __value_Location = ((global::CSharpToJsonSchema.IntegrationTests.Weather)value).Location; - if (__value_Location is not null) - { - writer.WriteString(PropName_location, __value_Location); - } - writer.WriteNumber(PropName_temperature, ((global::CSharpToJsonSchema.IntegrationTests.Weather)value).Temperature); - writer.WritePropertyName(PropName_unit); - global::System.Text.Json.JsonSerializer.Serialize(writer, ((global::CSharpToJsonSchema.IntegrationTests.Weather)value).Unit, Unit); - string __value_Description = ((global::CSharpToJsonSchema.IntegrationTests.Weather)value).Description; - if (__value_Description is not null) - { - writer.WriteString(PropName_description, __value_Description); - } - - writer.WriteEndObject(); - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.g.verified.cs deleted file mode 100644 index e0160a5..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather#IWeatherTools.g.verified.cs +++ /dev/null @@ -1,111 +0,0 @@ -//HintName: IWeatherTools.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("CSharpToJsonSchema.Generators", "3.0.0.0")] - public partial class WeatherToolsExtensionsJsonSerializerContext - { - private readonly static global::System.Text.Json.JsonSerializerOptions s_defaultOptions = new(global::System.Text.Json.JsonSerializerDefaults.Web) - { - AllowOutOfOrderMetadataProperties = true, - AllowTrailingCommas = false, - DefaultBufferSize = 1024, - DefaultIgnoreCondition = global::System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull, - RespectNullableAnnotations = true, - RespectRequiredConstructorParameters = false, - IgnoreReadOnlyFields = false, - IgnoreReadOnlyProperties = false, - IncludeFields = false, - MaxDepth = 64, - NewLine = "\n", - NumberHandling = global::System.Text.Json.Serialization.JsonNumberHandling.Strict, - PreferredObjectCreationHandling = global::System.Text.Json.Serialization.JsonObjectCreationHandling.Replace, - PropertyNameCaseInsensitive = true, - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - ReadCommentHandling = global::System.Text.Json.JsonCommentHandling.Disallow, - UnknownTypeHandling = global::System.Text.Json.Serialization.JsonUnknownTypeHandling.JsonElement, - UnmappedMemberHandling = global::System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip, - WriteIndented = false, - IndentCharacter = ' ', - IndentSize = 2, - }; - - private const global::System.Reflection.BindingFlags InstanceMemberBindingFlags = - global::System.Reflection.BindingFlags.Instance | - global::System.Reflection.BindingFlags.Public | - global::System.Reflection.BindingFlags.NonPublic; - - /// - /// The default associated with a default instance. - /// - public static global::CSharpToJsonSchema.IntegrationTests.WeatherToolsExtensionsJsonSerializerContext Default { get; } = new global::CSharpToJsonSchema.IntegrationTests.WeatherToolsExtensionsJsonSerializerContext(new global::System.Text.Json.JsonSerializerOptions(s_defaultOptions)); - - /// - /// The source-generated options associated with this context. - /// - protected override global::System.Text.Json.JsonSerializerOptions? GeneratedSerializerOptions { get; } = s_defaultOptions; - - /// - public WeatherToolsExtensionsJsonSerializerContext() : base(null) - { - } - - /// - public WeatherToolsExtensionsJsonSerializerContext(global::System.Text.Json.JsonSerializerOptions options) : base(options) - { - } - - private static bool TryGetTypeInfoForRuntimeCustomConverter(global::System.Text.Json.JsonSerializerOptions options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo) - { - global::System.Text.Json.Serialization.JsonConverter? converter = GetRuntimeConverterForType(typeof(TJsonMetadataType), options); - if (converter != null) - { - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(options, converter); - return true; - } - - jsonTypeInfo = null; - return false; - } - - private static global::System.Text.Json.Serialization.JsonConverter? GetRuntimeConverterForType(global::System.Type type, global::System.Text.Json.JsonSerializerOptions options) - { - for (int i = 0; i < options.Converters.Count; i++) - { - global::System.Text.Json.Serialization.JsonConverter? converter = options.Converters[i]; - if (converter?.CanConvert(type) == true) - { - return ExpandConverter(type, converter, options, validateCanConvert: false); - } - } - - return null; - } - - private static global::System.Text.Json.Serialization.JsonConverter ExpandConverter(global::System.Type type, global::System.Text.Json.Serialization.JsonConverter converter, global::System.Text.Json.JsonSerializerOptions options, bool validateCanConvert = true) - { - if (validateCanConvert && !converter.CanConvert(type)) - { - throw new global::System.InvalidOperationException(string.Format("The converter '{0}' is not compatible with the type '{1}'.", converter.GetType(), type)); - } - - if (converter is global::System.Text.Json.Serialization.JsonConverterFactory factory) - { - converter = factory.CreateConverter(type, options); - if (converter is null || converter is global::System.Text.Json.Serialization.JsonConverterFactory) - { - throw new global::System.InvalidOperationException(string.Format("The converter '{0}' cannot return null or a JsonConverterFactory instance.", factory.GetType())); - } - } - - return converter; - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.Calls.generated.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.Calls.generated.verified.cs deleted file mode 100644 index 80ef1b8..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.Calls.generated.verified.cs +++ /dev/null @@ -1,195 +0,0 @@ -//HintName: IWeatherStrictTools.Calls.generated.cs -#nullable enable - -namespace CSharpToJsonSchema.IntegrationTests -{ - public class GetCurrentWeather2Args - { - - [global::System.ComponentModel.Description("The city and state, e.g. San Francisco, CA")] - public string? Location { get; set; } = string.Empty; - [global::System.ComponentModel.Description("")] - public CSharpToJsonSchema.IntegrationTests.Unit2 Unit { get; set; } - } - - public class GetCurrentWeatherAsync2Args - { - - [global::System.ComponentModel.Description("The city and state, e.g. San Francisco, CA")] - public string? Location { get; set; } = string.Empty; - [global::System.ComponentModel.Description("")] - public CSharpToJsonSchema.IntegrationTests.Unit2 Unit { get; set; } - } - - public static partial class WeatherStrictToolsExtensions - { - public static global::System.Collections.Generic.IReadOnlyDictionary>> AsCalls(this IWeatherStrictTools service) - { - return new global::System.Collections.Generic.Dictionary>> - { - ["GetCurrentWeather2"] = (json, _) => - { - return global::System.Threading.Tasks.Task.FromResult(service.CallGetCurrentWeather2(json)); - }, - - ["GetCurrentWeatherAsync2"] = async (json, cancellationToken) => - { - return await service.CallGetCurrentWeatherAsync2(json, cancellationToken); - }, - - }; - } - - #pragma warning disable IL2026, IL3050 - public static GetCurrentWeather2Args AsGetCurrentWeather2Args( - this IWeatherStrictTools functions, - string json) - { - #if NET6_0_OR_GREATER - if(global::System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault) - { - - return global::System.Text.Json.JsonSerializer.Deserialize(json, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = {{ new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }} - }) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - - } - else - { - return global::System.Text.Json.JsonSerializer.Deserialize(json, global::CSharpToJsonSchema.IntegrationTests.WeatherStrictToolsExtensionsJsonSerializerContext.Default.GetCurrentWeather2Args) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - } - #else - return - global::System.Text.Json.JsonSerializer.Deserialize(json, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = {{ new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }} - }) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - #endif - } - #pragma warning restore IL2026, IL3050 - - #pragma warning disable IL2026, IL3050 - public static GetCurrentWeatherAsync2Args AsGetCurrentWeatherAsync2Args( - this IWeatherStrictTools functions, - string json) - { - #if NET6_0_OR_GREATER - if(global::System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault) - { - - return global::System.Text.Json.JsonSerializer.Deserialize(json, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = {{ new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }} - }) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - - } - else - { - return global::System.Text.Json.JsonSerializer.Deserialize(json, global::CSharpToJsonSchema.IntegrationTests.WeatherStrictToolsExtensionsJsonSerializerContext.Default.GetCurrentWeatherAsync2Args) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - } - #else - return - global::System.Text.Json.JsonSerializer.Deserialize(json, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = {{ new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }} - }) ?? - throw new global::System.InvalidOperationException("Could not deserialize JSON."); - #endif - } - #pragma warning restore IL2026, IL3050 - - #pragma warning disable IL2026, IL3050 - public static string CallGetCurrentWeather2(this IWeatherStrictTools functions, string json) - { - var args = functions.AsGetCurrentWeather2Args(json); - var jsonResult = functions.GetCurrentWeather2(args.Location, args.Unit); - - #if NET6_0_OR_GREATER - if(global::System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault) - { - - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = { new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }, - }); - - } - else - { - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, global::CSharpToJsonSchema.IntegrationTests.WeatherStrictToolsExtensionsJsonSerializerContext.Default.GetTypeInfo(jsonResult.GetType())); - } - #else - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = { new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }, - }); - #endif - } - #pragma warning restore IL2026, IL3050 - - - #pragma warning disable IL2026, IL3050 - public static async global::System.Threading.Tasks.Task CallGetCurrentWeatherAsync2( - this IWeatherStrictTools functions, - string json, - global::System.Threading.CancellationToken cancellationToken = default) - { - var args = functions.AsGetCurrentWeatherAsync2Args(json); - var jsonResult = await functions.GetCurrentWeatherAsync2(args.Location, args.Unit, cancellationToken); - - #if NET6_0_OR_GREATER - if(global::System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault) - { - - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = { new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }, - }); - } - else - { - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, global::CSharpToJsonSchema.IntegrationTests.WeatherStrictToolsExtensionsJsonSerializerContext.Default.GetTypeInfo(jsonResult.GetType())); - } - #else - return global::System.Text.Json.JsonSerializer.Serialize(jsonResult, new global::System.Text.Json.JsonSerializerOptions - { - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - Converters = { new global::System.Text.Json.Serialization.JsonStringEnumConverter(global::System.Text.Json.JsonNamingPolicy.CamelCase) }, - }); - #endif - - } - #pragma warning restore IL2026, IL3050 - - - - public static async global::System.Threading.Tasks.Task CallAsync( - this IWeatherStrictTools service, - string functionName, - string argumentsAsJson, - global::System.Threading.CancellationToken cancellationToken = default) - { - var calls = service.AsCalls(); - var func = calls[functionName]; - - return await func(argumentsAsJson, cancellationToken); - } - } - - public partial class WeatherStrictToolsExtensionsJsonSerializerContext: global::System.Text.Json.Serialization.JsonSerializerContext - { - } -} \ No newline at end of file diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.Double.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.Double.g.verified.cs deleted file mode 100644 index 452fe78..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.Double.g.verified.cs +++ /dev/null @@ -1,37 +0,0 @@ -//HintName: IWeatherStrictTools.Double.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class WeatherStrictToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _Double; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Double - #nullable enable annotations - { - get => _Double ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(double)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_Double(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.DoubleConverter); - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.GetCurrentWeather2Args.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.GetCurrentWeather2Args.g.verified.cs deleted file mode 100644 index 2d4e52f..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.GetCurrentWeather2Args.g.verified.cs +++ /dev/null @@ -1,118 +0,0 @@ -//HintName: IWeatherStrictTools.GetCurrentWeather2Args.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class WeatherStrictToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _GetCurrentWeather2Args; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo GetCurrentWeather2Args - #nullable enable annotations - { - get => _GetCurrentWeather2Args ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather2Args)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_GetCurrentWeather2Args(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues - { - ObjectCreator = () => new global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather2Args(), - ObjectWithParameterizedConstructorCreator = null, - PropertyMetadataInitializer = _ => GetCurrentWeather2ArgsPropInit(options), - ConstructorParameterMetadataInitializer = null, - ConstructorAttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather2Args).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty(), modifiers: null), - SerializeHandler = GetCurrentWeather2ArgsSerializeHandler, - }; - - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(options, objectInfo); - jsonTypeInfo.NumberHandling = null; - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - - private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] GetCurrentWeather2ArgsPropInit(global::System.Text.Json.JsonSerializerOptions options) - { - var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[2]; - - var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather2Args), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather2Args)obj).Location, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather2Args)obj).Location = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Location", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather2Args).GetProperty("Location", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty(), null), - }; - - properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info0); - - var info1 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather2Args), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather2Args)obj).Unit, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather2Args)obj).Unit = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Unit", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather2Args).GetProperty("Unit", InstanceMemberBindingFlags, null, typeof(global::CSharpToJsonSchema.IntegrationTests.Unit2), global::System.Array.Empty(), null), - }; - - properties[1] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info1); - - return properties; - } - - // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance - // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk. - private void GetCurrentWeather2ArgsSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather2Args? value) - { - if (value is null) - { - writer.WriteNullValue(); - return; - } - - writer.WriteStartObject(); - - string __value_Location = ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather2Args)value).Location; - if (__value_Location is not null) - { - writer.WriteString(PropName_location, __value_Location); - } - writer.WritePropertyName(PropName_unit); - global::System.Text.Json.JsonSerializer.Serialize(writer, ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather2Args)value).Unit, Unit2); - - writer.WriteEndObject(); - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.GetCurrentWeatherAsync2Args.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.GetCurrentWeatherAsync2Args.g.verified.cs deleted file mode 100644 index 715c33e..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.GetCurrentWeatherAsync2Args.g.verified.cs +++ /dev/null @@ -1,118 +0,0 @@ -//HintName: IWeatherStrictTools.GetCurrentWeatherAsync2Args.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class WeatherStrictToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _GetCurrentWeatherAsync2Args; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo GetCurrentWeatherAsync2Args - #nullable enable annotations - { - get => _GetCurrentWeatherAsync2Args ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsync2Args)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_GetCurrentWeatherAsync2Args(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues - { - ObjectCreator = () => new global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsync2Args(), - ObjectWithParameterizedConstructorCreator = null, - PropertyMetadataInitializer = _ => GetCurrentWeatherAsync2ArgsPropInit(options), - ConstructorParameterMetadataInitializer = null, - ConstructorAttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsync2Args).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty(), modifiers: null), - SerializeHandler = GetCurrentWeatherAsync2ArgsSerializeHandler, - }; - - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(options, objectInfo); - jsonTypeInfo.NumberHandling = null; - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - - private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] GetCurrentWeatherAsync2ArgsPropInit(global::System.Text.Json.JsonSerializerOptions options) - { - var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[2]; - - var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsync2Args), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsync2Args)obj).Location, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsync2Args)obj).Location = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Location", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsync2Args).GetProperty("Location", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty(), null), - }; - - properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info0); - - var info1 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsync2Args), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsync2Args)obj).Unit, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsync2Args)obj).Unit = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Unit", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsync2Args).GetProperty("Unit", InstanceMemberBindingFlags, null, typeof(global::CSharpToJsonSchema.IntegrationTests.Unit2), global::System.Array.Empty(), null), - }; - - properties[1] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info1); - - return properties; - } - - // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance - // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk. - private void GetCurrentWeatherAsync2ArgsSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsync2Args? value) - { - if (value is null) - { - writer.WriteNullValue(); - return; - } - - writer.WriteStartObject(); - - string __value_Location = ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsync2Args)value).Location; - if (__value_Location is not null) - { - writer.WriteString(PropName_location, __value_Location); - } - writer.WritePropertyName(PropName_unit); - global::System.Text.Json.JsonSerializer.Serialize(writer, ((global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsync2Args)value).Unit, Unit2); - - writer.WriteEndObject(); - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.GetJsonTypeInfo.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.GetJsonTypeInfo.g.verified.cs deleted file mode 100644 index 1b7617b..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.GetJsonTypeInfo.g.verified.cs +++ /dev/null @@ -1,50 +0,0 @@ -//HintName: IWeatherStrictTools.GetJsonTypeInfo.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class WeatherStrictToolsExtensionsJsonSerializerContext : global::System.Text.Json.Serialization.Metadata.IJsonTypeInfoResolver - { - /// - public override global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? GetTypeInfo(global::System.Type type) - { - Options.TryGetTypeInfo(type, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? typeInfo); - return typeInfo; - } - - global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? global::System.Text.Json.Serialization.Metadata.IJsonTypeInfoResolver.GetTypeInfo(global::System.Type type, global::System.Text.Json.JsonSerializerOptions options) - { - if (type == typeof(double)) - { - return Create_Double(options); - } - if (type == typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeather2Args)) - { - return Create_GetCurrentWeather2Args(options); - } - if (type == typeof(global::CSharpToJsonSchema.IntegrationTests.GetCurrentWeatherAsync2Args)) - { - return Create_GetCurrentWeatherAsync2Args(options); - } - if (type == typeof(global::CSharpToJsonSchema.IntegrationTests.Unit2)) - { - return Create_Unit2(options); - } - if (type == typeof(global::CSharpToJsonSchema.IntegrationTests.Weather2)) - { - return Create_Weather2(options); - } - if (type == typeof(string)) - { - return Create_String(options); - } - return null; - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.PropertyNames.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.PropertyNames.g.verified.cs deleted file mode 100644 index a8edc96..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.PropertyNames.g.verified.cs +++ /dev/null @@ -1,19 +0,0 @@ -//HintName: IWeatherStrictTools.PropertyNames.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class WeatherStrictToolsExtensionsJsonSerializerContext - { - private static readonly global::System.Text.Json.JsonEncodedText PropName_location = global::System.Text.Json.JsonEncodedText.Encode("location"); - private static readonly global::System.Text.Json.JsonEncodedText PropName_unit = global::System.Text.Json.JsonEncodedText.Encode("unit"); - private static readonly global::System.Text.Json.JsonEncodedText PropName_temperature = global::System.Text.Json.JsonEncodedText.Encode("temperature"); - private static readonly global::System.Text.Json.JsonEncodedText PropName_description = global::System.Text.Json.JsonEncodedText.Encode("description"); - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.String.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.String.g.verified.cs deleted file mode 100644 index 004080e..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.String.g.verified.cs +++ /dev/null @@ -1,37 +0,0 @@ -//HintName: IWeatherStrictTools.String.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class WeatherStrictToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _String; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo String - #nullable enable annotations - { - get => _String ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(string)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_String(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.StringConverter); - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.Tools.generated.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.Tools.generated.verified.cs deleted file mode 100644 index 3195177..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.Tools.generated.verified.cs +++ /dev/null @@ -1,31 +0,0 @@ -//HintName: IWeatherStrictTools.Tools.generated.cs - -#nullable enable - -namespace CSharpToJsonSchema.IntegrationTests -{ - public static partial class WeatherStrictToolsExtensions - { - public static global::System.Collections.Generic.IList AsTools(this IWeatherStrictTools functions) - { - return new global::System.Collections.Generic.List - { - new global::CSharpToJsonSchema.Tool - { - Name = "GetCurrentWeather2", - Description = "Get the current weather in a given location", - Strict = true, - Parameters = global::CSharpToJsonSchema.SchemaBuilder.ConvertToSchema(global::CSharpToJsonSchema.IntegrationTests.WeatherStrictToolsExtensionsJsonSerializerContext.Default.GetCurrentWeather2Args,"{\"mainFunction_Desc\":\"Get the current weather in a given location\"}"), - }, - - new global::CSharpToJsonSchema.Tool - { - Name = "GetCurrentWeatherAsync2", - Description = "Get the current weather in a given location", - Strict = true, - Parameters = global::CSharpToJsonSchema.SchemaBuilder.ConvertToSchema(global::CSharpToJsonSchema.IntegrationTests.WeatherStrictToolsExtensionsJsonSerializerContext.Default.GetCurrentWeatherAsync2Args,"{\"mainFunction_Desc\":\"Get the current weather in a given location\"}"), - }, - }; - } - } -} \ No newline at end of file diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.Unit2.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.Unit2.g.verified.cs deleted file mode 100644 index c3526ac..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.Unit2.g.verified.cs +++ /dev/null @@ -1,38 +0,0 @@ -//HintName: IWeatherStrictTools.Unit2.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class WeatherStrictToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _Unit2; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Unit2 - #nullable enable annotations - { - get => _Unit2 ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.Unit2)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_Unit2(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - global::System.Text.Json.Serialization.JsonConverter converter = ExpandConverter(typeof(global::CSharpToJsonSchema.IntegrationTests.Unit2), new global::System.Text.Json.Serialization.JsonStringEnumConverter(), options); - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo (options, converter); - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.Weather2.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.Weather2.g.verified.cs deleted file mode 100644 index 56c793b..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.Weather2.g.verified.cs +++ /dev/null @@ -1,164 +0,0 @@ -//HintName: IWeatherStrictTools.Weather2.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - public partial class WeatherStrictToolsExtensionsJsonSerializerContext - { - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? _Weather2; - - /// - /// Defines the source generated JSON serialization contract metadata for a given type. - /// - #nullable disable annotations // Marking the property type as nullable-oblivious. - public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Weather2 - #nullable enable annotations - { - get => _Weather2 ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo)Options.GetTypeInfo(typeof(global::CSharpToJsonSchema.IntegrationTests.Weather2)); - } - - private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo Create_Weather2(global::System.Text.Json.JsonSerializerOptions options) - { - if (!TryGetTypeInfoForRuntimeCustomConverter(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo)) - { - var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues - { - ObjectCreator = () => new global::CSharpToJsonSchema.IntegrationTests.Weather2(), - ObjectWithParameterizedConstructorCreator = null, - PropertyMetadataInitializer = _ => Weather2PropInit(options), - ConstructorParameterMetadataInitializer = null, - ConstructorAttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.Weather2).GetConstructor(InstanceMemberBindingFlags, binder: null, global::System.Array.Empty(), modifiers: null), - SerializeHandler = Weather2SerializeHandler, - }; - - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo(options, objectInfo); - jsonTypeInfo.NumberHandling = null; - } - - jsonTypeInfo.OriginatingResolver = this; - return jsonTypeInfo; - } - - private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] Weather2PropInit(global::System.Text.Json.JsonSerializerOptions options) - { - var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[4]; - - var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.Weather2), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.Weather2)obj).Location, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.Weather2)obj).Location = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Location", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.Weather2).GetProperty("Location", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty(), null), - }; - - properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info0); - - var info1 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.Weather2), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.Weather2)obj).Temperature, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.Weather2)obj).Temperature = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Temperature", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.Weather2).GetProperty("Temperature", InstanceMemberBindingFlags, null, typeof(double), global::System.Array.Empty(), null), - }; - - properties[1] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info1); - - var info2 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.Weather2), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.Weather2)obj).Unit, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.Weather2)obj).Unit = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Unit", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.Weather2).GetProperty("Unit", InstanceMemberBindingFlags, null, typeof(global::CSharpToJsonSchema.IntegrationTests.Unit2), global::System.Array.Empty(), null), - }; - - properties[2] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info2); - - var info3 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues - { - IsProperty = true, - IsPublic = true, - IsVirtual = false, - DeclaringType = typeof(global::CSharpToJsonSchema.IntegrationTests.Weather2), - Converter = null, - Getter = static obj => ((global::CSharpToJsonSchema.IntegrationTests.Weather2)obj).Description, - Setter = static (obj, value) => ((global::CSharpToJsonSchema.IntegrationTests.Weather2)obj).Description = value!, - IgnoreCondition = null, - HasJsonInclude = false, - IsExtensionData = false, - NumberHandling = null, - PropertyName = "Description", - JsonPropertyName = null, - AttributeProviderFactory = static () => typeof(global::CSharpToJsonSchema.IntegrationTests.Weather2).GetProperty("Description", InstanceMemberBindingFlags, null, typeof(string), global::System.Array.Empty(), null), - }; - - properties[3] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo(options, info3); - - return properties; - } - - // Intentionally not a static method because we create a delegate to it. Invoking delegates to instance - // methods is almost as fast as virtual calls. Static methods need to go through a shuffle thunk. - private void Weather2SerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::CSharpToJsonSchema.IntegrationTests.Weather2? value) - { - if (value is null) - { - writer.WriteNullValue(); - return; - } - - writer.WriteStartObject(); - - string __value_Location = ((global::CSharpToJsonSchema.IntegrationTests.Weather2)value).Location; - if (__value_Location is not null) - { - writer.WriteString(PropName_location, __value_Location); - } - writer.WriteNumber(PropName_temperature, ((global::CSharpToJsonSchema.IntegrationTests.Weather2)value).Temperature); - writer.WritePropertyName(PropName_unit); - global::System.Text.Json.JsonSerializer.Serialize(writer, ((global::CSharpToJsonSchema.IntegrationTests.Weather2)value).Unit, Unit2); - string __value_Description = ((global::CSharpToJsonSchema.IntegrationTests.Weather2)value).Description; - if (__value_Description is not null) - { - writer.WriteString(PropName_description, __value_Description); - } - - writer.WriteEndObject(); - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.g.verified.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.g.verified.cs deleted file mode 100644 index 5869fdd..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict#IWeatherStrictTools.g.verified.cs +++ /dev/null @@ -1,111 +0,0 @@ -//HintName: IWeatherStrictTools.g.cs -// - -#nullable enable annotations -#nullable disable warnings - -// Suppress warnings about [Obsolete] member usage in generated code. -#pragma warning disable CS0612, CS0618 - -namespace CSharpToJsonSchema.IntegrationTests -{ - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("CSharpToJsonSchema.Generators", "3.0.0.0")] - public partial class WeatherStrictToolsExtensionsJsonSerializerContext - { - private readonly static global::System.Text.Json.JsonSerializerOptions s_defaultOptions = new(global::System.Text.Json.JsonSerializerDefaults.Web) - { - AllowOutOfOrderMetadataProperties = true, - AllowTrailingCommas = false, - DefaultBufferSize = 1024, - DefaultIgnoreCondition = global::System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull, - RespectNullableAnnotations = true, - RespectRequiredConstructorParameters = false, - IgnoreReadOnlyFields = false, - IgnoreReadOnlyProperties = false, - IncludeFields = false, - MaxDepth = 64, - NewLine = "\n", - NumberHandling = global::System.Text.Json.Serialization.JsonNumberHandling.Strict, - PreferredObjectCreationHandling = global::System.Text.Json.Serialization.JsonObjectCreationHandling.Replace, - PropertyNameCaseInsensitive = true, - PropertyNamingPolicy = global::System.Text.Json.JsonNamingPolicy.CamelCase, - ReadCommentHandling = global::System.Text.Json.JsonCommentHandling.Disallow, - UnknownTypeHandling = global::System.Text.Json.Serialization.JsonUnknownTypeHandling.JsonElement, - UnmappedMemberHandling = global::System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip, - WriteIndented = false, - IndentCharacter = ' ', - IndentSize = 2, - }; - - private const global::System.Reflection.BindingFlags InstanceMemberBindingFlags = - global::System.Reflection.BindingFlags.Instance | - global::System.Reflection.BindingFlags.Public | - global::System.Reflection.BindingFlags.NonPublic; - - /// - /// The default associated with a default instance. - /// - public static global::CSharpToJsonSchema.IntegrationTests.WeatherStrictToolsExtensionsJsonSerializerContext Default { get; } = new global::CSharpToJsonSchema.IntegrationTests.WeatherStrictToolsExtensionsJsonSerializerContext(new global::System.Text.Json.JsonSerializerOptions(s_defaultOptions)); - - /// - /// The source-generated options associated with this context. - /// - protected override global::System.Text.Json.JsonSerializerOptions? GeneratedSerializerOptions { get; } = s_defaultOptions; - - /// - public WeatherStrictToolsExtensionsJsonSerializerContext() : base(null) - { - } - - /// - public WeatherStrictToolsExtensionsJsonSerializerContext(global::System.Text.Json.JsonSerializerOptions options) : base(options) - { - } - - private static bool TryGetTypeInfoForRuntimeCustomConverter(global::System.Text.Json.JsonSerializerOptions options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo) - { - global::System.Text.Json.Serialization.JsonConverter? converter = GetRuntimeConverterForType(typeof(TJsonMetadataType), options); - if (converter != null) - { - jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo(options, converter); - return true; - } - - jsonTypeInfo = null; - return false; - } - - private static global::System.Text.Json.Serialization.JsonConverter? GetRuntimeConverterForType(global::System.Type type, global::System.Text.Json.JsonSerializerOptions options) - { - for (int i = 0; i < options.Converters.Count; i++) - { - global::System.Text.Json.Serialization.JsonConverter? converter = options.Converters[i]; - if (converter?.CanConvert(type) == true) - { - return ExpandConverter(type, converter, options, validateCanConvert: false); - } - } - - return null; - } - - private static global::System.Text.Json.Serialization.JsonConverter ExpandConverter(global::System.Type type, global::System.Text.Json.Serialization.JsonConverter converter, global::System.Text.Json.JsonSerializerOptions options, bool validateCanConvert = true) - { - if (validateCanConvert && !converter.CanConvert(type)) - { - throw new global::System.InvalidOperationException(string.Format("The converter '{0}' is not compatible with the type '{1}'.", converter.GetType(), type)); - } - - if (converter is global::System.Text.Json.Serialization.JsonConverterFactory factory) - { - converter = factory.CreateConverter(type, options); - if (converter is null || converter is global::System.Text.Json.Serialization.JsonConverterFactory) - { - throw new global::System.InvalidOperationException(string.Format("The converter '{0}' cannot return null or a JsonConverterFactory instance.", factory.GetType())); - } - } - - return converter; - } - } -} diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict_Diagnostics.verified.txt b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict_Diagnostics.verified.txt deleted file mode 100644 index ad47dbb..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.WeatherStrict_Diagnostics.verified.txt +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather_Diagnostics.verified.txt b/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather_Diagnostics.verified.txt deleted file mode 100644 index ad47dbb..0000000 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/Snapshots/ToolTests.Weather_Diagnostics.verified.txt +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/src/tests/CSharpToJsonSchema.SnapshotTests/TestHelper.cs b/src/tests/CSharpToJsonSchema.SnapshotTests/TestHelper.cs index 85062ed..b600bb4 100755 --- a/src/tests/CSharpToJsonSchema.SnapshotTests/TestHelper.cs +++ b/src/tests/CSharpToJsonSchema.SnapshotTests/TestHelper.cs @@ -33,13 +33,13 @@ public static async Task CheckSourceAsync( await Task.WhenAll( verifier .Verify(diagnostics) - //.AutoVerify() + .AutoVerify() .UseDirectory("Snapshots") .UseTextForParameters("Diagnostics"), verifier .Verify(driver) - //.AutoVerify() + .AutoVerify() .UseDirectory("Snapshots")); } } \ No newline at end of file