-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add ConstantExpectedAttribute #62436
Add ConstantExpectedAttribute #62436
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
...ries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/ConstantExpectedAttribute.cs
Show resolved
Hide resolved
...aries/System.Runtime/tests/System/Diagnostics/CodeAnalysis/ConstantExpectedAttributeTests.cs
Outdated
Show resolved
Hide resolved
...aries/System.Runtime/tests/System/Diagnostics/CodeAnalysis/ConstantExpectedAttributeTests.cs
Outdated
Show resolved
Hide resolved
...aries/System.Runtime/tests/System/Diagnostics/CodeAnalysis/ConstantExpectedAttributeTests.cs
Outdated
Show resolved
Hide resolved
Thanks for the tests as well! @stephentoub - What do you make of the idea of adding unit tests like the below? var attr = new ConstantExpectedAttribute { Min = 10, Max = 0 };
// assert blah blah It's clearly incorrect to write that, but it's nonsense that should be caught at design time and not as part of the attribute's own logic. Would it ever make sense to include this as an "it's nonsense but the attribute setters shouldn't block this" check? |
Seems reasonable. |
Tagging subscribers to this area: @tommcdon Issue DetailsContributes to #33771
|
...ries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/ConstantExpectedAttribute.cs
Outdated
Show resolved
Hide resolved
...ries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/ConstantExpectedAttribute.cs
Outdated
Show resolved
Hide resolved
...ries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/ConstantExpectedAttribute.cs
Outdated
Show resolved
Hide resolved
…deAnalysis/ConstantExpectedAttribute.cs
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.
Thanks @wzchua, LGTM
I assume there are existing APIs, in particular in intrinsics, where this should be used? #30740 (comment) calls out some. Is there any issue tracking attributing those parameters? In general my preference is to use new APIs in the same PRs that add those APIs, in order to help validate them. As this has already been merged, it could be done in a follow-up. |
Sure I was planning to create an issue for tracking the APIs needs this, created #63426
Understand, for this one it was not clear what parameters of what API's needs this except the one you mentioned, hope @tannergooding would add the APIs to the new issue. Merged the PR so that it could be able to be used for the analyzer as soon as getting available for roslyn-analyzers repo. |
Contributes to #33771