-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Add ExcludeStatics support to trimming tools #117904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
And doc comments
There was a problem hiding this 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 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
ExcludeStatics
property 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
Tagging subscribers to this area: @dotnet/illink |
Co-authored-by: Copilot <[email protected]>
See API proposal in #117524.