-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Add CompilerLoweringPreserveAttribute #117729
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
Conversation
And apply it to DynamicallyAccessedMembersAttribute. This ensures that DAM flows to compiler-generated code.
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 introduces a new CompilerLoweringPreserveAttribute
and applies it to DynamicallyAccessedMembersAttribute
to ensure that dynamically accessed members information flows correctly to compiler-generated code. This addresses issue #103430 where the DAM attribute was not being preserved during compiler lowering transformations.
Key changes:
- Adds a new
CompilerLoweringPreserveAttribute
class for marking attributes that should be preserved during compiler lowering - Applies this attribute to
DynamicallyAccessedMembersAttribute
to fix the flow issue - Updates project files to include the new attribute in builds targeting older frameworks
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/CompilerLoweringPreserveAttribute.cs |
New attribute class definition with conditional visibility |
src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/DynamicallyAccessedMembersAttribute.cs |
Applies the new preserve attribute to DAM |
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems |
Includes new attribute in shared project items |
src/libraries/System.Runtime/ref/System.Runtime.cs |
Adds reference API surface for the new attribute and decorates DAM |
src/libraries/System.Text.Json/src/System.Text.Json.csproj |
Includes new attribute for non-.NET Core builds |
src/libraries/System.Text.Json/ref/System.Text.Json.csproj |
Includes new attribute in reference assembly |
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.
LGTM. Thanks!
Tagging subscribers to this area: @dotnet/area-system-runtime-compilerservices |
/ba-g "timeout" |
And apply it to DynamicallyAccessedMembersAttribute. This ensures that DAM flows to compiler-generated code.
Fixes #103430
Fixes #101861 (tests are in a separate PR: #117624)