diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs index 6142e050d76..59dd15d9e23 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs @@ -931,6 +931,157 @@ public void CommentOnSameLineAsHtml() """); } + [Fact, WorkItem("https://github.com/dotnet/razor/issues/7230")] + public void SwitchExpression() + { + ParseDocumentTest(""" + @{ + var val = 0 switch + { + 0 => "value", + _ => "no value" + }; + } + """); + } + + [Fact, WorkItem("https://github.com/dotnet/razor/issues/7230")] + public void SwitchExpression_WithLessThan() + { + ParseDocumentTest(""" + @{ + var val = 0 switch + { + < 9 => "less than 10" + }; + } + """); + } + + [Fact, WorkItem("https://github.com/dotnet/razor/issues/7230")] + public void SwitchExpression_WithGreaterThan() + { + ParseDocumentTest(""" + @{ + var val = 0 switch + { + > 10 => "greater than 10" + }; + } + """); + } + + [Fact, WorkItem("https://github.com/dotnet/razor/issues/7230")] + public void SwitchExpression_WithMultipleComparisons() + { + ParseDocumentTest(""" + @{ + var val = 0 switch + { + < 9 => "less than 10", + 10 => "equal to 10", + > 10 => "greater than 10" + }; + } + """); + } + + [Fact, WorkItem("https://github.com/dotnet/razor/issues/7230")] + public void SwitchExpression_Incomplete() + { + ParseDocumentTest(""" + @{ + var val = 0 switch + { + 0 => "value" + + var val2 = "value2"; + } + """); + } + + [Fact, WorkItem("https://github.com/dotnet/razor/issues/7230")] + public void SwitchExpression_WithLessThan_Incomplete() + { + ParseDocumentTest(""" + @{ + var val = 0 switch + { + < 9 => "less than 10" + + var val2 = "value2"; + } + """); + } + + [Fact, WorkItem("https://github.com/dotnet/razor/issues/7230")] + public void SwitchExpression_WithWrongKeyword() + { + ParseDocumentTest(""" + @{ + var val = 0 using + { + 0 => "value" + }; + } + """); + } + + [Fact, WorkItem("https://github.com/dotnet/razor/issues/7230")] + public void SwitchExpression_WithWrongKeyword_AndLessThan() + { + ParseDocumentTest(""" + @{ + var val = 0 using + { + < 9 => "less than 10" + }; + } + """); + } + + [Fact, WorkItem("https://github.com/dotnet/razor/issues/7230")] + public void SwitchExpression_WithMarkupInside() + { + ParseDocumentTest(""" + @{ + var val = 0 switch + { + 0 => some html, + _ => "value" + }; + } + """); + } + + [Fact, WorkItem("https://github.com/dotnet/razor/issues/7230")] + public void SwitchExpression_WithMarkupInside_ViaAtSymbol() + { + ParseDocumentTest(""" + @{ + var val = 0 switch + { + 0 => @zero, + _ => @one + }; + } + """); + } + + [Fact, WorkItem("https://github.com/dotnet/razor/issues/7230")] + public void SwitchExpression_WithMarkupInside_WithLessThan() + { + ParseDocumentTest(""" + @{ + var val = 0 switch + { + < 10 => @less than 10, + _ => @other + }; + } + """); + } + private void RunRazorCommentBetweenClausesTest(string preComment, string postComment, AcceptedCharactersInternal acceptedCharacters = AcceptedCharactersInternal.Any) { ParseDocumentTest(preComment + "@* Foo *@ @* Bar *@" + postComment); diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpExplicitExpressionTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpExplicitExpressionTest.cs index 9dd2aafc484..03775950c01 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpExplicitExpressionTest.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpExplicitExpressionTest.cs @@ -4,6 +4,7 @@ #nullable disable using System; +using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.AspNetCore.Razor.Language.Legacy; @@ -76,4 +77,50 @@ public void ShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings() { ParseDocumentTest("@(@\"\"\"\"\"\")"); } + + [Fact, WorkItem("https://github.com/dotnet/razor/issues/7230")] + public void SwitchExpression() + { + ParseDocumentTest(""" + @(value switch{ + 10 => "ten", + _ => "other" + }) + + @code{ + public int value = 10; + } + """); + } + + [Fact, WorkItem("https://github.com/dotnet/razor/issues/7230")] + public void SwitchExpression_WithLessThan() + { + ParseDocumentTest(""" + @(value switch{ + < 10 => "less than", + 10 => "ten", + _ => "other" + }) + + @code{ + public int value = 10; + } + """); + } + + [Fact, WorkItem("https://github.com/dotnet/razor/issues/7230")] + public void SwitchExpression_WithHtml() + { + ParseDocumentTest(""" + @(value switch{ + 10 => ten, + _ => "other" + }) + + @code{ + public int value = 10; + } + """); + } } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression.cspans.txt new file mode 100644 index 00000000000..4735a170f25 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [92] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [92] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [92] ) +Code span at (2:0,2 [89] ) - Parent: Statement block at (0:0,0 [92] ) +MetaCode span at (91:6,0 [1] ) - Parent: Statement block at (0:0,0 [92] ) +Markup span at (92:6,1 [0] ) - Parent: Markup block at (0:0,0 [92] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression.stree.txt new file mode 100644 index 00000000000..c12ad43af9b --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression.stree.txt @@ -0,0 +1,52 @@ +RazorDocument - [0..92)::92 - [@{LF var val = 0 switchLF {LF 0 => "value",LF _ => "no value"LF };LF}] + MarkupBlock - [0..92)::92 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..92)::92 + CSharpStatement - [0..92)::92 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..92)::91 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..91)::89 + CSharpStatementLiteral - [2..91)::89 - [LF var val = 0 switchLF {LF 0 => "value",LF _ => "no value"LF };LF] - Gen + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[var]; + Whitespace;[ ]; + Identifier;[val]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + NumericLiteral;[0]; + Whitespace;[ ]; + Keyword;[switch]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + NumericLiteral;[0]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + StringLiteral;["value"]; + Comma;[,]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[_]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + StringLiteral;["no value"]; + NewLine;[LF]; + Whitespace;[ ]; + RightBrace;[}]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [91..92)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [92..92)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_Incomplete.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_Incomplete.cspans.txt new file mode 100644 index 00000000000..c01f9850b2a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_Incomplete.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [86] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [86] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [86] ) +Code span at (2:0,2 [84] ) - Parent: Statement block at (0:0,0 [86] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_Incomplete.diag.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_Incomplete.diag.txt new file mode 100644 index 00000000000..bcd37730bb1 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_Incomplete.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_Incomplete.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_Incomplete.stree.txt new file mode 100644 index 00000000000..cb8363db2ba --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_Incomplete.stree.txt @@ -0,0 +1,50 @@ +RazorDocument - [0..86)::86 - [@{LF var val = 0 switchLF {LF 0 => "value"LFLF var val2 = "value2";LF}] + MarkupBlock - [0..86)::86 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..86)::86 + CSharpStatement - [0..86)::86 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..86)::85 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..86)::84 + CSharpStatementLiteral - [2..86)::84 - [LF var val = 0 switchLF {LF 0 => "value"LFLF var val2 = "value2";LF}] - Gen + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[var]; + Whitespace;[ ]; + Identifier;[val]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + NumericLiteral;[0]; + Whitespace;[ ]; + Keyword;[switch]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + NumericLiteral;[0]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + StringLiteral;["value"]; + NewLine;[LF]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[var]; + Whitespace;[ ]; + Identifier;[val2]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["value2"]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; + RazorMetaCode - [86..86)::0 - Gen + RightBrace;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithGreaterThan.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithGreaterThan.cspans.txt new file mode 100644 index 00000000000..419520ad9b6 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithGreaterThan.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [79] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [79] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [79] ) +Code span at (2:0,2 [76] ) - Parent: Statement block at (0:0,0 [79] ) +MetaCode span at (78:5,0 [1] ) - Parent: Statement block at (0:0,0 [79] ) +Markup span at (79:5,1 [0] ) - Parent: Markup block at (0:0,0 [79] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithGreaterThan.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithGreaterThan.stree.txt new file mode 100644 index 00000000000..a55bfd990a0 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithGreaterThan.stree.txt @@ -0,0 +1,46 @@ +RazorDocument - [0..79)::79 - [@{LF var val = 0 switchLF {LF > 10 => "greater than 10"LF };LF}] + MarkupBlock - [0..79)::79 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..79)::79 + CSharpStatement - [0..79)::79 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..79)::78 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..78)::76 + CSharpStatementLiteral - [2..78)::76 - [LF var val = 0 switchLF {LF > 10 => "greater than 10"LF };LF] - Gen + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[var]; + Whitespace;[ ]; + Identifier;[val]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + NumericLiteral;[0]; + Whitespace;[ ]; + Keyword;[switch]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + GreaterThan;[>]; + Whitespace;[ ]; + NumericLiteral;[10]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + StringLiteral;["greater than 10"]; + NewLine;[LF]; + Whitespace;[ ]; + RightBrace;[}]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [78..79)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [79..79)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithLessThan.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithLessThan.cspans.txt new file mode 100644 index 00000000000..11d636f3db8 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithLessThan.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [75] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [75] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [75] ) +Code span at (2:0,2 [72] ) - Parent: Statement block at (0:0,0 [75] ) +MetaCode span at (74:5,0 [1] ) - Parent: Statement block at (0:0,0 [75] ) +Markup span at (75:5,1 [0] ) - Parent: Markup block at (0:0,0 [75] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithLessThan.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithLessThan.stree.txt new file mode 100644 index 00000000000..e0c2dcba4ad --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithLessThan.stree.txt @@ -0,0 +1,46 @@ +RazorDocument - [0..75)::75 - [@{LF var val = 0 switchLF {LF < 9 => "less than 10"LF };LF}] + MarkupBlock - [0..75)::75 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..75)::75 + CSharpStatement - [0..75)::75 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..75)::74 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..74)::72 + CSharpStatementLiteral - [2..74)::72 - [LF var val = 0 switchLF {LF < 9 => "less than 10"LF };LF] - Gen + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[var]; + Whitespace;[ ]; + Identifier;[val]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + NumericLiteral;[0]; + Whitespace;[ ]; + Keyword;[switch]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + NumericLiteral;[9]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + StringLiteral;["less than 10"]; + NewLine;[LF]; + Whitespace;[ ]; + RightBrace;[}]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [74..75)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [75..75)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithLessThan_Incomplete.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithLessThan_Incomplete.cspans.txt new file mode 100644 index 00000000000..ef773df7ec6 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithLessThan_Incomplete.cspans.txt @@ -0,0 +1,4 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [95] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [95] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [95] ) +Code span at (2:0,2 [93] ) - Parent: Statement block at (0:0,0 [95] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithLessThan_Incomplete.diag.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithLessThan_Incomplete.diag.txt new file mode 100644 index 00000000000..bcd37730bb1 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithLessThan_Incomplete.diag.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithLessThan_Incomplete.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithLessThan_Incomplete.stree.txt new file mode 100644 index 00000000000..22f33697f27 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithLessThan_Incomplete.stree.txt @@ -0,0 +1,52 @@ +RazorDocument - [0..95)::95 - [@{LF var val = 0 switchLF {LF < 9 => "less than 10"LFLF var val2 = "value2";LF}] + MarkupBlock - [0..95)::95 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..95)::95 + CSharpStatement - [0..95)::95 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..95)::94 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..95)::93 + CSharpStatementLiteral - [2..95)::93 - [LF var val = 0 switchLF {LF < 9 => "less than 10"LFLF var val2 = "value2";LF}] - Gen + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[var]; + Whitespace;[ ]; + Identifier;[val]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + NumericLiteral;[0]; + Whitespace;[ ]; + Keyword;[switch]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + NumericLiteral;[9]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + StringLiteral;["less than 10"]; + NewLine;[LF]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[var]; + Whitespace;[ ]; + Identifier;[val2]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + StringLiteral;["value2"]; + Semicolon;[;]; + NewLine;[LF]; + RightBrace;[}]; + RazorMetaCode - [95..95)::0 - Gen + RightBrace;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMarkupInside.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMarkupInside.cspans.txt new file mode 100644 index 00000000000..4731ba0bbe5 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMarkupInside.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [111] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [111] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [111] ) +Code span at (2:0,2 [108] ) - Parent: Statement block at (0:0,0 [111] ) +MetaCode span at (110:6,0 [1] ) - Parent: Statement block at (0:0,0 [111] ) +Markup span at (111:6,1 [0] ) - Parent: Markup block at (0:0,0 [111] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMarkupInside.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMarkupInside.stree.txt new file mode 100644 index 00000000000..3bd30db8269 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMarkupInside.stree.txt @@ -0,0 +1,68 @@ +RazorDocument - [0..111)::111 - [@{LF var val = 0 switchLF {LF 0 => some html,LF _ => "value"LF };LF}] + MarkupBlock - [0..111)::111 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..111)::111 + CSharpStatement - [0..111)::111 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..111)::110 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..110)::108 + CSharpStatementLiteral - [2..110)::108 - [LF var val = 0 switchLF {LF 0 => some html,LF _ => "value"LF };LF] - Gen + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[var]; + Whitespace;[ ]; + Identifier;[val]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + NumericLiteral;[0]; + Whitespace;[ ]; + Keyword;[switch]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + NumericLiteral;[0]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + LessThan;[<]; + Identifier;[span]; + GreaterThan;[>]; + Identifier;[some]; + Whitespace;[ ]; + LessThan;[<]; + Identifier;[i]; + GreaterThan;[>]; + Identifier;[html]; + LessThan;[<]; + CSharpOperator;[/]; + Identifier;[i]; + GreaterThan;[>]; + LessThan;[<]; + CSharpOperator;[/]; + Identifier;[span]; + GreaterThan;[>]; + Comma;[,]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[_]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + StringLiteral;["value"]; + NewLine;[LF]; + Whitespace;[ ]; + RightBrace;[}]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [110..111)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [111..111)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMarkupInside_ViaAtSymbol.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMarkupInside_ViaAtSymbol.cspans.txt new file mode 100644 index 00000000000..7ec01ca859a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMarkupInside_ViaAtSymbol.cspans.txt @@ -0,0 +1,17 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [110] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [110] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [110] ) +Code span at (2:0,2 [46] ) - Parent: Statement block at (0:0,0 [110] ) +Transition span at (48:3,13 [1] ) - Parent: Markup block at (48:3,13 [18] ) +Markup span at (49:3,14 [6] ) - Parent: Tag block at (49:3,14 [6] ) +Markup span at (55:3,20 [4] ) - Parent: Markup block at (48:3,13 [18] ) +Markup span at (59:3,24 [7] ) - Parent: Tag block at (59:3,24 [7] ) +Code span at (66:3,31 [16] ) - Parent: Statement block at (0:0,0 [110] ) +Transition span at (82:4,13 [1] ) - Parent: Markup block at (82:4,13 [19] ) +Markup span at (83:4,14 [6] ) - Parent: Tag block at (83:4,14 [6] ) +Markup span at (89:4,20 [3] ) - Parent: Markup block at (82:4,13 [19] ) +Markup span at (92:4,23 [7] ) - Parent: Tag block at (92:4,23 [7] ) +Markup span at (99:4,30 [2] ) - Parent: Markup block at (82:4,13 [19] ) +Code span at (101:5,0 [8] ) - Parent: Statement block at (0:0,0 [110] ) +MetaCode span at (109:6,0 [1] ) - Parent: Statement block at (0:0,0 [110] ) +Markup span at (110:6,1 [0] ) - Parent: Markup block at (0:0,0 [110] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMarkupInside_ViaAtSymbol.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMarkupInside_ViaAtSymbol.stree.txt new file mode 100644 index 00000000000..7e71ccb5aba --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMarkupInside_ViaAtSymbol.stree.txt @@ -0,0 +1,85 @@ +RazorDocument - [0..110)::110 - [@{LF var val = 0 switchLF {LF 0 => @zero,LF _ => @oneLF };LF}] + MarkupBlock - [0..110)::110 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..110)::110 + CSharpStatement - [0..110)::110 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..110)::109 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..109)::107 + CSharpStatementLiteral - [2..48)::46 - [LF var val = 0 switchLF {LF 0 => ] - Gen + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[var]; + Whitespace;[ ]; + Identifier;[val]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + NumericLiteral;[0]; + Whitespace;[ ]; + Keyword;[switch]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + NumericLiteral;[0]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + CSharpTemplateBlock - [48..66)::18 + MarkupBlock - [48..66)::18 + MarkupTransition - [48..49)::1 - Gen + Transition;[@]; + MarkupElement - [49..66)::17 + MarkupStartTag - [49..55)::6 - [] - Gen + OpenAngle;[<]; + Text;[span]; + CloseAngle;[>]; + MarkupTextLiteral - [55..59)::4 - [zero] - Gen + Text;[zero]; + MarkupEndTag - [59..66)::7 - [] - Gen + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[span]; + CloseAngle;[>]; + CSharpStatementLiteral - [66..82)::16 - [,LF _ => ] - Gen + Comma;[,]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[_]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + CSharpTemplateBlock - [82..101)::19 + MarkupBlock - [82..101)::19 + MarkupTransition - [82..83)::1 - Gen + Transition;[@]; + MarkupElement - [83..99)::16 + MarkupStartTag - [83..89)::6 - [] - Gen + OpenAngle;[<]; + Text;[span]; + CloseAngle;[>]; + MarkupTextLiteral - [89..92)::3 - [one] - Gen + Text;[one]; + MarkupEndTag - [92..99)::7 - [] - Gen + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[span]; + CloseAngle;[>]; + MarkupTextLiteral - [99..101)::2 - [LF] - Gen + NewLine;[LF]; + CSharpStatementLiteral - [101..109)::8 - [ };LF] - Gen + Whitespace;[ ]; + RightBrace;[}]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [109..110)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [110..110)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMarkupInside_WithLessThan.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMarkupInside_WithLessThan.cspans.txt new file mode 100644 index 00000000000..9abc93e8674 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMarkupInside_WithLessThan.cspans.txt @@ -0,0 +1,17 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [123] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [123] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [123] ) +Code span at (2:0,2 [49] ) - Parent: Statement block at (0:0,0 [123] ) +Transition span at (51:3,16 [1] ) - Parent: Markup block at (51:3,16 [26] ) +Markup span at (52:3,17 [6] ) - Parent: Tag block at (52:3,17 [6] ) +Markup span at (58:3,23 [12] ) - Parent: Markup block at (51:3,16 [26] ) +Markup span at (70:3,35 [7] ) - Parent: Tag block at (70:3,35 [7] ) +Code span at (77:3,42 [16] ) - Parent: Statement block at (0:0,0 [123] ) +Transition span at (93:4,13 [1] ) - Parent: Markup block at (93:4,13 [21] ) +Markup span at (94:4,14 [6] ) - Parent: Tag block at (94:4,14 [6] ) +Markup span at (100:4,20 [5] ) - Parent: Markup block at (93:4,13 [21] ) +Markup span at (105:4,25 [7] ) - Parent: Tag block at (105:4,25 [7] ) +Markup span at (112:4,32 [2] ) - Parent: Markup block at (93:4,13 [21] ) +Code span at (114:5,0 [8] ) - Parent: Statement block at (0:0,0 [123] ) +MetaCode span at (122:6,0 [1] ) - Parent: Statement block at (0:0,0 [123] ) +Markup span at (123:6,1 [0] ) - Parent: Markup block at (0:0,0 [123] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMarkupInside_WithLessThan.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMarkupInside_WithLessThan.stree.txt new file mode 100644 index 00000000000..c77d1d81932 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMarkupInside_WithLessThan.stree.txt @@ -0,0 +1,91 @@ +RazorDocument - [0..123)::123 - [@{LF var val = 0 switchLF {LF < 10 => @less than 10,LF _ => @otherLF };LF}] + MarkupBlock - [0..123)::123 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..123)::123 + CSharpStatement - [0..123)::123 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..123)::122 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..122)::120 + CSharpStatementLiteral - [2..51)::49 - [LF var val = 0 switchLF {LF < 10 => ] - Gen + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[var]; + Whitespace;[ ]; + Identifier;[val]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + NumericLiteral;[0]; + Whitespace;[ ]; + Keyword;[switch]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + NumericLiteral;[10]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + CSharpTemplateBlock - [51..77)::26 + MarkupBlock - [51..77)::26 + MarkupTransition - [51..52)::1 - Gen + Transition;[@]; + MarkupElement - [52..77)::25 + MarkupStartTag - [52..58)::6 - [] - Gen + OpenAngle;[<]; + Text;[span]; + CloseAngle;[>]; + MarkupTextLiteral - [58..70)::12 - [less than 10] - Gen + Text;[less]; + Whitespace;[ ]; + Text;[than]; + Whitespace;[ ]; + Text;[10]; + MarkupEndTag - [70..77)::7 - [] - Gen + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[span]; + CloseAngle;[>]; + CSharpStatementLiteral - [77..93)::16 - [,LF _ => ] - Gen + Comma;[,]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[_]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + CSharpTemplateBlock - [93..114)::21 + MarkupBlock - [93..114)::21 + MarkupTransition - [93..94)::1 - Gen + Transition;[@]; + MarkupElement - [94..112)::18 + MarkupStartTag - [94..100)::6 - [] - Gen + OpenAngle;[<]; + Text;[span]; + CloseAngle;[>]; + MarkupTextLiteral - [100..105)::5 - [other] - Gen + Text;[other]; + MarkupEndTag - [105..112)::7 - [] - Gen + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[span]; + CloseAngle;[>]; + MarkupTextLiteral - [112..114)::2 - [LF] - Gen + NewLine;[LF]; + CSharpStatementLiteral - [114..122)::8 - [ };LF] - Gen + Whitespace;[ ]; + RightBrace;[}]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [122..123)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [123..123)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMultipleComparisons.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMultipleComparisons.cspans.txt new file mode 100644 index 00000000000..6c30f50644f --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMultipleComparisons.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [141] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [141] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [141] ) +Code span at (2:0,2 [138] ) - Parent: Statement block at (0:0,0 [141] ) +MetaCode span at (140:7,0 [1] ) - Parent: Statement block at (0:0,0 [141] ) +Markup span at (141:7,1 [0] ) - Parent: Markup block at (0:0,0 [141] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMultipleComparisons.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMultipleComparisons.stree.txt new file mode 100644 index 00000000000..26350dfd805 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithMultipleComparisons.stree.txt @@ -0,0 +1,64 @@ +RazorDocument - [0..141)::141 - [@{LF var val = 0 switchLF {LF < 9 => "less than 10",LF 10 => "equal to 10",LF > 10 => "greater than 10"LF };LF}] + MarkupBlock - [0..141)::141 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..141)::141 + CSharpStatement - [0..141)::141 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..141)::140 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..140)::138 + CSharpStatementLiteral - [2..140)::138 - [LF var val = 0 switchLF {LF < 9 => "less than 10",LF 10 => "equal to 10",LF > 10 => "greater than 10"LF };LF] - Gen + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[var]; + Whitespace;[ ]; + Identifier;[val]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + NumericLiteral;[0]; + Whitespace;[ ]; + Keyword;[switch]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + NumericLiteral;[9]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + StringLiteral;["less than 10"]; + Comma;[,]; + NewLine;[LF]; + Whitespace;[ ]; + NumericLiteral;[10]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + StringLiteral;["equal to 10"]; + Comma;[,]; + NewLine;[LF]; + Whitespace;[ ]; + GreaterThan;[>]; + Whitespace;[ ]; + NumericLiteral;[10]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + StringLiteral;["greater than 10"]; + NewLine;[LF]; + Whitespace;[ ]; + RightBrace;[}]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [140..141)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [141..141)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithWrongKeyword.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithWrongKeyword.cspans.txt new file mode 100644 index 00000000000..c7077e09573 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithWrongKeyword.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [65] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [65] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [65] ) +Code span at (2:0,2 [62] ) - Parent: Statement block at (0:0,0 [65] ) +MetaCode span at (64:5,0 [1] ) - Parent: Statement block at (0:0,0 [65] ) +Markup span at (65:5,1 [0] ) - Parent: Markup block at (0:0,0 [65] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithWrongKeyword.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithWrongKeyword.stree.txt new file mode 100644 index 00000000000..0c6a1ab1dea --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithWrongKeyword.stree.txt @@ -0,0 +1,44 @@ +RazorDocument - [0..65)::65 - [@{LF var val = 0 usingLF {LF 0 => "value"LF };LF}] + MarkupBlock - [0..65)::65 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..65)::65 + CSharpStatement - [0..65)::65 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..65)::64 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..64)::62 + CSharpStatementLiteral - [2..64)::62 - [LF var val = 0 usingLF {LF 0 => "value"LF };LF] - Gen + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[var]; + Whitespace;[ ]; + Identifier;[val]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + NumericLiteral;[0]; + Whitespace;[ ]; + Keyword;[using]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + NumericLiteral;[0]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + StringLiteral;["value"]; + NewLine;[LF]; + Whitespace;[ ]; + RightBrace;[}]; + Semicolon;[;]; + NewLine;[LF]; + RazorMetaCode - [64..65)::1 - Gen + RightBrace;[}]; + MarkupTextLiteral - [65..65)::0 - [] - Gen + Marker;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithWrongKeyword_AndLessThan.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithWrongKeyword_AndLessThan.cspans.txt new file mode 100644 index 00000000000..f8ab6e1670e --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithWrongKeyword_AndLessThan.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [75] ) +Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [75] ) +MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [75] ) +Code span at (2:0,2 [32] ) - Parent: Statement block at (0:0,0 [75] ) +Markup span at (34:3,0 [9] ) - Parent: Markup block at (34:3,0 [41] ) +Markup span at (43:3,9 [1] ) - Parent: Tag block at (43:3,9 [6] ) +Markup span at (44:3,10 [4] ) - Parent: Markup block at (44:3,10 [4] ) +Markup span at (48:3,14 [1] ) - Parent: Tag block at (43:3,9 [6] ) +Markup span at (49:3,15 [26] ) - Parent: Markup block at (34:3,0 [41] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithWrongKeyword_AndLessThan.diag.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithWrongKeyword_AndLessThan.diag.txt new file mode 100644 index 00000000000..38f0aa59af9 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithWrongKeyword_AndLessThan.diag.txt @@ -0,0 +1,2 @@ +(1,2): Error RZ1006: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. +(4,11): Error RZ1025: The "" element was not closed. All elements must be either self-closing or have a matching end tag. diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithWrongKeyword_AndLessThan.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithWrongKeyword_AndLessThan.stree.txt new file mode 100644 index 00000000000..aa7b280ad89 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/SwitchExpression_WithWrongKeyword_AndLessThan.stree.txt @@ -0,0 +1,61 @@ +RazorDocument - [0..75)::75 - [@{LF var val = 0 usingLF {LF < 9 => "less than 10"LF };LF}] + MarkupBlock - [0..75)::75 + MarkupTextLiteral - [0..0)::0 - [] - Gen + Marker;[]; + CSharpCodeBlock - [0..75)::75 + CSharpStatement - [0..75)::75 + CSharpTransition - [0..1)::1 - Gen + Transition;[@]; + CSharpStatementBody - [1..75)::74 + RazorMetaCode - [1..2)::1 - Gen + LeftBrace;[{]; + CSharpCodeBlock - [2..75)::73 + CSharpStatementLiteral - [2..34)::32 - [LF var val = 0 usingLF {LF] - Gen + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[var]; + Whitespace;[ ]; + Identifier;[val]; + Whitespace;[ ]; + Assign;[=]; + Whitespace;[ ]; + NumericLiteral;[0]; + Whitespace;[ ]; + Keyword;[using]; + NewLine;[LF]; + Whitespace;[ ]; + LeftBrace;[{]; + NewLine;[LF]; + MarkupBlock - [34..75)::41 + MarkupTextLiteral - [34..43)::9 - [ ] - Gen + Whitespace;[ ]; + MarkupElement - [43..75)::32 + MarkupStartTag - [43..49)::6 - [< 9 =>] - Gen + OpenAngle;[<]; + Text;[]; + MarkupAttributeBlock - [44..48)::4 - [ 9 =] + MarkupTextLiteral - [44..45)::1 - [ ] - Gen + Whitespace;[ ]; + MarkupTextLiteral - [45..46)::1 - [9] - Gen + Text;[9]; + MarkupTextLiteral - [46..47)::1 - [ ] - Gen + Whitespace;[ ]; + Equals;[=]; + CloseAngle;[>]; + MarkupTextLiteral - [49..75)::26 - [ "less than 10"LF };LF}] - Gen + Whitespace;[ ]; + DoubleQuote;["]; + Text;[less]; + Whitespace;[ ]; + Text;[than]; + Whitespace;[ ]; + Text;[10]; + DoubleQuote;["]; + NewLine;[LF]; + Whitespace;[ ]; + Text;[};]; + NewLine;[LF]; + Text;[}]; + RazorMetaCode - [75..75)::0 - Gen + RightBrace;[]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/SwitchExpression.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/SwitchExpression.cspans.txt new file mode 100644 index 00000000000..36f15ecb9d1 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/SwitchExpression.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [6] ) - Parent: Tag block at (0:0,0 [6] ) +Transition span at (6:0,6 [1] ) - Parent: Expression block at (6:0,6 [55] ) +MetaCode span at (7:0,7 [1] ) - Parent: Expression block at (6:0,6 [55] ) +Code span at (8:0,8 [52] ) - Parent: Expression block at (6:0,6 [55] ) +MetaCode span at (60:3,1 [1] ) - Parent: Expression block at (6:0,6 [55] ) +Markup span at (61:3,2 [7] ) - Parent: Tag block at (61:3,2 [7] ) +Markup span at (68:3,9 [4] ) - Parent: Markup block at (0:0,0 [109] ) +Transition span at (72:5,0 [1] ) - Parent: Expression block at (72:5,0 [5] ) +Code span at (73:5,1 [4] ) - Parent: Expression block at (72:5,0 [5] ) +Markup span at (77:5,5 [32] ) - Parent: Markup block at (0:0,0 [109] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/SwitchExpression.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/SwitchExpression.stree.txt new file mode 100644 index 00000000000..55d1ff488cb --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/SwitchExpression.stree.txt @@ -0,0 +1,71 @@ +RazorDocument - [0..109)::109 - [@(value switch{LF 10 => "ten",LF _ => "other"LF})LFLF@code{LF public int value = 10;LF}] + MarkupBlock - [0..109)::109 + MarkupElement - [0..68)::68 + MarkupStartTag - [0..6)::6 - [] - Gen + OpenAngle;[<]; + Text;[span]; + CloseAngle;[>]; + CSharpCodeBlock - [6..61)::55 + CSharpExplicitExpression - [6..61)::55 + CSharpTransition - [6..7)::1 - Gen + Transition;[@]; + CSharpExplicitExpressionBody - [7..61)::54 + RazorMetaCode - [7..8)::1 - Gen + LeftParenthesis;[(]; + CSharpCodeBlock - [8..60)::52 + CSharpExpressionLiteral - [8..60)::52 - [value switch{LF 10 => "ten",LF _ => "other"LF}] - Gen + Identifier;[value]; + Whitespace;[ ]; + Keyword;[switch]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + NumericLiteral;[10]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + StringLiteral;["ten"]; + Comma;[,]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[_]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + StringLiteral;["other"]; + NewLine;[LF]; + RightBrace;[}]; + RazorMetaCode - [60..61)::1 - Gen + RightParenthesis;[)]; + MarkupEndTag - [61..68)::7 - [] - Gen + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[span]; + CloseAngle;[>]; + MarkupTextLiteral - [68..72)::4 - [LFLF] - Gen + NewLine;[LF]; + NewLine;[LF]; + CSharpCodeBlock - [72..77)::5 + CSharpImplicitExpression - [72..77)::5 + CSharpTransition - [72..73)::1 - Gen + Transition;[@]; + CSharpImplicitExpressionBody - [73..77)::4 + CSharpCodeBlock - [73..77)::4 + CSharpExpressionLiteral - [73..77)::4 - [code] - Gen + Identifier;[code]; + MarkupTextLiteral - [77..109)::32 - [{LF public int value = 10;LF}] - Gen + Text;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Text;[public]; + Whitespace;[ ]; + Text;[int]; + Whitespace;[ ]; + Text;[value]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[10;]; + NewLine;[LF]; + Text;[}]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/SwitchExpression_WithHtml.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/SwitchExpression_WithHtml.cspans.txt new file mode 100644 index 00000000000..eb6c6326224 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/SwitchExpression_WithHtml.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [6] ) - Parent: Tag block at (0:0,0 [6] ) +Transition span at (6:0,6 [1] ) - Parent: Expression block at (6:0,6 [66] ) +MetaCode span at (7:0,7 [1] ) - Parent: Expression block at (6:0,6 [66] ) +Code span at (8:0,8 [63] ) - Parent: Expression block at (6:0,6 [66] ) +MetaCode span at (71:3,1 [1] ) - Parent: Expression block at (6:0,6 [66] ) +Markup span at (72:3,2 [7] ) - Parent: Tag block at (72:3,2 [7] ) +Markup span at (79:3,9 [4] ) - Parent: Markup block at (0:0,0 [120] ) +Transition span at (83:5,0 [1] ) - Parent: Expression block at (83:5,0 [5] ) +Code span at (84:5,1 [4] ) - Parent: Expression block at (83:5,0 [5] ) +Markup span at (88:5,5 [32] ) - Parent: Markup block at (0:0,0 [120] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/SwitchExpression_WithHtml.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/SwitchExpression_WithHtml.stree.txt new file mode 100644 index 00000000000..498c07c5c23 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/SwitchExpression_WithHtml.stree.txt @@ -0,0 +1,78 @@ +RazorDocument - [0..120)::120 - [@(value switch{LF 10 => ten,LF _ => "other"LF})LFLF@code{LF public int value = 10;LF}] + MarkupBlock - [0..120)::120 + MarkupElement - [0..79)::79 + MarkupStartTag - [0..6)::6 - [] - Gen + OpenAngle;[<]; + Text;[span]; + CloseAngle;[>]; + CSharpCodeBlock - [6..72)::66 + CSharpExplicitExpression - [6..72)::66 + CSharpTransition - [6..7)::1 - Gen + Transition;[@]; + CSharpExplicitExpressionBody - [7..72)::65 + RazorMetaCode - [7..8)::1 - Gen + LeftParenthesis;[(]; + CSharpCodeBlock - [8..71)::63 + CSharpExpressionLiteral - [8..71)::63 - [value switch{LF 10 => ten,LF _ => "other"LF}] - Gen + Identifier;[value]; + Whitespace;[ ]; + Keyword;[switch]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + NumericLiteral;[10]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + LessThan;[<]; + Identifier;[span]; + GreaterThan;[>]; + Identifier;[ten]; + LessThan;[<]; + CSharpOperator;[/]; + Identifier;[span]; + GreaterThan;[>]; + Comma;[,]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[_]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + StringLiteral;["other"]; + NewLine;[LF]; + RightBrace;[}]; + RazorMetaCode - [71..72)::1 - Gen + RightParenthesis;[)]; + MarkupEndTag - [72..79)::7 - [] - Gen + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[span]; + CloseAngle;[>]; + MarkupTextLiteral - [79..83)::4 - [LFLF] - Gen + NewLine;[LF]; + NewLine;[LF]; + CSharpCodeBlock - [83..88)::5 + CSharpImplicitExpression - [83..88)::5 + CSharpTransition - [83..84)::1 - Gen + Transition;[@]; + CSharpImplicitExpressionBody - [84..88)::4 + CSharpCodeBlock - [84..88)::4 + CSharpExpressionLiteral - [84..88)::4 - [code] - Gen + Identifier;[code]; + MarkupTextLiteral - [88..120)::32 - [{LF public int value = 10;LF}] - Gen + Text;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Text;[public]; + Whitespace;[ ]; + Text;[int]; + Whitespace;[ ]; + Text;[value]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[10;]; + NewLine;[LF]; + Text;[}]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/SwitchExpression_WithLessThan.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/SwitchExpression_WithLessThan.cspans.txt new file mode 100644 index 00000000000..3fda7945558 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/SwitchExpression_WithLessThan.cspans.txt @@ -0,0 +1,10 @@ +Markup span at (0:0,0 [6] ) - Parent: Tag block at (0:0,0 [6] ) +Transition span at (6:0,6 [1] ) - Parent: Expression block at (6:0,6 [81] ) +MetaCode span at (7:0,7 [1] ) - Parent: Expression block at (6:0,6 [81] ) +Code span at (8:0,8 [78] ) - Parent: Expression block at (6:0,6 [81] ) +MetaCode span at (86:4,1 [1] ) - Parent: Expression block at (6:0,6 [81] ) +Markup span at (87:4,2 [7] ) - Parent: Tag block at (87:4,2 [7] ) +Markup span at (94:4,9 [4] ) - Parent: Markup block at (0:0,0 [135] ) +Transition span at (98:6,0 [1] ) - Parent: Expression block at (98:6,0 [5] ) +Code span at (99:6,1 [4] ) - Parent: Expression block at (98:6,0 [5] ) +Markup span at (103:6,5 [32] ) - Parent: Markup block at (0:0,0 [135] ) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/SwitchExpression_WithLessThan.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/SwitchExpression_WithLessThan.stree.txt new file mode 100644 index 00000000000..df30587b92d --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpExplicitExpressionTest/SwitchExpression_WithLessThan.stree.txt @@ -0,0 +1,81 @@ +RazorDocument - [0..135)::135 - [@(value switch{LF < 10 => "less than",LF 10 => "ten",LF _ => "other"LF})LFLF@code{LF public int value = 10;LF}] + MarkupBlock - [0..135)::135 + MarkupElement - [0..94)::94 + MarkupStartTag - [0..6)::6 - [] - Gen + OpenAngle;[<]; + Text;[span]; + CloseAngle;[>]; + CSharpCodeBlock - [6..87)::81 + CSharpExplicitExpression - [6..87)::81 + CSharpTransition - [6..7)::1 - Gen + Transition;[@]; + CSharpExplicitExpressionBody - [7..87)::80 + RazorMetaCode - [7..8)::1 - Gen + LeftParenthesis;[(]; + CSharpCodeBlock - [8..86)::78 + CSharpExpressionLiteral - [8..86)::78 - [value switch{LF < 10 => "less than",LF 10 => "ten",LF _ => "other"LF}] - Gen + Identifier;[value]; + Whitespace;[ ]; + Keyword;[switch]; + LeftBrace;[{]; + NewLine;[LF]; + Whitespace;[ ]; + LessThan;[<]; + Whitespace;[ ]; + NumericLiteral;[10]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + StringLiteral;["less than"]; + Comma;[,]; + NewLine;[LF]; + Whitespace;[ ]; + NumericLiteral;[10]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + StringLiteral;["ten"]; + Comma;[,]; + NewLine;[LF]; + Whitespace;[ ]; + Keyword;[_]; + Whitespace;[ ]; + CSharpOperator;[=>]; + Whitespace;[ ]; + StringLiteral;["other"]; + NewLine;[LF]; + RightBrace;[}]; + RazorMetaCode - [86..87)::1 - Gen + RightParenthesis;[)]; + MarkupEndTag - [87..94)::7 - [] - Gen + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[span]; + CloseAngle;[>]; + MarkupTextLiteral - [94..98)::4 - [LFLF] - Gen + NewLine;[LF]; + NewLine;[LF]; + CSharpCodeBlock - [98..103)::5 + CSharpImplicitExpression - [98..103)::5 + CSharpTransition - [98..99)::1 - Gen + Transition;[@]; + CSharpImplicitExpressionBody - [99..103)::4 + CSharpCodeBlock - [99..103)::4 + CSharpExpressionLiteral - [99..103)::4 - [code] - Gen + Identifier;[code]; + MarkupTextLiteral - [103..135)::32 - [{LF public int value = 10;LF}] - Gen + Text;[{]; + NewLine;[LF]; + Whitespace;[ ]; + Text;[public]; + Whitespace;[ ]; + Text;[int]; + Whitespace;[ ]; + Text;[value]; + Whitespace;[ ]; + Equals;[=]; + Whitespace;[ ]; + Text;[10;]; + NewLine;[LF]; + Text;[}]; + EndOfFile;[]; diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/CSharpCodeParser.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/CSharpCodeParser.cs index 1270c10c540..9e9b47b7d43 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/CSharpCodeParser.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/CSharpCodeParser.cs @@ -997,7 +997,8 @@ not SyntaxKind.Transition and not SyntaxKind.LeftBrace and not SyntaxKind.LeftParenthesis and not SyntaxKind.LeftBracket and - not SyntaxKind.RightBrace, + not SyntaxKind.RightBrace and + not SyntaxKind.Keyword, ref read.AsRef()); if ((!Context.Options.AllowRazorInAllCodeBlocks && At(SyntaxKind.LeftBrace)) || @@ -1005,14 +1006,8 @@ not SyntaxKind.LeftBracket and At(SyntaxKind.LeftBracket)) { Accept(in read); - if (Balance(builder, BalancingModes.AllowCommentsAndTemplates | BalancingModes.BacktrackOnFailure)) + if (!TryBalanceBlock(builder)) { - TryAccept(SyntaxKind.RightBrace); - } - else - { - // Recovery - AcceptUntil(SyntaxKind.LessThan, SyntaxKind.RightBrace); return; } } @@ -1106,6 +1101,23 @@ not SyntaxKind.LeftBracket and Accept(in read); return; } + else if (At(SyntaxKind.Keyword)) + { + Accept(in read); + if (CurrentToken.Content == "switch") + { + AcceptUntil(SyntaxKind.LeftBrace); // TODO: how do we do error recovery at this point? + if (!TryBalanceBlock(builder)) + { + return; + } + } + else + { + // unknown keyword, continue parsing + AcceptAndMoveNext(); + } + } else { _tokenizer.Reset(bookmark); @@ -1114,6 +1126,22 @@ not SyntaxKind.LeftBracket and return; } } + + bool TryBalanceBlock(SyntaxListBuilder builder) + { + if (Balance(builder, BalancingModes.AllowCommentsAndTemplates | BalancingModes.BacktrackOnFailure)) + { + TryAccept(SyntaxKind.RightBrace); + } + else + { + // Recovery + AcceptUntil(SyntaxKind.LessThan, SyntaxKind.RightBrace); + return false; + } + + return true; + } } private void ParseTemplate(in SyntaxListBuilder builder)