Skip to content
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

Improve support for Analyzer AOT warnings #2495

Open
agocke opened this issue Jan 10, 2022 · 4 comments
Open

Improve support for Analyzer AOT warnings #2495

agocke opened this issue Jan 10, 2022 · 4 comments

Comments

@agocke
Copy link
Member

agocke commented Jan 10, 2022

Currently, we have an analyzer that can support IL3050 and IL3051. This allows having warnings into methods and classes annotated with RequiresDynamicCode when they are accessed, which is similar behavior to what we have for RequiresUnreferencedCode.

In the case of RequiresUnreferencedCode we use a DynamicallyAccessedMembersAnalyzer to conduct a broader analysis, we run a Dataflow section in which special methods considered "intrinsics" are treated as special method calls. They are considered special because although the methods are annotated with RequiresUnreferencedCode and they will warn in certain scenarios, we use the dataflow analysis to understand the inputs to the method and try not to warn for scenarios that are safe for trimming.

For AOT, we have a similar number of intrinsics that the compiler does a broader analysis in order to warn only in certain scenarios but at this moment they all will warn unconditionally e.g. with MakeGenericType

Additional to the intrinsic support which are methods annotated with RequiresDynamicCode they are certain patterns that the AOT compiler verifies during the analysis phase and creates warnings for IL3052, IL3054, IL3055, IL3056 that need to be produced by the analyzer

@agocke agocke added this to Needs triage in AppModel .NET 7 via automation Jan 10, 2022
@agocke agocke moved this from Needs triage to Normal priority in AppModel .NET 7 Jan 10, 2022
@tlakollo
Copy link
Contributor

Less relevant but in the same line, NativeAOT needs a place to document warnings. We already have the RequiresDynamicCode warning produced by both the AOT code and analyzer, but is not in the Microsoft Docs

@vitek-karas
Copy link
Member

The warnings are now documented, for example: https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/warnings/il3050

@tlakollo do you remember what kind of support is this issue about? We do have the analyzer for RequiresDynamicCode. Do we need anything more?

The only thing I'm aware of is that NativeAOT has special handling for a couple of APIs like Enum.GetValues and might avoid producing IL3050 if it can figure the type in question. But that's a relatively niche thing.
And for that we would have start treating RequiresDynamicCode just like RequiresUnreferencedCode and make it part of the data flow analysis.

@tlakollo
Copy link
Contributor

I think this issue refers to two different things, mainly the intrinsic support for NativeAOT, second part is the diagnostic codes that are currently not produced by the analyzer IL3053-IL3055 but likely are even more niche to encounter. This issue was filled when we already had support for IL3050-IL3052

@vitek-karas
Copy link
Member

Since you have more context, could you please rename the issue and add larger description about what it wants?

@tlakollo tlakollo changed the title Analyzer needs support for AOT warnings Improve support for Analyzer AOT warnings Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
AppModel .NET 7
Normal priority
Development

No branches or pull requests

3 participants