-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
Description
Consider the following snippet in a project marked for Native AOT publish (<PublishAot>true</PublishAot> but the same happens for <IsAotCompatible>true</IsAotCompatible>)
if (true)
{
Console.WriteLine("ok");
}
else
{
Console.WriteLine("dead code");
var myType2 = typeof(List<>).MakeGenericType(typeof(bool));
Console.WriteLine(myType2);
}When I build it, I get the following build output:
1>------ Rebuild All started: Project: AotErrorsThatShouldntBeThere, Configuration: Debug Any CPU ------
1>C:\Program Files\dotnet\sdk\8.0.400-preview.0.24276.1\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(311,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
Restored D:\Projects\AotErrorsThatShouldntBeThere\AotErrorsThatShouldntBeThere.csproj (in 13 ms).
1>D:\Projects\AotErrorsThatShouldntBeThere\Program.cs(11,5,11,12): warning CS0162: Unreachable code detected
1>D:\Projects\AotErrorsThatShouldntBeThere\Program.cs(12,19,12,63): warning IL3050: Using member 'System.Type.MakeGenericType(params Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
1>AotErrorsThatShouldntBeThere -> D:\Projects\AotErrorsThatShouldntBeThere\bin\Debug\net8.0\AotErrorsThatShouldntBeThere.dll
1>Done building project "AotErrorsThatShouldntBeThere.csproj".
Is there a way to not show the warning IL3050: Using member 'System.Type.MakeGenericType(params Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime. ?
I can do the actual publish and then get accurate errors, but that's quite cumbersome (proper publish takes much longer)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status