Skip to content

Conversation

@sbomer
Copy link
Member

@sbomer sbomer commented Jul 21, 2025

See API proposal in #117524.

@sbomer sbomer requested review from a team and Copilot July 21, 2025 23:15
@sbomer sbomer mentioned this pull request Jul 21, 2025
@github-actions github-actions bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Jul 21, 2025
@dotnet-policy-service dotnet-policy-service bot added the linkable-framework Issues associated with delivering a linker friendly framework label Jul 21, 2025
Copy link
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 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();

@dotnet-policy-service
Copy link
Contributor

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

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Fix kept items validation for polyfilled attributes
- Clean up tests
- Fix to ignore NativeAOT injected members
@sbomer
Copy link
Member Author

sbomer commented Jul 23, 2025

/ba-g "timeouts"

@sbomer sbomer merged commit b019cbd into dotnet:main Jul 23, 2025
108 of 116 checks passed
@sbomer sbomer deleted the excludeStatics branch July 23, 2025 20:04
@github-actions github-actions bot locked and limited conversation to collaborators Aug 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

2 participants