Skip to content

Conversation

333fred
Copy link
Member

@333fred 333fred commented Jul 18, 2024

This type effectively duplicates a lot of Roslyn's SyntaxKind. So we just use that instead.

This type effectively duplicates a lot of Roslyn's SyntaxKind. So we just use that instead.
@333fred 333fred marked this pull request as ready for review July 18, 2024 22:59
@333fred 333fred requested a review from a team as a code owner July 18, 2024 22:59
@333fred
Copy link
Member Author

333fred commented Jul 18, 2024

@dotnet/razor-compiler for review. This is an easily-extractable part of the lexer change, so I went ahead and pulled it out.

{ "namespace", CSharpKeyword.Namespace },
{ "when", CSharpKeyword.When },
{ "where", CSharpKeyword.Where }
private static readonly Dictionary<string, CSharpSyntaxKind> _keywords = new Dictionary<string, CSharpSyntaxKind>(StringComparer.Ordinal)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider making this a FrozenDictionary in the future.

{
var result = CSharpTokenizer.GetTokenKeyword(CurrentToken);
return result.HasValue && (result.Value == CSharpKeyword.True || result.Value == CSharpKeyword.False);
return LegacyCSharpTokenizer.GetTokenKeyword(CurrentToken) is CSharpSyntaxKind.TrueKeyword or CSharpSyntaxKind.FalseKeyword;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is LegacyCSharpTokenizer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's sign I missed one thing when fixing up the cherry-pick

{ "namespace", CSharpSyntaxKind.NamespaceKeyword },
{ "when", CSharpSyntaxKind.WhenKeyword },
{ "where", CSharpSyntaxKind.WhereKeyword }
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a test or assert that checks those match (stringifying the enum value gives back a string equal to the key)

@DustinCampbell
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-compiler Umbrella for all compiler issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants