-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
is there a way to not show native AOT warnings for statically inaccessible code during build? #103250
Comments
Could you describe more of the scenario? I assume you don't have literal For the pattern you have there ( |
I'm trying to clean up AOT warnings in the EF Core repo. The plan is to use feature switches to trim out large portion of the problematic code base (query compilation, model generation). I need to figure all the strategic places that we need to put the feature switch guard in order to trim out that code. Since feature switch effectively converts the switch property into a constant, I was hoping I could simulate what the proper feature switch + publish would do by using constant directly and rely on compiler to show me if that block would have been trimmed out. We have around 60k warnings so I'm looking for a way to get quick-and-dirty way to to see incremental progress and/or test some stuff. I will try .net 9 and more recent VS, it should at least reduce the number of warnings that get reported and make my job bit easier, thanks. |
.NET 9 will have more capable analysis and it also has support for feature guards that might help keep the warnings away: dotnet/designs#305. My expectation would be that you'd start with placing One general warning I would give: suppressing trimming/AOT analysis warnings with UnconditionalSuppressMessages has been a bug farm even within the scope of the dotnet/runtime and dotnet/aspnetcore repos, so if you need to use that, assume it's introducing a bug unless proven otherwise (it should be reviewed with the same level of skepticism as Cc @sbomer |
Agreed, I'd recommend you use feature guards like |
thanks @MichalStrehovsky and @sbomer - feel free to close the issue |
Thanks! Happy to help if you have any questions about feature guards/switches. |
Consider the following snippet in a project marked for Native AOT publish (
<PublishAot>true</PublishAot>
but the same happens for<IsAotCompatible>true</IsAotCompatible>
)When I build it, I get the following build output:
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)
The text was updated successfully, but these errors were encountered: