Skip to content

Remove RequiresUnsafeAnalyzer#127768

Open
jjonescz wants to merge 1 commit intodotnet:mainfrom
jjonescz:Unsafe-RemoveAnalyzer
Open

Remove RequiresUnsafeAnalyzer#127768
jjonescz wants to merge 1 commit intodotnet:mainfrom
jjonescz:Unsafe-RemoveAnalyzer

Conversation

@jjonescz
Copy link
Copy Markdown
Member

@jjonescz jjonescz commented May 4, 2026

@jjonescz jjonescz requested review from agocke and Copilot May 4, 2026 17:59
@github-actions github-actions Bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label May 4, 2026
@dotnet-policy-service dotnet-policy-service Bot added the linkable-framework Issues associated with delivering a linker friendly framework label May 4, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/illink
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 RequiresUnsafeAnalyzer and UnsafeMethodMissingRequiresUnsafeAnalyzer, plus their associated DiagnosticId entries and shared resource strings.
  • Remove corresponding code fix providers (RequiresUnsafeCodeFixProvider and UnsafeMethodMissingRequiresUnsafeCodeFixProvider) and all related analyzer/code-fix tests.
  • Stop wiring the removed analyzer into analyzer/test composition and remove the EnableUnsafeAnalyzer compiler-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”).

Copy link
Copy Markdown
Member

@am11 am11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@jjonescz
Copy link
Copy Markdown
Member Author

jjonescz commented May 6, 2026

@agocke had some concerns about this offline, I'll let him speak to this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Tools-ILLink .NET linker development as well as trimming analyzers linkable-framework Issues associated with delivering a linker friendly framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants