");
}
[Fact]
public void ParseBlockStartingWithEndTagProducesRazorErrorThenOutputsMarkupSegmentAndEndsBlock()
{
- ParseBlockTest(" bar baz",
- new MarkupBlock(
- new MarkupTagBlock(
- Factory.Markup("").Accepts(AcceptedCharactersInternal.None)),
- Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)),
- RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag(
- new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 3), "foo"));
+ ParseBlockTest(" bar baz");
}
[Fact]
public void ParseBlockWithUnclosedTopLevelTagThrowsMissingEndTagParserExceptionOnOutermostUnclosedTag()
{
- ParseBlockTest("",
- new MarkupBlock(
- new MarkupTagBlock(
- Factory.Markup("").Accepts(AcceptedCharactersInternal.None)),
- new MarkupTagBlock(
- Factory.Markup("").Accepts(AcceptedCharactersInternal.None)),
- new MarkupTagBlock(
- Factory.Markup("").Accepts(AcceptedCharactersInternal.None))),
- RazorDiagnosticFactory.CreateParsing_MissingEndTag(
- new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"));
+ ParseBlockTest("");
}
[Fact]
public void ParseBlockWithUnclosedTagAtEOFThrowsMissingEndTagException()
{
- ParseBlockTest("blah blah blah blah blah",
- new MarkupBlock(
- new MarkupTagBlock(
- Factory.Markup("").Accepts(AcceptedCharactersInternal.None)),
- Factory.Markup("blah blah blah blah blah")),
- RazorDiagnosticFactory.CreateParsing_MissingEndTag(
- new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 3), "foo"));
+ ParseBlockTest("blah blah blah blah blah");
}
[Fact]
public void ParseBlockWithUnfinishedTagAtEOFThrowsIncompleteTagException()
{
- ParseBlockTest("(" bar=", 4, 0, 4), new LocationTagged(string.Empty, 12, 0, 12)),
- Factory.Markup(" bar=").With(SpanChunkGenerator.Null),
- Factory.Markup("baz").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 9, 0, 9), new LocationTagged("baz", 9, 0, 9)))))),
- RazorDiagnosticFactory.CreateParsing_UnfinishedTag(
- new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 3), "foo"));
+ ParseBlockTest(" - 26 - (0:0,0)
+ Tag block - Gen - 11 - (0:0,0)
+ Markup span - Gen - [<1-foo+bar>] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:3
+ HtmlSymbolType.OpenAngle;[<];
+ HtmlSymbolType.Text;[1-foo+bar];
+ HtmlSymbolType.CloseAngle;[>];
+ Markup span - Gen - [foo] - SpanEditHandler;Accepts:Any - (11:0,11) - Symbols:1
+ HtmlSymbolType.Text;[foo];
+ Tag block - Gen - 12 - (14:0,14)
+ Markup span - Gen - [1-foo+bar>] - SpanEditHandler;Accepts:None - (14:0,14) - Symbols:4
+ HtmlSymbolType.OpenAngle;[<];
+ HtmlSymbolType.ForwardSlash;[/];
+ HtmlSymbolType.Text;[1-foo+bar];
+ HtmlSymbolType.CloseAngle;[>];
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockStartingWithEndTagProducesRazorErrorThenOutputsMarkupSegmentAndEndsBlock.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockStartingWithEndTagProducesRazorErrorThenOutputsMarkupSegmentAndEndsBlock.diagnostics.txt
new file mode 100644
index 0000000000..817c1816ff
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockStartingWithEndTagProducesRazorErrorThenOutputsMarkupSegmentAndEndsBlock.diagnostics.txt
@@ -0,0 +1 @@
+(1,3): Error RZ1026: Encountered end tag "foo" with no matching start tag. Are your start/end tags properly balanced?
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockStartingWithEndTagProducesRazorErrorThenOutputsMarkupSegmentAndEndsBlock.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockStartingWithEndTagProducesRazorErrorThenOutputsMarkupSegmentAndEndsBlock.syntaxtree.txt
new file mode 100644
index 0000000000..837fcf37ea
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockStartingWithEndTagProducesRazorErrorThenOutputsMarkupSegmentAndEndsBlock.syntaxtree.txt
@@ -0,0 +1,9 @@
+Markup block - Gen - 7 - (0:0,0)
+ Tag block - Gen - 6 - (0:0,0)
+ Markup span - Gen - [] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:4
+ HtmlSymbolType.OpenAngle;[<];
+ HtmlSymbolType.ForwardSlash;[/];
+ HtmlSymbolType.Text;[foo];
+ HtmlSymbolType.CloseAngle;[>];
+ Markup span - Gen - [ ] - SpanEditHandler;Accepts:None - (6:0,6) - Symbols:1
+ HtmlSymbolType.WhiteSpace;[ ];
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockThrowsErrorIfEndTextTagContainsTextAfterName.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockThrowsErrorIfEndTextTagContainsTextAfterName.diagnostics.txt
new file mode 100644
index 0000000000..3f53c2b067
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockThrowsErrorIfEndTextTagContainsTextAfterName.diagnostics.txt
@@ -0,0 +1 @@
+(1,9): Error RZ1023: "" and "" tags cannot contain attributes.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockThrowsErrorIfEndTextTagContainsTextAfterName.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockThrowsErrorIfEndTextTagContainsTextAfterName.syntaxtree.txt
new file mode 100644
index 0000000000..2a07155bd9
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockThrowsErrorIfEndTextTagContainsTextAfterName.syntaxtree.txt
@@ -0,0 +1,16 @@
+Markup block - Gen - 21 - (0:0,0)
+ Tag block - Gen - 6 - (0:0,0)
+ Transition span - Gen - [] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:3
+ HtmlSymbolType.OpenAngle;[<];
+ HtmlSymbolType.Text;[text];
+ HtmlSymbolType.CloseAngle;[>];
+ Tag block - Gen - 15 - (6:0,6)
+ Transition span - Gen - [] - SpanEditHandler;Accepts:Any - (6:0,6) - Symbols:8
+ HtmlSymbolType.OpenAngle;[<];
+ HtmlSymbolType.ForwardSlash;[/];
+ HtmlSymbolType.Text;[text];
+ HtmlSymbolType.WhiteSpace;[ ];
+ HtmlSymbolType.Text;[foo];
+ HtmlSymbolType.WhiteSpace;[ ];
+ HtmlSymbolType.Text;[bar];
+ HtmlSymbolType.CloseAngle;[>];
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockThrowsErrorIfStartTextTagContainsTextAfterName.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockThrowsErrorIfStartTextTagContainsTextAfterName.diagnostics.txt
new file mode 100644
index 0000000000..63bd9873af
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockThrowsErrorIfStartTextTagContainsTextAfterName.diagnostics.txt
@@ -0,0 +1 @@
+(1,2): Error RZ1023: "" and "" tags cannot contain attributes.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockThrowsErrorIfStartTextTagContainsTextAfterName.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockThrowsErrorIfStartTextTagContainsTextAfterName.syntaxtree.txt
new file mode 100644
index 0000000000..558bd85db1
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockThrowsErrorIfStartTextTagContainsTextAfterName.syntaxtree.txt
@@ -0,0 +1,16 @@
+Markup block - Gen - 21 - (0:0,0)
+ Tag block - Gen - 14 - (0:0,0)
+ Transition span - Gen - [] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:7
+ HtmlSymbolType.OpenAngle;[<];
+ HtmlSymbolType.Text;[text];
+ HtmlSymbolType.WhiteSpace;[ ];
+ HtmlSymbolType.Text;[foo];
+ HtmlSymbolType.WhiteSpace;[ ];
+ HtmlSymbolType.Text;[bar];
+ HtmlSymbolType.CloseAngle;[>];
+ Tag block - Gen - 7 - (14:0,14)
+ Transition span - Gen - [] - SpanEditHandler;Accepts:None - (14:0,14) - Symbols:4
+ HtmlSymbolType.OpenAngle;[<];
+ HtmlSymbolType.ForwardSlash;[/];
+ HtmlSymbolType.Text;[text];
+ HtmlSymbolType.CloseAngle;[>];
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockThrowsExceptionIfBlockDoesNotStartWithTag.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockThrowsExceptionIfBlockDoesNotStartWithTag.diagnostics.txt
new file mode 100644
index 0000000000..7895bdeeab
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockThrowsExceptionIfBlockDoesNotStartWithTag.diagnostics.txt
@@ -0,0 +1 @@
+(1,1): Error RZ1021: Markup in a code block must start with a tag and all start tags must be matched with end tags. Do not use unclosed tags like "
". Instead use self-closing tags like "
".
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockThrowsExceptionIfBlockDoesNotStartWithTag.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockThrowsExceptionIfBlockDoesNotStartWithTag.syntaxtree.txt
new file mode 100644
index 0000000000..2817f30307
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockThrowsExceptionIfBlockDoesNotStartWithTag.syntaxtree.txt
@@ -0,0 +1 @@
+Markup block - Gen - 0 - (0:0,0)
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockWithUnclosedTagAtEOFThrowsMissingEndTagException.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockWithUnclosedTagAtEOFThrowsMissingEndTagException.diagnostics.txt
new file mode 100644
index 0000000000..1de63b58d1
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockWithUnclosedTagAtEOFThrowsMissingEndTagException.diagnostics.txt
@@ -0,0 +1 @@
+(1,2): Error RZ1025: The "foo" element was not closed. All elements must be either self-closing or have a matching end tag.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockWithUnclosedTagAtEOFThrowsMissingEndTagException.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockWithUnclosedTagAtEOFThrowsMissingEndTagException.syntaxtree.txt
new file mode 100644
index 0000000000..7ef17370f7
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockWithUnclosedTagAtEOFThrowsMissingEndTagException.syntaxtree.txt
@@ -0,0 +1,16 @@
+Markup block - Gen - 29 - (0:0,0)
+ Tag block - Gen - 5 - (0:0,0)
+ Markup span - Gen - [] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:3
+ HtmlSymbolType.OpenAngle;[<];
+ HtmlSymbolType.Text;[foo];
+ HtmlSymbolType.CloseAngle;[>];
+ Markup span - Gen - [blah blah blah blah blah] - SpanEditHandler;Accepts:Any - (5:0,5) - Symbols:9
+ HtmlSymbolType.Text;[blah];
+ HtmlSymbolType.WhiteSpace;[ ];
+ HtmlSymbolType.Text;[blah];
+ HtmlSymbolType.WhiteSpace;[ ];
+ HtmlSymbolType.Text;[blah];
+ HtmlSymbolType.WhiteSpace;[ ];
+ HtmlSymbolType.Text;[blah];
+ HtmlSymbolType.WhiteSpace;[ ];
+ HtmlSymbolType.Text;[blah];
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockWithUnclosedTopLevelTagThrowsMissingEndTagParserExceptionOnOutermostUnclosedTag.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockWithUnclosedTopLevelTagThrowsMissingEndTagParserExceptionOnOutermostUnclosedTag.diagnostics.txt
new file mode 100644
index 0000000000..62f7a40547
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockWithUnclosedTopLevelTagThrowsMissingEndTagParserExceptionOnOutermostUnclosedTag.diagnostics.txt
@@ -0,0 +1 @@
+(1,2): Error RZ1025: The "p" element was not closed. All elements must be either self-closing or have a matching end tag.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockWithUnclosedTopLevelTagThrowsMissingEndTagParserExceptionOnOutermostUnclosedTag.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockWithUnclosedTopLevelTagThrowsMissingEndTagParserExceptionOnOutermostUnclosedTag.syntaxtree.txt
new file mode 100644
index 0000000000..88641f430d
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockWithUnclosedTopLevelTagThrowsMissingEndTagParserExceptionOnOutermostUnclosedTag.syntaxtree.txt
@@ -0,0 +1,17 @@
+Markup block - Gen - 14 - (0:0,0)
+ Tag block - Gen - 3 - (0:0,0)
+ Markup span - Gen - [] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:3
+ HtmlSymbolType.OpenAngle;[<];
+ HtmlSymbolType.Text;[p];
+ HtmlSymbolType.CloseAngle;[>];
+ Tag block - Gen - 5 - (3:0,3)
+ Markup span - Gen - [] - SpanEditHandler;Accepts:None - (3:0,3) - Symbols:3
+ HtmlSymbolType.OpenAngle;[<];
+ HtmlSymbolType.Text;[foo];
+ HtmlSymbolType.CloseAngle;[>];
+ Tag block - Gen - 6 - (8:0,8)
+ Markup span - Gen - [] - SpanEditHandler;Accepts:None - (8:0,8) - Symbols:4
+ HtmlSymbolType.OpenAngle;[<];
+ HtmlSymbolType.ForwardSlash;[/];
+ HtmlSymbolType.Text;[bar];
+ HtmlSymbolType.CloseAngle;[>];
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockWithUnfinishedTagAtEOFThrowsIncompleteTagException.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockWithUnfinishedTagAtEOFThrowsIncompleteTagException.diagnostics.txt
new file mode 100644
index 0000000000..3ad9732fe6
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockWithUnfinishedTagAtEOFThrowsIncompleteTagException.diagnostics.txt
@@ -0,0 +1 @@
+(1,2): Error RZ1024: End of file or an unexpected character was reached before the "foo" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("
") or have matching end tags ("Hello
"). If you intended to display a "<" character, use the "<" HTML entity.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockWithUnfinishedTagAtEOFThrowsIncompleteTagException.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockWithUnfinishedTagAtEOFThrowsIncompleteTagException.syntaxtree.txt
new file mode 100644
index 0000000000..14f833f254
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/HtmlErrorTest/ParseBlockWithUnfinishedTagAtEOFThrowsIncompleteTagException.syntaxtree.txt
@@ -0,0 +1,12 @@
+Markup block - Gen - 12 - (0:0,0)
+ Tag block - Gen - 12 - (0:0,0)
+ Markup span - Gen - [ - 8 - (4:0,4)
+ Markup span - Gen - [ bar=] - SpanEditHandler;Accepts:Any - (4:0,4) - Symbols:3
+ HtmlSymbolType.WhiteSpace;[ ];
+ HtmlSymbolType.Text;[bar];
+ HtmlSymbolType.Equals;[=];
+ Markup span - Gen - [baz] - SpanEditHandler;Accepts:Any - (9:0,9) - Symbols:1
+ HtmlSymbolType.Text;[baz];