Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

Factor ReflectionMethodBodyScanner to be more similar to analyzer - #2761

Merged
vitek-karas merged 6 commits into
dotnet:mainfrom
sbomer:reflectionMarker
Apr 26, 2022
Merged

vitek-karas merged 6 commits into
dotnet:mainfrom
sbomer:reflectionMarker

Conversation

@sbomer

@sbomer sbomer commented Apr 25, 2022

Copy link
Copy Markdown
Member

Follow-up to #2747. This is a factoring change only and doesn't introduce functional changes.

This does two things to move the method body scanner to be more similar to the trim analysis visitor:

  • Uses DiagnosticContext to record diagnostics. Right now, this still happens inline as we run the scanner, but the idea will be to move this out to a driver that runs the analysis, and then records diagnostics from the recorded patterns (like how it is done in the analyzer)
  • Moves reflection-marking helpers out of ReflectionMethodBodyScanner to a separate class. This prevents us from having to pass around the scanner to other helpers, and makes it more obvious which parts of the code to scanning only vs other things. The new ReflectionMarker is conceptually similar to ReflectionAccessAnalyzer in the Roslyn analyzer and could be a candidate for future code sharing.

- Clean up left-over comments, newlines
- Remove unnecessary MessageOrigin argument
@vitek-karas

Copy link
Copy Markdown
Member

I'm going to merge this - working on more sharing and this would come really handy.

@vitek-karas
vitek-karas merged commit f26189b into dotnet:main Apr 26, 2022
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
…tnet/linker#2761)

Follow-up to dotnet/linker#2747. This is a factoring change only and doesn't introduce functional changes.

This does two things to move the method body scanner to be more similar to the trim analysis visitor:
- Uses `DiagnosticContext` to record diagnostics. Right now, this still happens inline as we run the scanner, but the idea will be to move this out to a driver that runs the analysis, and then records diagnostics from the recorded patterns (like how it is done in the analyzer)
- Moves reflection-marking helpers out of `ReflectionMethodBodyScanner` to a separate class. This prevents us from having to pass around the scanner to other helpers, and makes it more obvious which parts of the code to scanning only vs other things. The new `ReflectionMarker` is conceptually similar to `ReflectionAccessAnalyzer` in the Roslyn analyzer and could be a candidate for future code sharing.

Commit migrated from dotnet/linker@f26189b
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants