Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Commit

Permalink
Fix nested C# blocks when combined with C# @ symbols.
Browse files Browse the repository at this point in the history
- We used to accept until markup or an ending brace which didn't allow the parser to balance nested braces.

#679
  • Loading branch information
NTaylorMullen committed Mar 3, 2016
1 parent 38183b5 commit e6d4d6c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ private void StandardStatement()
{
Context.Source.Position = bookmark;
NextToken();
AcceptUntil(CSharpSymbolType.LessThan, CSharpSymbolType.RightBrace);
AcceptUntil(CSharpSymbolType.LessThan, CSharpSymbolType.LeftBrace, CSharpSymbolType.RightBrace);
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit e6d4d6c

Please sign in to comment.