-
Notifications
You must be signed in to change notification settings - Fork 128
Fix inconsistencies in Requires attribute checks #2553
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
- Remove unnecessary check for ITypeSymbol - Clean up null check logic
tlakollo
left a comment
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.
Looks good to me
vitek-karas
left a comment
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.
Looks good - maybe just one nit about making it future proof by always validating the RUC attribute.
| if (instanceCtor.TargetHasRequiresAttribute (RequiresAttributeName, out var requiresAttribute) && | ||
| VerifyAttributeArguments (requiresAttribute)) { |
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.
In @tlakollo PR there will be a single method to do this at once: https://github.com/dotnet/linker/pull/2418/files#diff-6417c9266a49f206907dd0ece745dc0c77c5f5c9a0c92ec3bb749d4c8e2c039aR14-R15
Please make sure we end up using it here as well.
| if (symbol is ITypeSymbol) | ||
| return false; | ||
|
|
||
| if (symbol.HasAttribute (requiresAttribute) |
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.
I'm thinking a safer thing would be to call "Validate" on the attribute as well - it basically checks that the attribute is in the form we recognize. As a safe guard against potential future changes which could for example add some kind of "feature condition" to the RUC attribute (I know we've discussed this), in which case the attribute is not always "active", so it's safer to NOT recognize it.
|
Thanks @vitek-karas, I will track those suggestions in #2554 |
* Fix inconsistencies in Requires attribute checks * Fix build and continue verifying attribute arguments * PR feedback - Remove unnecessary check for ITypeSymbol - Clean up null check logic * containingSymbol -> symbol * Rename symbol -> member
* Fix inconsistencies in Requires attribute checks * Fix build and continue verifying attribute arguments * PR feedback - Remove unnecessary check for ITypeSymbol - Clean up null check logic * containingSymbol -> symbol * Rename symbol -> member Commit migrated from dotnet/linker@b2e8419
While investigating failures in #2536 I came across a bunch of places where we check for RequiresAttribute without considering RUC on type.
dynamicshould be silenced in a method whose declaring type has RequiresAttributeI added tests for all of the above. Also fixes #2529.
I noticed another inconsistency in the attribute checks that I'm not addressing here: #2554