dotnet / dotnet/linker

Improve support for Analyzer AOT warnings

Open
#2,495 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
392
Forks
128
Avg merge
2d 10h
Merged PRs (30d)
2

Description

Currently, we have an analyzer that can support [IL3050](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/warnings/il3050) and [IL3051](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/warnings/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](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/warnings/il3052), [IL3054](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/warnings/il3054), [IL3055](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/warnings/il3055), [IL3056](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/warnings/il3056) that need to be produced by the analyzer

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.