Remove RequiresUnsafeAnalyzer#127768
Open
jjonescz wants to merge 1 commit intodotnet:mainfrom
Open
Conversation
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/illink |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the experimental RequiresUnsafe / UnsafeMethodMissingRequiresUnsafe analyzers and related code fixes from the ILLink Roslyn analyzer toolset, along with their tests and resource strings. This aligns ILLink’s analyzer/test infrastructure with the Roslyn direction that RequiresUnsafeAttribute should not be authored in source (favoring the unsafe modifier instead).
Changes:
- Remove
RequiresUnsafeAnalyzerandUnsafeMethodMissingRequiresUnsafeAnalyzer, plus their associatedDiagnosticIdentries and shared resource strings. - Remove corresponding code fix providers (
RequiresUnsafeCodeFixProviderandUnsafeMethodMissingRequiresUnsafeCodeFixProvider) and all related analyzer/code-fix tests. - Stop wiring the removed analyzer into analyzer/test composition and remove the
EnableUnsafeAnalyzercompiler-visible property from the ILLink analyzer props.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/UnsafeMethodMissingRequiresUnsafeTests.cs | Removes tests for the “missing RequiresUnsafe” analyzer and its code fix. |
| src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/TestCaseCompilation.cs | Stops adding RequiresUnsafeAnalyzer to the supported analyzer set in tests. |
| src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/RequiresUnsafeCodeFixTests.cs | Removes code fix tests that manipulate RequiresUnsafeAttribute usage. |
| src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/RequiresUnsafeAnalyzerTests.cs | Removes analyzer tests for RequiresUnsafe diagnostics. |
| src/tools/illink/src/ILLink.Shared/SharedStrings.resx | Removes shared strings for RequiresUnsafe-related diagnostics/titles/messages. |
| src/tools/illink/src/ILLink.Shared/DiagnosticId.cs | Removes DEBUG-only RequiresUnsafe diagnostic IDs and subcategory mapping. |
| src/tools/illink/src/ILLink.RoslynAnalyzer/UnsafeMethodMissingRequiresUnsafeAnalyzer.cs | Deletes the analyzer that suggested adding RequiresUnsafeAttribute for pointer-signature members. |
| src/tools/illink/src/ILLink.RoslynAnalyzer/RequiresUnsafeAnalyzer.cs | Deletes the analyzer producing RequiresUnsafe diagnostics. |
| src/tools/illink/src/ILLink.RoslynAnalyzer/MSBuildPropertyOptionNames.cs | Removes the DEBUG-only EnableUnsafeAnalyzer property constant. |
| src/tools/illink/src/ILLink.RoslynAnalyzer/DynamicallyAccessedMembersAnalyzer.cs | Stops registering the removed RequiresUnsafe analyzer in the “requires analyzers” set. |
| src/tools/illink/src/ILLink.RoslynAnalyzer/build/Microsoft.NET.ILLink.Analyzers.props | Removes EnableUnsafeAnalyzer from compiler-visible properties list. |
| src/tools/illink/src/ILLink.CodeFix/UnsafeMethodMissingRequiresUnsafeCodeFixProvider.cs | Deletes the code fix provider that adds RequiresUnsafeAttribute to pointer-signature members. |
| src/tools/illink/src/ILLink.CodeFix/Resources.resx | Removes code-fix resource strings tied to the deleted code fixes. |
| src/tools/illink/src/ILLink.CodeFix/RequiresUnsafeCodeFixProvider.cs | Deletes the code fix provider for RequiresUnsafe diagnostics (“add attribute” / “wrap in unsafe block”). |
This was referenced May 5, 2026
Open
EgorBo
approved these changes
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
See #127761 (comment).
Related to #125800 and dotnet/roslyn#81207.