-
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
Escape record
keywords
#74227
base: main
Are you sure you want to change the base?
Escape record
keywords
#74227
Conversation
@@ -991,6 +991,8 @@ public static SyntaxKind GetKeywordKind(string text) | |||
return SyntaxKind.UsingKeyword; | |||
case "class": | |||
return SyntaxKind.ClassKeyword; | |||
case "record": | |||
return SyntaxKind.RecordKeyword; |
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.
We can't make this appear as keyword kind. We likely need to special case it in the visitor.
@@ -127,7 +127,7 @@ private static bool IsEscapable(SymbolDisplayPartKind kind) | |||
private static string EscapeIdentifier(string identifier) | |||
{ | |||
var kind = SyntaxFacts.GetKeywordKind(identifier); | |||
return kind == SyntaxKind.None | |||
return kind == SyntaxKind.None && !StringComparer.Ordinal.Equals(identifier, "record") |
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 could be wrong again about this, but this seems the next most logical place to always escape record identifiers
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.
Almost. I think we likely want this, but we also want to only escape some kinds. Let's add a parallel to IsEscapable specifically for records; we only want to escape type names, as that's all we warn on. We can then pass that flag into EscapeIdentifier
and adjust this second half of the condition appropriately.
See issue #74117 where it was decided that records should be escaped, even though they're not keywords, as it is the safer thing to do.
See other PR #74125