Skip to content

Conversation

@sbomer
Copy link
Member

@sbomer sbomer commented Aug 5, 2024

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.

sbomer added 2 commits August 5, 2024 16:05
Instead, report them immediately.
ReflectionAccessAnalyzer will need to be able to produce diagnostics
with differing locations for a single call to
GetReflectionAccessDiagnostics, to support warnings for
DynamicallyAccessedMembers on type.

This matches ReflectionMarker in ILLink and ILC, where
MarkTypeForDynamicallyAccessedMembers takes a MessageOrigin rather
than a DiagnosticContext.
@ghost ghost added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Aug 5, 2024
@dotnet-policy-service dotnet-policy-service bot added the linkable-framework Issues associated with delivering a linker friendly framework label Aug 5, 2024
@sbomer sbomer requested a review from a team August 5, 2024 22:12
@sbomer
Copy link
Member Author

sbomer commented Aug 6, 2024

/ba-g "unrelated timeout in IcuSharding test"

@sbomer sbomer merged commit d5af5bd into dotnet:main Aug 6, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

linkable-framework Issues associated with delivering a linker friendly framework needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ILLink: Trim analyzer doesn't warn on reflection access to annotated members when the source of the Type is GetType on a DAM-annotated class

2 participants