diff --git a/sandbox/GeneratorSandbox/Program.cs b/sandbox/GeneratorSandbox/Program.cs index 68d7f13..2c0db53 100644 --- a/sandbox/GeneratorSandbox/Program.cs +++ b/sandbox/GeneratorSandbox/Program.cs @@ -10,6 +10,8 @@ //using Microsoft.Extensions.Options; //using ZLogger; + + //args = ["echo", "--msg", "zzzz"]; //// IHostBuilder @@ -145,6 +147,11 @@ namespace ConsoleAppFramework { internal static partial class ConsoleApp { + static void Foo() + { + var options = JsonSerializerOptions ?? System.Text.Json.JsonSerializerOptions.Default; + } + //public static ConsoleAppBuilder Create(IServiceProvider serviceProvider) //{ // ConsoleApp.ServiceProvider = serviceProvider; diff --git a/src/ConsoleAppFramework/ConsoleAppBaseCode.cs b/src/ConsoleAppFramework/ConsoleAppBaseCode.cs index 5eb8469..3b6c71a 100644 --- a/src/ConsoleAppFramework/ConsoleAppBaseCode.cs +++ b/src/ConsoleAppFramework/ConsoleAppBaseCode.cs @@ -228,7 +228,8 @@ static bool TrySplitParse(ReadOnlySpan s, out T[] result) { try { - var type = (System.Text.Json.Serialization.Metadata.JsonTypeInfo)JsonSerializerOptions.GetTypeInfo(typeof(T))!; + var options = JsonSerializerOptions ?? System.Text.Json.JsonSerializerOptions.Default; + var type = (System.Text.Json.Serialization.Metadata.JsonTypeInfo)options.GetTypeInfo(typeof(T[]))!; result = System.Text.Json.JsonSerializer.Deserialize(s, type)!; return true; }