-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Fix custom-attribute generic argument dataflow in the trimmer #128776
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
Open
Copilot
wants to merge
11
commits into
main
Choose a base branch
from
copilot/fix-trimmer-parameterless-constructor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
004bcff
Initial plan
Copilot 00f3516
Add failing ILLink test for new()-constrained generic attribute argument
Copilot 732780f
Process generic argument dataflow for custom attribute types to keep …
Copilot 72898f2
Apply suggestion from @jtschuster
jtschuster 69ba2bf
Apply suggestion from @jtschuster
jtschuster 9cb20b9
Apply suggestion from @jtschuster
jtschuster 9dfc881
Apply suggestion from @jtschuster
jtschuster 4d72619
Address PR feedback on generic attribute dataflow coverage
Copilot 3df8a70
Get GenericAttributes illink test to green; cover achievable DAM gene…
Copilot f9748e8
Merge branch 'main' into copilot/fix-trimmer-parameterless-constructor
jtschuster 44cee58
Fix IL2089-2095 generic-parameter message regression in trimmer
jtschuster File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
52 changes: 52 additions & 0 deletions
52
.../illink/test/Mono.Linker.Tests.Cases/Attributes/Dependencies/GenericAttributesDataFlow.il
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| .assembly extern System.Runtime | ||
| { | ||
| .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) | ||
| } | ||
| .assembly 'GenericAttributesDataFlow' | ||
| { | ||
| .hash algorithm 0x00008004 | ||
| .ver 1:0:0:0 | ||
| } | ||
| .module GenericAttributesDataFlow.dll | ||
|
|
||
| .namespace Mono.Linker.Tests.Cases.Attributes.Dependencies | ||
| { | ||
| // A generic attribute whose type parameter requires DynamicallyAccessedMemberTypes.PublicMethods. | ||
| .class public auto ansi beforefieldinit DynamicallyAccessedMembersGenericAttribute`1<T> | ||
| extends [System.Runtime]System.Attribute | ||
| { | ||
| .param type T | ||
| .custom instance void [System.Runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes) = ( | ||
| 01 00 08 00 00 00 00 00 | ||
| ) | ||
|
|
||
| .method public hidebysig specialname rtspecialname | ||
| instance default void '.ctor' () cil managed | ||
| { | ||
| .maxstack 8 | ||
| IL_0000: ldarg.0 | ||
| IL_0001: call instance void class [System.Runtime]System.Attribute::'.ctor'() | ||
| IL_0006: ret | ||
| } | ||
| } | ||
|
|
||
| // The attribute is applied with the class's own generic parameter as the generic argument. This | ||
| // construct cannot be expressed in C# (CS8968: an attribute type argument cannot use type | ||
| // parameters), so it is provided in IL. The trimmer must analyze the generic-argument data flow of | ||
| // the attribute without crashing and warn (IL2091) because the unannotated generic argument does | ||
| // not satisfy the attribute's PublicMethods requirement. | ||
| .class public auto ansi beforefieldinit ClassWithUnannotatedTypeParameter`1<T> | ||
| extends [System.Runtime]System.Object | ||
| { | ||
| .custom instance void class Mono.Linker.Tests.Cases.Attributes.Dependencies.DynamicallyAccessedMembersGenericAttribute`1<!T>::'.ctor'() = (01 00 00 00) | ||
|
|
||
| .method public hidebysig specialname rtspecialname | ||
| instance default void '.ctor' () cil managed | ||
| { | ||
| .maxstack 8 | ||
| IL_0000: ldarg.0 | ||
| IL_0001: call instance void class [System.Runtime]System.Object::'.ctor'() | ||
| IL_0006: ret | ||
| } | ||
| } | ||
| } |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.