Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

SteveDunn
Copy link
Contributor

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

@SteveDunn SteveDunn requested a review from a team as a code owner July 1, 2024 21:17
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Jul 1, 2024
@dotnet-policy-service dotnet-policy-service bot added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Jul 1, 2024
@@ -991,6 +991,8 @@ public static SyntaxKind GetKeywordKind(string text)
return SyntaxKind.UsingKeyword;
case "class":
return SyntaxKind.ClassKeyword;
case "record":
return SyntaxKind.RecordKeyword;
Copy link
Member

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")
Copy link
Contributor Author

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

Copy link
Member

@333fred 333fred Jul 2, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Community The pull request was submitted by a contributor who is not a Microsoft employee. untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants