Make ReflectionAccessAnalyzer logic more similar to ILLink/ILC #105956
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ReflectionAccessAnalyzer is analogous to ILLink/ILC's ReflectionMarker, and will be responsible for producing warnings about DynamicallyAccessedMembers on types when we fix #102002. These warnings will not all have the same location since they can be reported on different members of the type.
To support this, this is changing ReflectionAccessAnalyzer to create a DiagnosticContext as needed when reporting a warning, instead of taking it as an argument, which would require all warnings to share the same location (since DiagnosticContext holds a Location). This is similar to how ReflectionMarker takes a MessageOrigin instead of DiagnosticContext.
The first change makes DiagnosticContext report warnings immediately, instead of using it as a bag of warnings to be reported later. The second change does the factoring in ReflectionAccessAnalyzer.