Skip to content

Commit

Permalink
disable warning about native aot
Browse files Browse the repository at this point in the history
  • Loading branch information
neuecc committed Dec 27, 2024
1 parent 2cf40f2 commit 6cd24d8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 8 additions & 2 deletions sandbox/NativeAot/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
using ConsoleAppFramework;

using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Text.Json;

var app = ConsoleApp.Create();

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

app.Run(args);
public class Kabayaki
{
public int MyProperty { get; set; }
}

10 changes: 6 additions & 4 deletions src/ConsoleAppFramework/ConsoleAppBaseCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public static class ConsoleAppBaseCode
#pragma warning disable CA1050 // Declare types in namespaces.
#pragma warning disable CS1998
#pragma warning disable CS8625
#pragma warning disable IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
#pragma warning disable IL2026 // Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code
namespace ConsoleAppFramework;
using System;
Expand Down Expand Up @@ -55,6 +57,8 @@ namespace ConsoleAppFramework;
#pragma warning disable CA1050 // Declare types in namespaces.
#pragma warning disable CS1998
#pragma warning disable CS8625
#pragma warning disable IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
#pragma warning disable IL2026 // Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code
namespace ConsoleAppFramework;
Expand Down Expand Up @@ -228,9 +232,7 @@ static bool TrySplitParse<T>(ReadOnlySpan<char> s, out T[] result)
{
try
{
var options = JsonSerializerOptions ?? System.Text.Json.JsonSerializerOptions.Default;
var type = (System.Text.Json.Serialization.Metadata.JsonTypeInfo<T[]>)options.GetTypeInfo(typeof(T[]))!;
result = System.Text.Json.JsonSerializer.Deserialize<T[]>(s, type)!;
result = System.Text.Json.JsonSerializer.Deserialize<T[]>(s, JsonSerializerOptions)!;
return true;
}
catch
Expand Down

0 comments on commit 6cd24d8

Please sign in to comment.