Skip to content

Commit afcdfa7

Browse files
committed
resolve .NET 9 nativeaot warning
1 parent e205186 commit afcdfa7

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

sandbox/GeneratorSandbox/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
using ConsoleAppFramework;
44
using Microsoft.Extensions.DependencyInjection;
5+
using System.Text.Json;
56
//using Microsoft.Extensions.Configuration;
67
//using Microsoft.Extensions.DependencyInjection;
78
//// using Microsoft.Extensions.Hosting;
@@ -70,7 +71,7 @@
7071
// }
7172
//}
7273

73-
74+
// JsonSerializer.Deserialize<int>("foo");
7475

7576
//// inject logger to filter
7677
//internal class ReplaceLogFilter(ConsoleAppFilter next, ILogger<Program> logger)

sandbox/NativeAot/NativeAot.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net8.0</TargetFramework>
5+
<TargetFramework>net9.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<IsPackable>false</IsPackable>

sandbox/NativeAot/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55

66
//ConsoleApp.Run(args, (int x, int y) => Console.WriteLine(x + y));
77

8-
app.Run(args);
8+
app.Run(args);
9+

src/ConsoleAppFramework/ConsoleAppBaseCode.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ static bool TrySplitParse<T>(ReadOnlySpan<char> s, out T[] result)
228228
{
229229
try
230230
{
231-
result = System.Text.Json.JsonSerializer.Deserialize<T[]>(s, JsonSerializerOptions)!;
231+
var type = (System.Text.Json.Serialization.Metadata.JsonTypeInfo<T[]>)JsonSerializerOptions.GetTypeInfo(typeof(T))!;
232+
result = System.Text.Json.JsonSerializer.Deserialize<T[]>(s, type)!;
232233
return true;
233234
}
234235
catch

0 commit comments

Comments
 (0)