Add ExcludeStatics support to trimming tools#117904
Merged
sbomer merged 4 commits intodotnet:mainfrom Jul 23, 2025
Merged
Conversation
And doc comments
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for the ExcludeStatics property to the RequiresUnreferencedCode and RequiresDynamicCode attributes in trimming tools. This feature allows developers to apply requires attributes to classes while excluding static members from the warnings, providing more granular control over trim analysis.
Key changes:
- Added
ExcludeStaticsproperty to attribute definitions and parsing logic - Updated trimmer analysis logic to skip static members when
ExcludeStatics = true - Added comprehensive test cases to validate the new functionality
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/tools/illink/src/ILLink.Shared/RequiresUnreferencedCodeAttribute.cs |
Added new attribute definition with ExcludeStatics property |
src/tools/illink/src/ILLink.Shared/RequiresDynamicCodeAttribute.cs |
Added new attribute definition with ExcludeStatics property |
src/tools/illink/src/linker/Linker/LinkerAttributesInformation.cs |
Updated attribute parsing to handle ExcludeStatics property |
src/tools/illink/src/linker/Linker/Annotations.cs |
Modified analysis logic to respect ExcludeStatics setting |
src/tools/illink/src/ILLink.RoslynAnalyzer/RequiresISymbolExtensions.cs |
Updated analyzer to handle ExcludeStatics in Roslyn context |
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/DiagnosticUtilities.cs |
Updated NativeAOT compiler analysis logic |
src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresExcludeStatics.cs |
Comprehensive test cases for ExcludeStatics functionality |
| Various test infrastructure files | Updated to include new attribute files and test support |
Comments suppressed due to low confidence (1)
src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresOnClass.cs:86
- The call to AttributedMethod() is added without any context or expectations. If this is meant to test specific behavior, it should have corresponding ExpectedWarning or UnexpectedWarning attributes.
AttributedMethod();
src/tools/illink/src/ILLink.RoslynAnalyzer/RequiresISymbolExtensions.cs
Outdated
Show resolved
Hide resolved
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/DiagnosticUtilities.cs
Outdated
Show resolved
Hide resolved
Contributor
|
Tagging subscribers to this area: @dotnet/illink |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This was referenced Jul 22, 2025
Open
jtschuster
approved these changes
Jul 22, 2025
Member
Author
|
/ba-g "timeouts" |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 API proposal in #117524.