-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Do not return nonexistent kinds in SyntaxFacts
' methods
#72264
Conversation
SyntaxFacts
' methodsSyntaxFacts
' methods
Could you please elaborate what the problem is and open an issue that describes a user-facing problem? Even though there is no member in the enum, the number is still reserved. And |
I was working on a fix for #72258. I decided to populate all C# keywords' texts upfront, so I can later return them as completions. In order to achieve that I used
It is perfectly fine to reserve number ranges for different kinds of enum values. I would say, it is also fine to return unexisting kinds in an internal API, since this fact can then be shared as a common knowledge in the team, so additional checks can be made on caller side if necessary. However, this is public API and I can say with a very high level of certainty that consumers of public API by default assume that if API returns an enum value, this is an actual existing value of that enum. So I would classify this as a bug regardless of the user scenario it was discovered in (and I provided the way I personally discovered it) |
I am afraid we still need an issue, especially as you classify the behavior as a bug. |
Filled #72300 and #72301. I'll put this PR into a draft state until both issues are discussed and approved as actual bugs. Personally I feel very strongly about the first one being a bug and less strongly about the second one (but it is still not normal behavior IMO) |
4ab304c
to
2254bfb
Compare
@AlekseyTs #72300 has been classified as a bug. I've reverted other changes in this PR, so it only fixes that issue. This is now ready for review |
SyntaxFacts
' methodsSyntaxFacts
' methods
Done with review pass (commit 6) |
Done with review pass (commit 8) |
Done with review pass (commit 9) |
Done with review pass (commit 10) |
@@ -142,9 +145,10 @@ public static IEnumerable<SyntaxKind> GetPreprocessorKeywordKinds() | |||
yield return SyntaxKind.TrueKeyword; | |||
yield return SyntaxKind.FalseKeyword; | |||
yield return SyntaxKind.DefaultKeyword; | |||
yield return SyntaxKind.HiddenKeyword; | |||
|
|||
for (int i = (int)SyntaxKind.ElifKeyword; i <= (int)SyntaxKind.RestoreKeyword; i++) |
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.
The [SyntaxKind.ElifKeyword
- SyntaxKind.RestoreKeyword
] range already contains SyntaxKind.HiddenKeyword
, so I removed the duplicate. Found while working on tests
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 (commit 11), assuming CI is passing.
@dotnet/roslyn-compiler For the second review. |
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 (iteration 11)
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
Merged/squashed. Thanks for the contribution! |
Fixes: #72300