diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs index 257d8a202d..4fb9fe7b6a 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs @@ -9,105 +9,52 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpErrorTest : CsHtmlCodeParserTestBase { + public CSharpErrorTest() + { + UseBaselineTests = true; + } + [Fact] public void ParseBlockHandlesQuotesAfterTransition() { - ParseBlockTest("@\"", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.EmptyCSharp() - .AsImplicitExpression(KeywordSet) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace) - ), - RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), - "\"")); + ParseBlockTest("@\""); } [Fact] public void ParseBlockWithHelperDirectiveProducesError() { - ParseBlockTest("@helper fooHelper { }", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("helper") - .AsImplicitExpression(KeywordSet) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - RazorDiagnosticFactory.CreateParsing_HelperDirectiveNotAvailable( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 6))); + ParseBlockTest("@helper fooHelper { }"); } [Fact] public void ParseBlockWithNestedCodeBlockProducesError() { - ParseBlockTest("@if { @{} }", - new StatementBlock( - Factory.CodeTransition(), - Factory.Code("if { ") - .AsStatement() - .Accepts(AcceptedCharactersInternal.Any), - new StatementBlock( - Factory.CodeTransition(), - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.EmptyCSharp() - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - Factory.Code(" }") - .AsStatement() - .Accepts(AcceptedCharactersInternal.Any)), - RazorDiagnosticFactory.CreateParsing_UnexpectedNestedCodeBlock( - new SourceSpan(new SourceLocation(7, 0, 7), contentLength: 1))); + ParseBlockTest("@if { @{} }"); } [Fact] public void ParseBlockCapturesWhitespaceToEndOfLineInInvalidUsingStatementAndTreatsAsFileCode() { ParseBlockTest("using " + Environment.NewLine - + Environment.NewLine, - new StatementBlock( - Factory.Code("using " + Environment.NewLine).AsStatement() - )); + + Environment.NewLine); } [Fact] public void ParseBlockMethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace() { - ParseBlockTest("{", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.EmptyCSharp() - .AsStatement() - .With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" }) - ), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), Resources.BlockName_Code, "}", "{")); + ParseBlockTest("{"); } [Fact] public void ParseBlockMethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty() { - ParseBlockTest("{}", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.EmptyCSharp() - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("{}"); } [Fact] public void ParseBlockMethodProducesErrorIfNewlineFollowsTransition() { - ParseBlockTest("@" + Environment.NewLine, - new ExpressionBlock( - Factory.CodeTransition(), - Factory.EmptyCSharp() - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( - new SourceSpan(new SourceLocation(1, 0, 1), Environment.NewLine.Length))); + ParseBlockTest("@" + Environment.NewLine); } [Fact] @@ -115,72 +62,27 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { ParseBlockTest("{" + Environment.NewLine + " @ {}" + Environment.NewLine - + "}", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(Environment.NewLine + " ") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.EmptyCSharp() - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - Factory.Code(" {}" + Environment.NewLine).AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) - ), - RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( - new SourceSpan(new SourceLocation(6 + Environment.NewLine.Length, 1, 5), contentLength: 3))); + + "}"); } [Fact] public void ParseBlockMethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression() { ParseBlockTest("{" + Environment.NewLine - + " @", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(Environment.NewLine + " ") - .AsStatement() - .AutoCompleteWith("}"), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.EmptyCSharp() - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - Factory.EmptyCSharp().AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_UnexpectedEndOfFileAtStartOfCodeBlock( - new SourceSpan(new SourceLocation(6 + Environment.NewLine.Length, 1, 5), contentLength: 1)), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), Resources.BlockName_Code, "}", "{")); + + " @"); } [Fact] public void ParseBlockMethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace() { - ParseBlockTest("@!!!", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.EmptyCSharp() - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), - "!")); + ParseBlockTest("@!!!"); } [Fact] public void ParseBlockShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExpressionUnclosed() { ParseBlockTest("(foo bar" + Environment.NewLine - + "baz", - new ExpressionBlock( - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code($"foo bar{Environment.NewLine}baz").AsExpression() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), Resources.BlockName_ExplicitExpression, ")", "(")); + + "baz"); } [Fact] @@ -189,26 +91,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy ParseBlockTest("(foo bar" + Environment.NewLine + "" + Environment.NewLine + "baz" + Environment.NewLine - + "@Html.Foo(Bar);" + Environment.NewLine, - new ExpressionBlock( - Factory.Code("Href(" + Environment.NewLine) - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - ), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 1), "(", ")")); + + "

@Html.Foo(Bar);

" + Environment.NewLine); } [Fact] @@ -217,13 +107,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { ParseBlockTest("Foo(Bar(Baz)" + Environment.NewLine + "Biz" + Environment.NewLine - + "Boz", - new ExpressionBlock( - Factory.Code($"Foo(Bar(Baz){Environment.NewLine}Biz{Environment.NewLine}Boz") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - ), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(3, 0, 3), contentLength: 1), "(", ")")); + + "Boz"); } [Fact] @@ -234,13 +118,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy + "Biz" + Environment.NewLine + "" + Environment.NewLine + "Boz" + Environment.NewLine - + "", - new ExpressionBlock( - Factory.Code($"Foo(Bar(Baz){Environment.NewLine}Biz{Environment.NewLine}") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - ), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(3, 0, 3), contentLength: 1), "(", ")")); + + ""); } [Fact] @@ -249,13 +127,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { ParseBlockTest("Foo[Bar[Baz]" + Environment.NewLine + "Biz" + Environment.NewLine - + "Boz", - new ExpressionBlock( - Factory.Code($"Foo[Bar[Baz]{Environment.NewLine}Biz{Environment.NewLine}Boz") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - ), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(3, 0, 3), contentLength: 1), "[", "]")); + + "Boz"); } [Fact] @@ -266,47 +138,22 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy + "Biz" + Environment.NewLine + "" + Environment.NewLine + "Boz" + Environment.NewLine - + "", - new ExpressionBlock( - Factory.Code($"Foo[Bar[Baz]{Environment.NewLine}Biz{Environment.NewLine}") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - ), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(3, 0, 3), contentLength: 1), "[", "]")); + + ""); } // Simple EOF handling errors: [Fact] public void ParseBlockReportsErrorIfExplicitCodeBlockUnterminatedAtEOF() { - ParseBlockTest("{ var foo = bar; if(foo != null) { bar(); } ", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code(" var foo = bar; if(foo != null) { bar(); } ") - .AsStatement() - .AutoCompleteWith("}")), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), Resources.BlockName_Code, "}", "{")); + ParseBlockTest("{ var foo = bar; if(foo != null) { bar(); } "); } [Fact] public void ParseBlockReportsErrorIfClassBlockUnterminatedAtEOF() { - // Arrange - var chunkGenerator = new DirectiveChunkGenerator(FunctionsDirective.Directive); - chunkGenerator.Diagnostics.Add( - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1), "functions", "}", "{")); - - // Act & Assert ParseBlockTest( "functions { var foo = bar; if(foo != null) { bar(); } ", - new[] { FunctionsDirective.Directive }, - new DirectiveBlock(chunkGenerator, - Factory.MetaCode("functions").Accepts(AcceptedCharactersInternal.None), - Factory.Span(SpanKindInternal.Markup, " ", CSharpSymbolType.WhiteSpace).Accepts(AcceptedCharactersInternal.AllWhiteSpace), - Factory.MetaCode("{").AutoCompleteWith("}", atEndOfSpan: true).Accepts(AcceptedCharactersInternal.None), - Factory.Code(" var foo = bar; if(foo != null) { bar(); } ").AsCodeBlock())); + new[] { FunctionsDirective.Directive }); } [Fact] @@ -318,67 +165,37 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy [Fact] public void ParseBlockReportsErrorIfElseBlockUnterminatedAtEOF() { - ParseBlockTest("if(foo) { baz(); } else { var foo = bar; if(foo != null) { bar(); } ", - new StatementBlock( - Factory.Code("if(foo) { baz(); } else { var foo = bar; if(foo != null) { bar(); } ").AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(19, 0, 19), contentLength: 1), "else", "}", "{")); + ParseBlockTest("if(foo) { baz(); } else { var foo = bar; if(foo != null) { bar(); } "); } [Fact] public void ParseBlockReportsErrorIfElseIfBlockUnterminatedAtEOF() { - ParseBlockTest("if(foo) { baz(); } else if { var foo = bar; if(foo != null) { bar(); } ", - new StatementBlock( - Factory.Code("if(foo) { baz(); } else if { var foo = bar; if(foo != null) { bar(); } ").AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(19, 0, 19), contentLength: 1), "else if", "}", "{")); + ParseBlockTest("if(foo) { baz(); } else if { var foo = bar; if(foo != null) { bar(); } "); } [Fact] public void ParseBlockReportsErrorIfDoBlockUnterminatedAtEOF() { - ParseBlockTest("do { var foo = bar; if(foo != null) { bar(); } ", - new StatementBlock( - Factory.Code("do { var foo = bar; if(foo != null) { bar(); } ").AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), "do", "}", "{")); + ParseBlockTest("do { var foo = bar; if(foo != null) { bar(); } "); } [Fact] public void ParseBlockReportsErrorIfTryBlockUnterminatedAtEOF() { - ParseBlockTest("try { var foo = bar; if(foo != null) { bar(); } ", - new StatementBlock( - Factory.Code("try { var foo = bar; if(foo != null) { bar(); } ").AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), "try", "}", "{")); + ParseBlockTest("try { var foo = bar; if(foo != null) { bar(); } "); } [Fact] public void ParseBlockReportsErrorIfCatchBlockUnterminatedAtEOF() { - ParseBlockTest("try { baz(); } catch(Foo) { var foo = bar; if(foo != null) { bar(); } ", - new StatementBlock( - Factory.Code("try { baz(); } catch(Foo) { var foo = bar; if(foo != null) { bar(); } ").AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 1), "catch", "}", "{")); + ParseBlockTest("try { baz(); } catch(Foo) { var foo = bar; if(foo != null) { bar(); } "); } [Fact] public void ParseBlockReportsErrorIfFinallyBlockUnterminatedAtEOF() { - ParseBlockTest("try { baz(); } finally { var foo = bar; if(foo != null) { bar(); } ", - new StatementBlock( - Factory.Code("try { baz(); } finally { var foo = bar; if(foo != null) { bar(); } ").AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 1), "finally", "}", "{")); + ParseBlockTest("try { baz(); } finally { var foo = bar; if(foo != null) { bar(); } "); } [Fact] @@ -420,131 +237,54 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy [Fact] public void ParseBlockRequiresControlFlowStatementsToHaveBraces() { - var expectedMessage = Resources.FormatParseError_SingleLine_ControlFlowStatements_Not_Allowed("{", "<"); - ParseBlockTest("if(foo)

Bar

else if(bar)

Baz

else

Boz

", - new StatementBlock( - Factory.Code("if(foo) ").AsStatement(), - new MarkupBlock( - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup("Bar"), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), - Factory.Code("else if(bar) ").AsStatement(), - new MarkupBlock( - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup("Baz"), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), - Factory.Code("else ").AsStatement(), - new MarkupBlock( - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup("Boz"), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None)), - Factory.EmptyCSharp().AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( - new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 1), "{", "<"), - RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( - new SourceSpan(new SourceLocation(32, 0, 32), contentLength: 1), "{", "<"), - RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( - new SourceSpan(new SourceLocation(48, 0, 48), contentLength: 1), "{", "<")); + ParseBlockTest("if(foo)

Bar

else if(bar)

Baz

else

Boz

"); } [Fact] public void ParseBlockIncludesUnexpectedCharacterInSingleStatementControlFlowStatementError() { - ParseBlockTest("if(foo)) { var bar = foo; }", - new StatementBlock( - Factory.Code("if(foo)) { var bar = foo; }").AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( - new SourceSpan(new SourceLocation(7, 0, 7), contentLength: 1), "{", ")")); + ParseBlockTest("if(foo)) { var bar = foo; }"); } [Fact] public void ParseBlockOutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart() { - ParseBlockTest("if(foo) { @

Bar

}", - new StatementBlock( - Factory.Code("if(foo) {").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - Factory.MarkupTransition(), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup("Bar"), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), - Factory.Code("}").AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart( - new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1))); + ParseBlockTest("if(foo) { @

Bar

}"); } [Fact] public void ParseBlockTerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen() { ParseBlockTest("if(foo bar" + Environment.NewLine - + "baz", - new StatementBlock( - Factory.Code("if(foo bar" + Environment.NewLine).AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 1), "(", ")")); + + "baz"); } [Fact] public void ParseBlockTerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen() { ParseBlockTest("foreach(foo bar" + Environment.NewLine - + "baz", - new StatementBlock( - Factory.Code("foreach(foo bar" + Environment.NewLine).AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(7, 0, 7), contentLength: 1), "(", ")")); + + "baz"); } [Fact] public void ParseBlockTerminatesWhileClauseInDoStatementAtEOLWhenRecoveringFromMissingCloseParen() { ParseBlockTest("do { } while(foo bar" + Environment.NewLine - + "baz", - new StatementBlock( - Factory.Code("do { } while(foo bar" + Environment.NewLine).AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(12, 0, 12), contentLength: 1), "(", ")")); + + "baz"); } [Fact] public void ParseBlockTerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen() { ParseBlockTest("using(foo bar" + Environment.NewLine - + "baz", - new StatementBlock( - Factory.Code("using(foo bar" + Environment.NewLine).AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(5, 0, 5), contentLength: 1), "(", ")")); + + "baz"); } [Fact] public void ParseBlockResumesIfStatementAfterOpenParen() { ParseBlockTest("if(" + Environment.NewLine - + "else {

Foo

}", - new StatementBlock( - Factory.Code($"if({Environment.NewLine}else {{").AsStatement(), - new MarkupBlock( - Factory.Markup(" "), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup("Foo"), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), - Factory.Code("}").AsStatement().Accepts(AcceptedCharactersInternal.None) - ), - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 1), "(", ")")); + + "else {

Foo

}"); } [Fact] @@ -553,20 +293,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy SingleSpanBlockTest("if(foo) {" + Environment.NewLine + " var p = \"foo bar baz" + Environment.NewLine + ";" + Environment.NewLine - + "}", - BlockKindInternal.Statement, SpanKindInternal.Code, - RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( - new SourceSpan(new SourceLocation(21 + Environment.NewLine.Length, 1, 12), contentLength: 1))); + + "}"); } [Fact] public void ParseBlockTerminatesNormalStringAtEndOfFile() { - SingleSpanBlockTest("if(foo) { var foo = \"blah blah blah blah blah", BlockKindInternal.Statement, SpanKindInternal.Code, - RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( - new SourceSpan(new SourceLocation(20, 0, 20), contentLength: 1)), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), "if", "}", "{")); + SingleSpanBlockTest("if(foo) { var foo = \"blah blah blah blah blah"); } [Fact] @@ -576,12 +309,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy + "blah; " + Environment.NewLine + "

Foo

" + Environment.NewLine + "blah " + Environment.NewLine - + "blah", - BlockKindInternal.Statement, SpanKindInternal.Code, - RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( - new SourceSpan(new SourceLocation(20, 0, 20), contentLength: 1)), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), "if", "}", "{")); + + "blah"); } [Fact] @@ -590,65 +318,25 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy ParseBlockTest("if(foo) {" + Environment.NewLine + " var foo = \"foo bar baz" + Environment.NewLine + "

Foo is @foo

" + Environment.NewLine - + "}", - new StatementBlock( - Factory.Code($"if(foo) {{{Environment.NewLine} var foo = \"foo bar baz{Environment.NewLine} ").AsStatement(), - new MarkupBlock( - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup("Foo is "), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("foo") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None), - Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None)), - Factory.Code("}").AsStatement() - ), - RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( - new SourceSpan(new SourceLocation(23 + Environment.NewLine.Length, 1, 14), contentLength: 1))); + + "}"); } [Fact] public void ParseBlockCorrectlyParsesAtSignInDelimitedBlock() { - ParseBlockTest("(Request[\"description\"] ?? @photo.Description)", - new ExpressionBlock( - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code("Request[\"description\"] ?? @photo.Description").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("(Request[\"description\"] ?? @photo.Description)"); } [Fact] public void ParseBlockCorrectlyRecoversFromMissingCloseParenInExpressionWithinCode() { - ParseBlockTest(@"{string.Format(}", - new StatementBlock( - Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), - Factory.Code("string.Format(") - .AsStatement() - .AutoCompleteWith(autoCompleteString: null), - new MarkupBlock( - BlockFactory.MarkupTagBlock("", AcceptedCharactersInternal.None), - BlockFactory.MarkupTagBlock("", AcceptedCharactersInternal.None)), - Factory.EmptyCSharp().AsStatement(), - Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), - expectedErrors: new[] - { - RazorDiagnosticFactory.CreateParsing_ExpectedCloseBracketBeforeEOF( - new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 1), "(", ")"), - }); + ParseBlockTest(@"{string.Format(}"); } private void RunUnterminatedSimpleKeywordBlock(string keyword) { SingleSpanBlockTest( - keyword + " (foo) { var foo = bar; if(foo != null) { bar(); } ", - BlockKindInternal.Statement, - SpanKindInternal.Code, - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(SourceLocation.Zero, contentLength: 1), keyword, "}", "{")); + keyword + " (foo) { var foo = bar; if(foo != null) { bar(); } "); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCapturesWhitespaceToEndOfLineInInvalidUsingStatementAndTreatsAsFileCode.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCapturesWhitespaceToEndOfLineInInvalidUsingStatementAndTreatsAsFileCode.syntaxtree.txt new file mode 100644 index 0000000000..10662a6c39 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCapturesWhitespaceToEndOfLineInInvalidUsingStatementAndTreatsAsFileCode.syntaxtree.txt @@ -0,0 +1,5 @@ +Statement block - Gen - 17 - (0:0,0) + Code span - Gen - [using LF] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:3 + CSharpSymbolType.Keyword;[using]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.NewLine;[LF]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.diagnostics.txt new file mode 100644 index 0000000000..ade6c85b25 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.diagnostics.txt @@ -0,0 +1 @@ +(1,5): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.syntaxtree.txt new file mode 100644 index 0000000000..30ca1ad20c --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed.syntaxtree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 7 - (0:0,0) + Code span - Gen - [Href(LF] - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 - (0:0,0) - Symbols:3 + CSharpSymbolType.Identifier;[Href]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.NewLine;[LF]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyParsesAtSignInDelimitedBlock.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyParsesAtSignInDelimitedBlock.syntaxtree.txt new file mode 100644 index 0000000000..59439ca8e0 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyParsesAtSignInDelimitedBlock.syntaxtree.txt @@ -0,0 +1,17 @@ +Expression block - Gen - 46 - (0:0,0) + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.LeftParenthesis;[(]; + Code span - Gen - [Request["description"] ?? @photo.Description] - SpanEditHandler;Accepts:Any - (1:0,1) - Symbols:11 + CSharpSymbolType.Identifier;[Request]; + CSharpSymbolType.LeftBracket;[[]; + CSharpSymbolType.StringLiteral;["description"]; + CSharpSymbolType.RightBracket;[]]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.NullCoalesce;[??]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Transition;[@]; + CSharpSymbolType.Identifier;[photo]; + CSharpSymbolType.Dot;[.]; + CSharpSymbolType.Identifier;[Description]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (45:0,45) - Symbols:1 + CSharpSymbolType.RightParenthesis;[)]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.diagnostics.txt new file mode 100644 index 0000000000..749c29cf56 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.diagnostics.txt @@ -0,0 +1 @@ +(2,15): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.syntaxtree.txt new file mode 100644 index 0000000000..57cdc77371 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement.syntaxtree.txt @@ -0,0 +1,45 @@ +Statement block - Gen - 64 - (0:0,0) + Code span - Gen - [if(foo) {LF var foo = "foo bar bazLF ] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:17 + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.NewLine;[LF]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[var]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Assign;[=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.StringLiteral;["foo bar baz];RZ1000(25:1,14 [1] ) + CSharpSymbolType.NewLine;[LF]; + CSharpSymbolType.WhiteSpace;[ ]; + Markup block - Gen - 20 - (43:2,4) + Tag block - Gen - 3 - (43:2,4) + Markup span - Gen - [

] - SpanEditHandler;Accepts:None - (43:2,4) - Symbols:3 + HtmlSymbolType.OpenAngle;[<]; + HtmlSymbolType.Text;[p]; + HtmlSymbolType.CloseAngle;[>]; + Markup span - Gen - [Foo is ] - SpanEditHandler;Accepts:Any - (46:2,7) - Symbols:4 + HtmlSymbolType.Text;[Foo]; + HtmlSymbolType.WhiteSpace;[ ]; + HtmlSymbolType.Text;[is]; + HtmlSymbolType.WhiteSpace;[ ]; + Expression block - Gen - 4 - (53:2,14) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (53:2,14) - Symbols:1 + CSharpSymbolType.Transition;[@]; + Code span - Gen - [foo] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (54:2,15) - Symbols:1 + CSharpSymbolType.Identifier;[foo]; + Tag block - Gen - 4 - (57:2,18) + Markup span - Gen - [

] - SpanEditHandler;Accepts:None - (57:2,18) - Symbols:4 + HtmlSymbolType.OpenAngle;[<]; + HtmlSymbolType.ForwardSlash;[/]; + HtmlSymbolType.Text;[p]; + HtmlSymbolType.CloseAngle;[>]; + Markup span - Gen - [LF] - SpanEditHandler;Accepts:None - (61:2,22) - Symbols:1 + HtmlSymbolType.NewLine;[LF]; + Code span - Gen - [}] - SpanEditHandler;Accepts:Any - (63:3,0) - Symbols:1 + CSharpSymbolType.RightBrace;[}]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.diagnostics.txt new file mode 100644 index 0000000000..994acd46f2 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.diagnostics.txt @@ -0,0 +1 @@ +(1,15): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.syntaxtree.txt new file mode 100644 index 0000000000..6cf94e97da --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockCorrectlyRecoversFromMissingCloseParenInExpressionWithinCode.syntaxtree.txt @@ -0,0 +1,24 @@ +Statement block - Gen - 29 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.LeftBrace;[{]; + Code span - Gen - [string.Format(] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL - (1:0,1) - Symbols:4 + CSharpSymbolType.Keyword;[string]; + CSharpSymbolType.Dot;[.]; + CSharpSymbolType.Identifier;[Format]; + CSharpSymbolType.LeftParenthesis;[(]; + Markup block - Gen - 13 - (15:0,15) + Tag block - Gen - 6 - (15:0,15) + Markup span - Gen - [] - SpanEditHandler;Accepts:None - (15:0,15) - Symbols:3 + HtmlSymbolType.OpenAngle;[<]; + HtmlSymbolType.Text;[html]; + HtmlSymbolType.CloseAngle;[>]; + Tag block - Gen - 7 - (21:0,21) + Markup span - Gen - [] - SpanEditHandler;Accepts:None - (21:0,21) - Symbols:4 + HtmlSymbolType.OpenAngle;[<]; + HtmlSymbolType.ForwardSlash;[/]; + HtmlSymbolType.Text;[html]; + HtmlSymbolType.CloseAngle;[>]; + Code span - Gen - [] - SpanEditHandler;Accepts:Any - (28:0,28) - Symbols:1 + CSharpSymbolType.Unknown;[]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (28:0,28) - Symbols:1 + CSharpSymbolType.RightBrace;[}]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockHandlesQuotesAfterTransition.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockHandlesQuotesAfterTransition.diagnostics.txt new file mode 100644 index 0000000000..0179da5b14 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockHandlesQuotesAfterTransition.diagnostics.txt @@ -0,0 +1 @@ +(1,2): Error RZ1005: """ is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockHandlesQuotesAfterTransition.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockHandlesQuotesAfterTransition.syntaxtree.txt new file mode 100644 index 0000000000..2ce6cbbd8a --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockHandlesQuotesAfterTransition.syntaxtree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 1 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.Transition;[@]; + Code span - Gen - [] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Symbols:1 + CSharpSymbolType.Unknown;[]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockIncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockIncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.diagnostics.txt new file mode 100644 index 0000000000..07f83443c3 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockIncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.diagnostics.txt @@ -0,0 +1,10 @@ +(1,8): Error RZ1008: Expected a "{" but found a ")". Block statements must be enclosed in "{" and "}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed: + +@if(isLoggedIn) +

Hello, @user

+ +Instead, wrap the contents of the block in "{}": + +@if(isLoggedIn) { +

Hello, @user

+} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockIncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockIncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.syntaxtree.txt new file mode 100644 index 0000000000..4f38bbc80d --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockIncludesUnexpectedCharacterInSingleStatementControlFlowStatementError.syntaxtree.txt @@ -0,0 +1,20 @@ +Statement block - Gen - 27 - (0:0,0) + Code span - Gen - [if(foo)) { var bar = foo; }] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:18 + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[var]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Assign;[=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.diagnostics.txt new file mode 100644 index 0000000000..3b54961cc8 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.diagnostics.txt @@ -0,0 +1 @@ +(1,1): 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.syntaxtree.txt new file mode 100644 index 0000000000..54058d35f2 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace.syntaxtree.txt @@ -0,0 +1,5 @@ +Statement block - Gen - 1 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.LeftBrace;[{]; + Code span - Gen - [] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[}];AtEOL - (1:0,1) - Symbols:1 + CSharpSymbolType.Unknown;[]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty.syntaxtree.txt new file mode 100644 index 0000000000..82873f5134 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty.syntaxtree.txt @@ -0,0 +1,7 @@ +Statement block - Gen - 2 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.LeftBrace;[{]; + Code span - Gen - [] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL - (1:0,1) - Symbols:1 + CSharpSymbolType.Unknown;[]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (1:0,1) - Symbols:1 + CSharpSymbolType.RightBrace;[}]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.diagnostics.txt new file mode 100644 index 0000000000..84fe5838bb --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.diagnostics.txt @@ -0,0 +1 @@ +(1,2): Error RZ1005: "!" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.syntaxtree.txt new file mode 100644 index 0000000000..2ce6cbbd8a --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace.syntaxtree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 1 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.Transition;[@]; + Code span - Gen - [] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Symbols:1 + CSharpSymbolType.Unknown;[]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.diagnostics.txt new file mode 100644 index 0000000000..cd939667f4 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.diagnostics.txt @@ -0,0 +1,2 @@ +(2,6): Error RZ1004: End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" +(1,1): 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.syntaxtree.txt new file mode 100644 index 0000000000..3df5c02a08 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression.syntaxtree.txt @@ -0,0 +1,13 @@ +Statement block - Gen - 8 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.LeftBrace;[{]; + Code span - Gen - [LF ] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[}];AtEOL - (1:0,1) - Symbols:2 + CSharpSymbolType.NewLine;[LF]; + CSharpSymbolType.WhiteSpace;[ ]; + Expression block - Gen - 1 - (7:1,4) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (7:1,4) - Symbols:1 + CSharpSymbolType.Transition;[@]; + Code span - Gen - [] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[ATD];K14 - (8:1,5) - Symbols:1 + CSharpSymbolType.Unknown;[]; + Code span - Gen - [] - SpanEditHandler;Accepts:Any - (8:1,5) - Symbols:1 + CSharpSymbolType.Unknown;[]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodProducesErrorIfNewlineFollowsTransition.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodProducesErrorIfNewlineFollowsTransition.diagnostics.txt new file mode 100644 index 0000000000..1a4e7725a4 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodProducesErrorIfNewlineFollowsTransition.diagnostics.txt @@ -0,0 +1 @@ +(1,2): Error RZ1003: A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodProducesErrorIfNewlineFollowsTransition.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodProducesErrorIfNewlineFollowsTransition.syntaxtree.txt new file mode 100644 index 0000000000..2ce6cbbd8a --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodProducesErrorIfNewlineFollowsTransition.syntaxtree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 1 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.Transition;[@]; + Code span - Gen - [] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Symbols:1 + CSharpSymbolType.Unknown;[]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpression.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpression.diagnostics.txt new file mode 100644 index 0000000000..a8f6dc0930 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpression.diagnostics.txt @@ -0,0 +1 @@ +(2,6): Error RZ1003: A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpression.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpression.syntaxtree.txt new file mode 100644 index 0000000000..cfb3d1f280 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockMethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpression.syntaxtree.txt @@ -0,0 +1,18 @@ +Statement block - Gen - 16 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.LeftBrace;[{]; + Code span - Gen - [LF ] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL - (1:0,1) - Symbols:2 + CSharpSymbolType.NewLine;[LF]; + CSharpSymbolType.WhiteSpace;[ ]; + Expression block - Gen - 1 - (7:1,4) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (7:1,4) - Symbols:1 + CSharpSymbolType.Transition;[@]; + Code span - Gen - [] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[ATD];K14 - (8:1,5) - Symbols:1 + CSharpSymbolType.Unknown;[]; + Code span - Gen - [ {}LF] - SpanEditHandler;Accepts:Any - (8:1,5) - Symbols:4 + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.NewLine;[LF]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (15:2,0) - Symbols:1 + CSharpSymbolType.RightBrace;[}]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockOutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockOutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.diagnostics.txt new file mode 100644 index 0000000000..81a565a43a --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockOutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.diagnostics.txt @@ -0,0 +1,5 @@ +(1,11): Error RZ1009: The "@" character must be followed by a ":", "(", or a C# identifier. If you intended to switch to markup, use an HTML start tag, for example: + +@if(isLoggedIn) { +

Hello, @user!

+} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockOutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockOutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.syntaxtree.txt new file mode 100644 index 0000000000..3fba28dea0 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockOutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart.syntaxtree.txt @@ -0,0 +1,30 @@ +Statement block - Gen - 23 - (0:0,0) + Code span - Gen - [if(foo) {] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:6 + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + Markup block - Gen - 13 - (9:0,9) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (9:0,9) - Symbols:1 + HtmlSymbolType.WhiteSpace;[ ]; + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (10:0,10) - Symbols:1 + HtmlSymbolType.Transition;[@]; + Tag block - Gen - 3 - (11:0,11) + Markup span - Gen - [

] - SpanEditHandler;Accepts:None - (11:0,11) - Symbols:3 + HtmlSymbolType.OpenAngle;[<]; + HtmlSymbolType.Text;[p]; + HtmlSymbolType.CloseAngle;[>]; + Markup span - Gen - [Bar] - SpanEditHandler;Accepts:Any - (14:0,14) - Symbols:1 + HtmlSymbolType.Text;[Bar]; + Tag block - Gen - 4 - (17:0,17) + Markup span - Gen - [

] - SpanEditHandler;Accepts:None - (17:0,17) - Symbols:4 + HtmlSymbolType.OpenAngle;[<]; + HtmlSymbolType.ForwardSlash;[/]; + HtmlSymbolType.Text;[p]; + HtmlSymbolType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (21:0,21) - Symbols:1 + HtmlSymbolType.WhiteSpace;[ ]; + Code span - Gen - [}] - SpanEditHandler;Accepts:Any - (22:0,22) - Symbols:1 + CSharpSymbolType.RightBrace;[}]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfCatchBlockUnterminatedAtEOF.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfCatchBlockUnterminatedAtEOF.diagnostics.txt new file mode 100644 index 0000000000..b9e68acd22 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfCatchBlockUnterminatedAtEOF.diagnostics.txt @@ -0,0 +1 @@ +(1,16): Error RZ1006: The catch 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfCatchBlockUnterminatedAtEOF.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfCatchBlockUnterminatedAtEOF.syntaxtree.txt new file mode 100644 index 0000000000..2d052b7c72 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfCatchBlockUnterminatedAtEOF.syntaxtree.txt @@ -0,0 +1,47 @@ +Statement block - Gen - 70 - (0:0,0) + Code span - Gen - [try { baz(); } catch(Foo) { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:45 + CSharpSymbolType.Keyword;[try]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[baz]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[catch]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[Foo]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[var]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Assign;[=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.NotEqual;[!=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[null]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.WhiteSpace;[ ]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfClassBlockUnterminatedAtEOF.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfClassBlockUnterminatedAtEOF.syntaxtree.txt new file mode 100644 index 0000000000..1775df09db --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfClassBlockUnterminatedAtEOF.syntaxtree.txt @@ -0,0 +1,36 @@ +Directive block - Gen - 54 - (0:0,0) + MetaCode span - Gen - [functions] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.Identifier;[functions]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:AllWhiteSpace - (9:0,9) - Symbols:1 + CSharpSymbolType.WhiteSpace;[ ]; + MetaCode span - Gen - [{] - AutoCompleteEditHandler;Accepts:None,AutoComplete:[}];AtEnd - (10:0,10) - Symbols:1 + CSharpSymbolType.LeftBrace;[{]; + Code span - Gen - [ var foo = bar; if(foo != null) { bar(); } ] - CodeBlockEditHandler;Accepts:Any;CodeBlock - (11:0,11) - Symbols:28 + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[var]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Assign;[=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.NotEqual;[!=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[null]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.WhiteSpace;[ ]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfDoBlockUnterminatedAtEOF.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfDoBlockUnterminatedAtEOF.diagnostics.txt new file mode 100644 index 0000000000..848ff180d7 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfDoBlockUnterminatedAtEOF.diagnostics.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The do 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfDoBlockUnterminatedAtEOF.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfDoBlockUnterminatedAtEOF.syntaxtree.txt new file mode 100644 index 0000000000..535f2e7bce --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfDoBlockUnterminatedAtEOF.syntaxtree.txt @@ -0,0 +1,33 @@ +Statement block - Gen - 47 - (0:0,0) + Code span - Gen - [do { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:31 + CSharpSymbolType.Keyword;[do]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[var]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Assign;[=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.NotEqual;[!=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[null]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.WhiteSpace;[ ]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfElseBlockUnterminatedAtEOF.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfElseBlockUnterminatedAtEOF.diagnostics.txt new file mode 100644 index 0000000000..00f5c555f9 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfElseBlockUnterminatedAtEOF.diagnostics.txt @@ -0,0 +1 @@ +(1,20): Error RZ1006: The else 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfElseBlockUnterminatedAtEOF.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfElseBlockUnterminatedAtEOF.syntaxtree.txt new file mode 100644 index 0000000000..b796d0fb50 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfElseBlockUnterminatedAtEOF.syntaxtree.txt @@ -0,0 +1,47 @@ +Statement block - Gen - 68 - (0:0,0) + Code span - Gen - [if(foo) { baz(); } else { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:45 + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[baz]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[else]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[var]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Assign;[=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.NotEqual;[!=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[null]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.WhiteSpace;[ ]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfElseIfBlockUnterminatedAtEOF.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfElseIfBlockUnterminatedAtEOF.diagnostics.txt new file mode 100644 index 0000000000..aa78495b19 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfElseIfBlockUnterminatedAtEOF.diagnostics.txt @@ -0,0 +1 @@ +(1,20): Error RZ1006: The else if 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfElseIfBlockUnterminatedAtEOF.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfElseIfBlockUnterminatedAtEOF.syntaxtree.txt new file mode 100644 index 0000000000..bb4b7b903c --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfElseIfBlockUnterminatedAtEOF.syntaxtree.txt @@ -0,0 +1,49 @@ +Statement block - Gen - 71 - (0:0,0) + Code span - Gen - [if(foo) { baz(); } else if { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:47 + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[baz]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[else]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[var]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Assign;[=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.NotEqual;[!=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[null]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.WhiteSpace;[ ]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.diagnostics.txt new file mode 100644 index 0000000000..3b54961cc8 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.diagnostics.txt @@ -0,0 +1 @@ +(1,1): 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.syntaxtree.txt new file mode 100644 index 0000000000..de2649a46f --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfExplicitCodeBlockUnterminatedAtEOF.syntaxtree.txt @@ -0,0 +1,32 @@ +Statement block - Gen - 44 - (0:0,0) + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.LeftBrace;[{]; + Code span - Gen - [ var foo = bar; if(foo != null) { bar(); } ] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[}];AtEOL - (1:0,1) - Symbols:28 + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[var]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Assign;[=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.NotEqual;[!=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[null]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.WhiteSpace;[ ]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfFinallyBlockUnterminatedAtEOF.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfFinallyBlockUnterminatedAtEOF.diagnostics.txt new file mode 100644 index 0000000000..8abedf47a1 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfFinallyBlockUnterminatedAtEOF.diagnostics.txt @@ -0,0 +1 @@ +(1,16): Error RZ1006: The finally 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfFinallyBlockUnterminatedAtEOF.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfFinallyBlockUnterminatedAtEOF.syntaxtree.txt new file mode 100644 index 0000000000..b108e413d1 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfFinallyBlockUnterminatedAtEOF.syntaxtree.txt @@ -0,0 +1,44 @@ +Statement block - Gen - 67 - (0:0,0) + Code span - Gen - [try { baz(); } finally { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:42 + CSharpSymbolType.Keyword;[try]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[baz]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[finally]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[var]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Assign;[=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.NotEqual;[!=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[null]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.WhiteSpace;[ ]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfForBlockUnterminatedAtEOF.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfForBlockUnterminatedAtEOF.diagnostics.txt new file mode 100644 index 0000000000..01cc5cb7b6 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfForBlockUnterminatedAtEOF.diagnostics.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The for 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfForBlockUnterminatedAtEOF.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfForBlockUnterminatedAtEOF.syntaxtree.txt new file mode 100644 index 0000000000..8ca6c0ffe6 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfForBlockUnterminatedAtEOF.syntaxtree.txt @@ -0,0 +1,37 @@ +Statement block - Gen - 54 - (0:0,0) + Code span - Gen - [for (foo) { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:35 + CSharpSymbolType.Keyword;[for]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[var]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Assign;[=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.NotEqual;[!=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[null]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.WhiteSpace;[ ]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfForeachBlockUnterminatedAtEOF.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfForeachBlockUnterminatedAtEOF.diagnostics.txt new file mode 100644 index 0000000000..ad3a00985c --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfForeachBlockUnterminatedAtEOF.diagnostics.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The foreach 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfForeachBlockUnterminatedAtEOF.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfForeachBlockUnterminatedAtEOF.syntaxtree.txt new file mode 100644 index 0000000000..38dde74508 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfForeachBlockUnterminatedAtEOF.syntaxtree.txt @@ -0,0 +1,37 @@ +Statement block - Gen - 58 - (0:0,0) + Code span - Gen - [foreach (foo) { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:35 + CSharpSymbolType.Keyword;[foreach]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[var]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Assign;[=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.NotEqual;[!=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[null]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.WhiteSpace;[ ]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfIfBlockUnterminatedAtEOF.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfIfBlockUnterminatedAtEOF.diagnostics.txt new file mode 100644 index 0000000000..8f817baa43 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfIfBlockUnterminatedAtEOF.diagnostics.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The if 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfIfBlockUnterminatedAtEOF.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfIfBlockUnterminatedAtEOF.syntaxtree.txt new file mode 100644 index 0000000000..8eea268e01 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfIfBlockUnterminatedAtEOF.syntaxtree.txt @@ -0,0 +1,37 @@ +Statement block - Gen - 53 - (0:0,0) + Code span - Gen - [if (foo) { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:35 + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[var]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Assign;[=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.NotEqual;[!=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[null]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.WhiteSpace;[ ]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfLockBlockUnterminatedAtEOF.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfLockBlockUnterminatedAtEOF.diagnostics.txt new file mode 100644 index 0000000000..f5a5f37b3d --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfLockBlockUnterminatedAtEOF.diagnostics.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The lock 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfLockBlockUnterminatedAtEOF.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfLockBlockUnterminatedAtEOF.syntaxtree.txt new file mode 100644 index 0000000000..113317cdc9 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfLockBlockUnterminatedAtEOF.syntaxtree.txt @@ -0,0 +1,37 @@ +Statement block - Gen - 55 - (0:0,0) + Code span - Gen - [lock (foo) { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:35 + CSharpSymbolType.Keyword;[lock]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[var]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Assign;[=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.NotEqual;[!=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[null]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.WhiteSpace;[ ]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfSwitchBlockUnterminatedAtEOF.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfSwitchBlockUnterminatedAtEOF.diagnostics.txt new file mode 100644 index 0000000000..245372b7fc --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfSwitchBlockUnterminatedAtEOF.diagnostics.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The switch 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfSwitchBlockUnterminatedAtEOF.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfSwitchBlockUnterminatedAtEOF.syntaxtree.txt new file mode 100644 index 0000000000..97331217b1 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfSwitchBlockUnterminatedAtEOF.syntaxtree.txt @@ -0,0 +1,37 @@ +Statement block - Gen - 57 - (0:0,0) + Code span - Gen - [switch (foo) { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:35 + CSharpSymbolType.Keyword;[switch]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[var]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Assign;[=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.NotEqual;[!=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[null]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.WhiteSpace;[ ]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfTryBlockUnterminatedAtEOF.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfTryBlockUnterminatedAtEOF.diagnostics.txt new file mode 100644 index 0000000000..6bb5602c0c --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfTryBlockUnterminatedAtEOF.diagnostics.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The try 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfTryBlockUnterminatedAtEOF.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfTryBlockUnterminatedAtEOF.syntaxtree.txt new file mode 100644 index 0000000000..c3b097f187 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfTryBlockUnterminatedAtEOF.syntaxtree.txt @@ -0,0 +1,33 @@ +Statement block - Gen - 48 - (0:0,0) + Code span - Gen - [try { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:31 + CSharpSymbolType.Keyword;[try]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[var]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Assign;[=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.NotEqual;[!=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[null]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.WhiteSpace;[ ]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfUsingBlockUnterminatedAtEOF.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfUsingBlockUnterminatedAtEOF.diagnostics.txt new file mode 100644 index 0000000000..65d152b240 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfUsingBlockUnterminatedAtEOF.diagnostics.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The using 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfUsingBlockUnterminatedAtEOF.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfUsingBlockUnterminatedAtEOF.syntaxtree.txt new file mode 100644 index 0000000000..db82b450d0 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfUsingBlockUnterminatedAtEOF.syntaxtree.txt @@ -0,0 +1,37 @@ +Statement block - Gen - 56 - (0:0,0) + Code span - Gen - [using (foo) { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:35 + CSharpSymbolType.Keyword;[using]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[var]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Assign;[=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.NotEqual;[!=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[null]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.WhiteSpace;[ ]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfWhileBlockUnterminatedAtEOF.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfWhileBlockUnterminatedAtEOF.diagnostics.txt new file mode 100644 index 0000000000..aa7f1b2bf2 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfWhileBlockUnterminatedAtEOF.diagnostics.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The while 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfWhileBlockUnterminatedAtEOF.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfWhileBlockUnterminatedAtEOF.syntaxtree.txt new file mode 100644 index 0000000000..a2bdbbb669 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockReportsErrorIfWhileBlockUnterminatedAtEOF.syntaxtree.txt @@ -0,0 +1,37 @@ +Statement block - Gen - 56 - (0:0,0) + Code span - Gen - [while (foo) { var foo = bar; if(foo != null) { bar(); } ] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:35 + CSharpSymbolType.Keyword;[while]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[var]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Assign;[=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.NotEqual;[!=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[null]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.WhiteSpace;[ ]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockRequiresControlFlowStatementsToHaveBraces.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockRequiresControlFlowStatementsToHaveBraces.diagnostics.txt new file mode 100644 index 0000000000..1c1f35257d --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockRequiresControlFlowStatementsToHaveBraces.diagnostics.txt @@ -0,0 +1,30 @@ +(1,9): Error RZ1008: Expected a "{" but found a "<". Block statements must be enclosed in "{" and "}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed: + +@if(isLoggedIn) +

Hello, @user

+ +Instead, wrap the contents of the block in "{}": + +@if(isLoggedIn) { +

Hello, @user

+} +(1,33): Error RZ1008: Expected a "{" but found a "<". Block statements must be enclosed in "{" and "}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed: + +@if(isLoggedIn) +

Hello, @user

+ +Instead, wrap the contents of the block in "{}": + +@if(isLoggedIn) { +

Hello, @user

+} +(1,49): Error RZ1008: Expected a "{" but found a "<". Block statements must be enclosed in "{" and "}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed: + +@if(isLoggedIn) +

Hello, @user

+ +Instead, wrap the contents of the block in "{}": + +@if(isLoggedIn) { +

Hello, @user

+} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockRequiresControlFlowStatementsToHaveBraces.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockRequiresControlFlowStatementsToHaveBraces.syntaxtree.txt new file mode 100644 index 0000000000..1f510343e6 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockRequiresControlFlowStatementsToHaveBraces.syntaxtree.txt @@ -0,0 +1,66 @@ +Statement block - Gen - 58 - (0:0,0) + Code span - Gen - [if(foo) ] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:5 + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + Markup block - Gen - 11 - (8:0,8) + Tag block - Gen - 3 - (8:0,8) + Markup span - Gen - [

] - SpanEditHandler;Accepts:None - (8:0,8) - Symbols:3 + HtmlSymbolType.OpenAngle;[<]; + HtmlSymbolType.Text;[p]; + HtmlSymbolType.CloseAngle;[>]; + Markup span - Gen - [Bar] - SpanEditHandler;Accepts:Any - (11:0,11) - Symbols:1 + HtmlSymbolType.Text;[Bar]; + Tag block - Gen - 4 - (14:0,14) + Markup span - Gen - [

] - SpanEditHandler;Accepts:None - (14:0,14) - Symbols:4 + HtmlSymbolType.OpenAngle;[<]; + HtmlSymbolType.ForwardSlash;[/]; + HtmlSymbolType.Text;[p]; + HtmlSymbolType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (18:0,18) - Symbols:1 + HtmlSymbolType.WhiteSpace;[ ]; + Code span - Gen - [else if(bar) ] - SpanEditHandler;Accepts:Any - (19:0,19) - Symbols:7 + CSharpSymbolType.Keyword;[else]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + Markup block - Gen - 11 - (32:0,32) + Tag block - Gen - 3 - (32:0,32) + Markup span - Gen - [

] - SpanEditHandler;Accepts:None - (32:0,32) - Symbols:3 + HtmlSymbolType.OpenAngle;[<]; + HtmlSymbolType.Text;[p]; + HtmlSymbolType.CloseAngle;[>]; + Markup span - Gen - [Baz] - SpanEditHandler;Accepts:Any - (35:0,35) - Symbols:1 + HtmlSymbolType.Text;[Baz]; + Tag block - Gen - 4 - (38:0,38) + Markup span - Gen - [

] - SpanEditHandler;Accepts:None - (38:0,38) - Symbols:4 + HtmlSymbolType.OpenAngle;[<]; + HtmlSymbolType.ForwardSlash;[/]; + HtmlSymbolType.Text;[p]; + HtmlSymbolType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (42:0,42) - Symbols:1 + HtmlSymbolType.WhiteSpace;[ ]; + Code span - Gen - [else ] - SpanEditHandler;Accepts:Any - (43:0,43) - Symbols:2 + CSharpSymbolType.Keyword;[else]; + CSharpSymbolType.WhiteSpace;[ ]; + Markup block - Gen - 10 - (48:0,48) + Tag block - Gen - 3 - (48:0,48) + Markup span - Gen - [

] - SpanEditHandler;Accepts:None - (48:0,48) - Symbols:3 + HtmlSymbolType.OpenAngle;[<]; + HtmlSymbolType.Text;[p]; + HtmlSymbolType.CloseAngle;[>]; + Markup span - Gen - [Boz] - SpanEditHandler;Accepts:Any - (51:0,51) - Symbols:1 + HtmlSymbolType.Text;[Boz]; + Tag block - Gen - 4 - (54:0,54) + Markup span - Gen - [

] - SpanEditHandler;Accepts:None - (54:0,54) - Symbols:4 + HtmlSymbolType.OpenAngle;[<]; + HtmlSymbolType.ForwardSlash;[/]; + HtmlSymbolType.Text;[p]; + HtmlSymbolType.CloseAngle;[>]; + Code span - Gen - [] - SpanEditHandler;Accepts:Any - (58:0,58) - Symbols:1 + CSharpSymbolType.Unknown;[]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockResumesIfStatementAfterOpenParen.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockResumesIfStatementAfterOpenParen.diagnostics.txt new file mode 100644 index 0000000000..409c3a530f --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockResumesIfStatementAfterOpenParen.diagnostics.txt @@ -0,0 +1 @@ +(1,3): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockResumesIfStatementAfterOpenParen.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockResumesIfStatementAfterOpenParen.syntaxtree.txt new file mode 100644 index 0000000000..e4f2a03e7c --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockResumesIfStatementAfterOpenParen.syntaxtree.txt @@ -0,0 +1,28 @@ +Statement block - Gen - 24 - (0:0,0) + Code span - Gen - [if(LFelse {] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:6 + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.NewLine;[LF]; + CSharpSymbolType.Keyword;[else]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + Markup block - Gen - 12 - (11:1,6) + Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (11:1,6) - Symbols:1 + HtmlSymbolType.WhiteSpace;[ ]; + Tag block - Gen - 3 - (12:1,7) + Markup span - Gen - [

] - SpanEditHandler;Accepts:None - (12:1,7) - Symbols:3 + HtmlSymbolType.OpenAngle;[<]; + HtmlSymbolType.Text;[p]; + HtmlSymbolType.CloseAngle;[>]; + Markup span - Gen - [Foo] - SpanEditHandler;Accepts:Any - (15:1,10) - Symbols:1 + HtmlSymbolType.Text;[Foo]; + Tag block - Gen - 4 - (18:1,13) + Markup span - Gen - [

] - SpanEditHandler;Accepts:None - (18:1,13) - Symbols:4 + HtmlSymbolType.OpenAngle;[<]; + HtmlSymbolType.ForwardSlash;[/]; + HtmlSymbolType.Text;[p]; + HtmlSymbolType.CloseAngle;[>]; + Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (22:1,17) - Symbols:1 + HtmlSymbolType.WhiteSpace;[ ]; + Code span - Gen - [}] - SpanEditHandler;Accepts:None - (23:1,18) - Symbols:1 + CSharpSymbolType.RightBrace;[}]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.diagnostics.txt new file mode 100644 index 0000000000..2355923768 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.diagnostics.txt @@ -0,0 +1 @@ +(1,4): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.syntaxtree.txt new file mode 100644 index 0000000000..508fa47432 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed.syntaxtree.txt @@ -0,0 +1,12 @@ +Expression block - Gen - 22 - (0:0,0) + Code span - Gen - [Foo[Bar[Baz]LFBizLFBoz] - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 - (0:0,0) - Symbols:10 + CSharpSymbolType.Identifier;[Foo]; + CSharpSymbolType.LeftBracket;[[]; + CSharpSymbolType.Identifier;[Bar]; + CSharpSymbolType.LeftBracket;[[]; + CSharpSymbolType.Identifier;[Baz]; + CSharpSymbolType.RightBracket;[]]; + CSharpSymbolType.NewLine;[LF]; + CSharpSymbolType.Identifier;[Biz]; + CSharpSymbolType.NewLine;[LF]; + CSharpSymbolType.Identifier;[Boz]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExpressionUnclosed.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExpressionUnclosed.diagnostics.txt new file mode 100644 index 0000000000..2996b166be --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExpressionUnclosed.diagnostics.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The explicit expression 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExpressionUnclosed.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExpressionUnclosed.syntaxtree.txt new file mode 100644 index 0000000000..2e966569e5 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExpressionUnclosed.syntaxtree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 13 - (0:0,0) + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.LeftParenthesis;[(]; + Code span - Gen - [foo barLFbaz] - SpanEditHandler;Accepts:Any - (1:0,1) - Symbols:5 + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.NewLine;[LF]; + CSharpSymbolType.Identifier;[baz]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtEOFIfParenInImplicitExpressionUnclosed.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtEOFIfParenInImplicitExpressionUnclosed.diagnostics.txt new file mode 100644 index 0000000000..a08a836e65 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtEOFIfParenInImplicitExpressionUnclosed.diagnostics.txt @@ -0,0 +1 @@ +(1,4): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtEOFIfParenInImplicitExpressionUnclosed.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtEOFIfParenInImplicitExpressionUnclosed.syntaxtree.txt new file mode 100644 index 0000000000..2507fca3e0 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtEOFIfParenInImplicitExpressionUnclosed.syntaxtree.txt @@ -0,0 +1,12 @@ +Expression block - Gen - 22 - (0:0,0) + Code span - Gen - [Foo(Bar(Baz)LFBizLFBoz] - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 - (0:0,0) - Symbols:10 + CSharpSymbolType.Identifier;[Foo]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[Bar]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[Baz]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.NewLine;[LF]; + CSharpSymbolType.Identifier;[Biz]; + CSharpSymbolType.NewLine;[LF]; + CSharpSymbolType.Identifier;[Boz]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExpressionUnclosed.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExpressionUnclosed.diagnostics.txt new file mode 100644 index 0000000000..2355923768 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExpressionUnclosed.diagnostics.txt @@ -0,0 +1 @@ +(1,4): Error RZ1027: An opening "[" is missing the corresponding closing "]". diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExpressionUnclosed.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExpressionUnclosed.syntaxtree.txt new file mode 100644 index 0000000000..22442daf9a --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExpressionUnclosed.syntaxtree.txt @@ -0,0 +1,11 @@ +Expression block - Gen - 19 - (0:0,0) + Code span - Gen - [Foo[Bar[Baz]LFBizLF] - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 - (0:0,0) - Symbols:9 + CSharpSymbolType.Identifier;[Foo]; + CSharpSymbolType.LeftBracket;[[]; + CSharpSymbolType.Identifier;[Bar]; + CSharpSymbolType.LeftBracket;[[]; + CSharpSymbolType.Identifier;[Baz]; + CSharpSymbolType.RightBracket;[]]; + CSharpSymbolType.NewLine;[LF]; + CSharpSymbolType.Identifier;[Biz]; + CSharpSymbolType.NewLine;[LF]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExpressionUnclosed.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExpressionUnclosed.diagnostics.txt new file mode 100644 index 0000000000..2996b166be --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExpressionUnclosed.diagnostics.txt @@ -0,0 +1 @@ +(1,1): Error RZ1006: The explicit expression 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExpressionUnclosed.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExpressionUnclosed.syntaxtree.txt new file mode 100644 index 0000000000..fff7ad0517 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExpressionUnclosed.syntaxtree.txt @@ -0,0 +1,8 @@ +Expression block - Gen - 10 - (0:0,0) + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.LeftParenthesis;[(]; + Code span - Gen - [foo barLF] - SpanEditHandler;Accepts:Any - (1:0,1) - Symbols:4 + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.NewLine;[LF]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.diagnostics.txt new file mode 100644 index 0000000000..a08a836e65 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.diagnostics.txt @@ -0,0 +1 @@ +(1,4): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.syntaxtree.txt new file mode 100644 index 0000000000..aead3fc0d1 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed.syntaxtree.txt @@ -0,0 +1,11 @@ +Expression block - Gen - 19 - (0:0,0) + Code span - Gen - [Foo(Bar(Baz)LFBizLF] - ImplicitExpressionEditHandler;Accepts:Any;ImplicitExpression[RTD];K14 - (0:0,0) - Symbols:9 + CSharpSymbolType.Identifier;[Foo]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[Bar]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[Baz]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.NewLine;[LF]; + CSharpSymbolType.Identifier;[Biz]; + CSharpSymbolType.NewLine;[LF]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.diagnostics.txt new file mode 100644 index 0000000000..b30a1516ec --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.diagnostics.txt @@ -0,0 +1 @@ +(1,8): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.syntaxtree.txt new file mode 100644 index 0000000000..e6a3bf318e --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen.syntaxtree.txt @@ -0,0 +1,8 @@ +Statement block - Gen - 17 - (0:0,0) + Code span - Gen - [foreach(foo barLF] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:6 + CSharpSymbolType.Keyword;[foreach]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.NewLine;[LF]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.diagnostics.txt new file mode 100644 index 0000000000..409c3a530f --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.diagnostics.txt @@ -0,0 +1 @@ +(1,3): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.syntaxtree.txt new file mode 100644 index 0000000000..32445eb7b7 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen.syntaxtree.txt @@ -0,0 +1,8 @@ +Statement block - Gen - 12 - (0:0,0) + Code span - Gen - [if(foo barLF] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:6 + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.NewLine;[LF]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.diagnostics.txt new file mode 100644 index 0000000000..73d5e27b67 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.diagnostics.txt @@ -0,0 +1 @@ +(2,13): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.syntaxtree.txt new file mode 100644 index 0000000000..475e4152b9 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing.syntaxtree.txt @@ -0,0 +1,21 @@ +Statement block - Gen - 41 - (0:0,0) + Code span - Gen - [if(foo) {LF var p = "foo bar bazLF;LF}] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:19 + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.NewLine;[LF]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[var]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[p]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Assign;[=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.StringLiteral;["foo bar baz];RZ1000(23:1,12 [1] ) + CSharpSymbolType.NewLine;[LF]; + CSharpSymbolType.Semicolon;[;]; + CSharpSymbolType.NewLine;[LF]; + CSharpSymbolType.RightBrace;[}]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesNormalStringAtEndOfFile.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesNormalStringAtEndOfFile.diagnostics.txt new file mode 100644 index 0000000000..87d10aab25 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesNormalStringAtEndOfFile.diagnostics.txt @@ -0,0 +1,2 @@ +(1,21): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. +(1,1): Error RZ1006: The if 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesNormalStringAtEndOfFile.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesNormalStringAtEndOfFile.syntaxtree.txt new file mode 100644 index 0000000000..6648ce44b9 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesNormalStringAtEndOfFile.syntaxtree.txt @@ -0,0 +1,16 @@ +Statement block - Gen - 45 - (0:0,0) + Code span - Gen - [if(foo) { var foo = "blah blah blah blah blah] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:14 + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[var]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Assign;[=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.StringLiteral;["blah blah blah blah blah];RZ1000(20:0,20 [1] ) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.diagnostics.txt new file mode 100644 index 0000000000..6cb7c82385 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.diagnostics.txt @@ -0,0 +1 @@ +(1,6): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.syntaxtree.txt new file mode 100644 index 0000000000..4e53aa8634 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen.syntaxtree.txt @@ -0,0 +1,8 @@ +Statement block - Gen - 15 - (0:0,0) + Code span - Gen - [using(foo barLF] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:6 + CSharpSymbolType.Keyword;[using]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.NewLine;[LF]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesVerbatimStringAtEndOfFile.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesVerbatimStringAtEndOfFile.diagnostics.txt new file mode 100644 index 0000000000..87d10aab25 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesVerbatimStringAtEndOfFile.diagnostics.txt @@ -0,0 +1,2 @@ +(1,21): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. +(1,1): Error RZ1006: The if 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/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesVerbatimStringAtEndOfFile.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesVerbatimStringAtEndOfFile.syntaxtree.txt new file mode 100644 index 0000000000..4137bfde8d --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesVerbatimStringAtEndOfFile.syntaxtree.txt @@ -0,0 +1,16 @@ +Statement block - Gen - 60 - (0:0,0) + Code span - Gen - [if(foo) { var foo = @"blah LFblah; LF

Foo

LFblah LFblah] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:14 + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.RightParenthesis;[)]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[var]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Assign;[=]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.StringLiteral;[@"blah LFblah; LF

Foo

LFblah LFblah];RZ1000(20:0,20 [1] ) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesWhileClauseInDoStatementAtEOLWhenRecoveringFromMissingCloseParen.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesWhileClauseInDoStatementAtEOLWhenRecoveringFromMissingCloseParen.diagnostics.txt new file mode 100644 index 0000000000..8ae5df0726 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesWhileClauseInDoStatementAtEOLWhenRecoveringFromMissingCloseParen.diagnostics.txt @@ -0,0 +1 @@ +(1,13): Error RZ1027: An opening "(" is missing the corresponding closing ")". diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesWhileClauseInDoStatementAtEOLWhenRecoveringFromMissingCloseParen.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesWhileClauseInDoStatementAtEOLWhenRecoveringFromMissingCloseParen.syntaxtree.txt new file mode 100644 index 0000000000..44c82a424c --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockTerminatesWhileClauseInDoStatementAtEOLWhenRecoveringFromMissingCloseParen.syntaxtree.txt @@ -0,0 +1,14 @@ +Statement block - Gen - 22 - (0:0,0) + Code span - Gen - [do { } while(foo barLF] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:12 + CSharpSymbolType.Keyword;[do]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Keyword;[while]; + CSharpSymbolType.LeftParenthesis;[(]; + CSharpSymbolType.Identifier;[foo]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.Identifier;[bar]; + CSharpSymbolType.NewLine;[LF]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockWithHelperDirectiveProducesError.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockWithHelperDirectiveProducesError.diagnostics.txt new file mode 100644 index 0000000000..dafdc8f2e9 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockWithHelperDirectiveProducesError.diagnostics.txt @@ -0,0 +1 @@ +(1,2): Error RZ1002: The helper directive is not supported. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockWithHelperDirectiveProducesError.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockWithHelperDirectiveProducesError.syntaxtree.txt new file mode 100644 index 0000000000..b3da1fc769 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockWithHelperDirectiveProducesError.syntaxtree.txt @@ -0,0 +1,5 @@ +Expression block - Gen - 7 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.Transition;[@]; + Code span - Gen - [helper] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (1:0,1) - Symbols:1 + CSharpSymbolType.Identifier;[helper]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockWithNestedCodeBlockProducesError.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockWithNestedCodeBlockProducesError.diagnostics.txt new file mode 100644 index 0000000000..302b641580 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockWithNestedCodeBlockProducesError.diagnostics.txt @@ -0,0 +1 @@ +(1,8): Error RZ1010: Unexpected "{" after "@" character. Once inside the body of a code block (@if {}, @{}, etc.) you do not need to use "@{" to switch to code. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockWithNestedCodeBlockProducesError.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockWithNestedCodeBlockProducesError.syntaxtree.txt new file mode 100644 index 0000000000..9507be3472 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpErrorTest/ParseBlockWithNestedCodeBlockProducesError.syntaxtree.txt @@ -0,0 +1,20 @@ +Statement block - Gen - 11 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.Transition;[@]; + Code span - Gen - [if { ] - SpanEditHandler;Accepts:Any - (1:0,1) - Symbols:4 + CSharpSymbolType.Keyword;[if]; + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.LeftBrace;[{]; + CSharpSymbolType.WhiteSpace;[ ]; + Statement block - Gen - 3 - (6:0,6) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (6:0,6) - Symbols:1 + CSharpSymbolType.Transition;[@]; + MetaCode span - Gen - [{] - SpanEditHandler;Accepts:None - (7:0,7) - Symbols:1 + CSharpSymbolType.LeftBrace;[{]; + Code span - Gen - [] - AutoCompleteEditHandler;Accepts:Any,AutoComplete:[];AtEOL - (8:0,8) - Symbols:1 + CSharpSymbolType.Unknown;[]; + MetaCode span - Gen - [}] - SpanEditHandler;Accepts:None - (8:0,8) - Symbols:1 + CSharpSymbolType.RightBrace;[}]; + Code span - Gen - [ }] - SpanEditHandler;Accepts:Any - (9:0,9) - Symbols:2 + CSharpSymbolType.WhiteSpace;[ ]; + CSharpSymbolType.RightBrace;[}]; diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs index 42031cd37f..82cd4f37c7 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs @@ -16,6 +16,7 @@ using System.Threading; using System.Text; using Xunit; using Xunit.Sdk; +using System.Text.RegularExpressions; namespace Microsoft.AspNetCore.Razor.Language.Legacy { @@ -112,7 +113,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy File.WriteAllText(baselineFullPath, SyntaxTreeNodeSerializer.Serialize(root)); var baselineDiagnosticsFullPath = Path.Combine(TestProjectRoot, baselineDiagnosticsFileName); - var lines = diagnostics.Select(RazorDiagnosticSerializer.Serialize).ToArray(); + var lines = diagnostics.Select(SerializeDiagnostic).ToArray(); if (lines.Any()) { File.WriteAllLines(baselineDiagnosticsFullPath, lines); @@ -141,10 +142,23 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy baselineDiagnostics = diagnosticsFile.ReadAllText(); } - var actualDiagnostics = string.Concat(diagnostics.Select(d => RazorDiagnosticSerializer.Serialize(d) + "\r\n")); + var actualDiagnostics = string.Concat(diagnostics.Select(d => SerializeDiagnostic(d) + "\r\n")); Assert.Equal(baselineDiagnostics, actualDiagnostics); } + private static string SerializeDiagnostic(RazorDiagnostic diagnostic) + { + var content = RazorDiagnosticSerializer.Serialize(diagnostic); + var normalized = NormalizeNewLines(content); + + return normalized; + } + + private static string NormalizeNewLines(string content) + { + return Regex.Replace(content, "(?