Fix invalid suppression in System.Attribute #70710
Closed
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.
The suppression on
System.Attributeis wrong. Ran into this in #70201 whereEditorBrowsableAttributeTests.EqualsTestis failing because we didn't generate any reflection metadata for the field. This proves beyond any doubt that even I can't write a correct trim warning suppression.There's a difference between "a field is kept" and "a field is accessible from reflection without issues". The issue is more pronounced in Native AOT (where the field can be completely erased from reflection). The implementation of
Attribute.Equalsdidn't see any fields on the attribute type because the static analysis didn't deem any of them necessary.Fields (or methods) that are provably not visible from reflection without warnings are free to be optimized in any way by trimming (e.g. how we strip method parameter names in illink).
This fixes the suppression and replaces it with a more correct DAM on type.
Cc @dotnet/ilc-contrib