Skip to content

Make ReflectionAccessAnalyzer logic more similar to ILLink/ILC - #105956

Merged
sbomer merged 2 commits into
dotnet:mainfrom
sbomer:reportDiagnostics
Aug 6, 2024
Merged

Make ReflectionAccessAnalyzer logic more similar to ILLink/ILC#105956
sbomer merged 2 commits into
dotnet:mainfrom
sbomer:reportDiagnostics

Conversation

@sbomer

@sbomersbomer commented Aug 5, 2024

Copy link
Copy Markdown
Member

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.

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.
@ghostghost 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-servicedotnet-policy-serviceBot added the linkable-framework Issues associated with delivering a linker friendly framework label Aug 5, 2024
@sbomer
sbomer requested a review from a teamAugust 5, 2024 22:12
@sbomer

Copy link
Copy Markdown
MemberAuthor

/ba-g "unrelated timeout in IcuSharding test"

@sbomer
sbomer merged commit d5af5bd into dotnet:mainAug 6, 2024
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Sep 7, 2024
@sbomer
sbomer deleted the reportDiagnostics branch June 26, 2026 18:08
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

linkable-frameworkIssues associated with delivering a linker friendly frameworkneeds-area-labelAn 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

@sbomer@vitek-karas