Fix nested C# blocks when combined with C# @ symbols.
- We used to accept until markup or an ending brace which didn't allow the parser to balance nested braces. #679
This commit is contained in:
parent
38183b5887
commit
e6d4d6c7a1
|
|
@ -654,7 +654,7 @@ namespace Microsoft.AspNetCore.Razor.Parser
|
|||
{
|
||||
Context.Source.Position = bookmark;
|
||||
NextToken();
|
||||
AcceptUntil(CSharpSymbolType.LessThan, CSharpSymbolType.RightBrace);
|
||||
AcceptUntil(CSharpSymbolType.LessThan, CSharpSymbolType.LeftBrace, CSharpSymbolType.RightBrace);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,20 @@ namespace Microsoft.AspNetCore.Razor.Test.Parser.CSharp
|
|||
{
|
||||
public class CSharpBlockTest : CsHtmlCodeParserTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void ParseBlock_NestedCodeBlockWithCSharpAt()
|
||||
{
|
||||
ParseBlockTest("{ if (true) { var val = @x; if (val != 3) { } } }",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("{").Accepts(AcceptedCharacters.None),
|
||||
Factory
|
||||
.Code(" if (true) { var val = @x; if (val != 3) { } } ")
|
||||
.AsStatement()
|
||||
.Accepts(AcceptedCharacters.Any)
|
||||
.AutoCompleteWith(autoCompleteString: null, atEndOfSpan: false),
|
||||
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseBlock_NestedCodeBlockWithMarkupSetsDotAsMarkup()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue