Moved HtmlMarkupParser out of LegacyRazorDiagnostic

This commit is contained in:
Ajay Bhargav Baaskaran 2017-12-19 16:09:43 -08:00
parent bace4a3818
commit 7d4fb5dcab
13 changed files with 197 additions and 231 deletions

View File

@ -310,9 +310,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
else else
{ {
Context.ErrorSink.OnError( Context.ErrorSink.OnError(
CurrentStart, RazorDiagnosticFactory.CreateParsing_MarkupBlockMustStartWithTag(
LegacyResources.ParseError_MarkupBlock_Must_Start_With_Tag, new SourceSpan(CurrentStart, CurrentSymbol.Content.Length)));
CurrentSymbol.Content.Length);
} }
Output(SpanKindInternal.Markup); Output(SpanKindInternal.Markup);
} }
@ -472,9 +471,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
if (tags.Count == 0) if (tags.Count == 0)
{ {
Context.ErrorSink.OnError( Context.ErrorSink.OnError(
CurrentStart, RazorDiagnosticFactory.CreateParsing_OuterTagMissingName(
LegacyResources.ParseError_OuterTagMissingName, new SourceSpan(CurrentStart, contentLength: 1 /* end of file */)));
length: 1 /* end of file */);
} }
return false; return false;
} }
@ -634,9 +632,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
if (!seenCloseAngle) if (!seenCloseAngle)
{ {
Context.ErrorSink.OnError( Context.ErrorSink.OnError(
textLocation, RazorDiagnosticFactory.CreateParsing_TextTagCannotContainAttributes(
LegacyResources.ParseError_TextTagCannotContainAttributes, new SourceSpan(textLocation, contentLength: 4 /* text */)));
length: 4 /* text */);
Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.Any; Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.Any;
RecoverTextTag(); RecoverTextTag();
@ -1089,9 +1086,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
Context.Source.Position = bookmark; Context.Source.Position = bookmark;
NextToken(); NextToken();
Context.ErrorSink.OnError( Context.ErrorSink.OnError(
textLocation, RazorDiagnosticFactory.CreateParsing_TextTagCannotContainAttributes(
LegacyResources.ParseError_TextTagCannotContainAttributes, new SourceSpan(textLocation, contentLength: 4 /* text */)));
length: 4 /* text */);
RecoverTextTag(); RecoverTextTag();
} }
@ -1142,9 +1138,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
if (!seenClose) if (!seenClose)
{ {
Context.ErrorSink.OnError( Context.ErrorSink.OnError(
SourceLocationTracker.Advance(tag.Item2, "<"), RazorDiagnosticFactory.CreateParsing_UnfinishedTag(
LegacyResources.FormatParseError_UnfinishedTag(tag.Item1.Content), new SourceSpan(
Math.Max(tag.Item1.Content.Length, 1)); SourceLocationTracker.Advance(tag.Item2, "<"),
Math.Max(tag.Item1.Content.Length, 1)),
tag.Item1.Content));
} }
else else
{ {
@ -1277,9 +1275,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
if (!Optional(HtmlSymbolType.CloseAngle)) if (!Optional(HtmlSymbolType.CloseAngle))
{ {
Context.ErrorSink.OnError( Context.ErrorSink.OnError(
SourceLocationTracker.Advance(tagStart, "</"), RazorDiagnosticFactory.CreateParsing_UnfinishedTag(
LegacyResources.FormatParseError_UnfinishedTag(ScriptTagName), new SourceSpan(SourceLocationTracker.Advance(tagStart, "</"), ScriptTagName.Length),
ScriptTagName.Length); ScriptTagName));
} }
Output(SpanKindInternal.Markup); Output(SpanKindInternal.Markup);
} }
@ -1335,16 +1333,17 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
if (currentTag != null) if (currentTag != null)
{ {
Context.ErrorSink.OnError( Context.ErrorSink.OnError(
SourceLocationTracker.Advance(currentTag.Item2, "<"), RazorDiagnosticFactory.CreateParsing_MissingEndTag(
LegacyResources.FormatParseError_MissingEndTag(currentTag.Item1.Content), new SourceSpan(
currentTag.Item1.Content.Length); SourceLocationTracker.Advance(currentTag.Item2, "<"),
currentTag.Item1.Content.Length),
currentTag.Item1.Content));
} }
else else
{ {
Context.ErrorSink.OnError( Context.ErrorSink.OnError(
SourceLocationTracker.Advance(tagStart, "</"), RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag(
LegacyResources.FormatParseError_UnexpectedEndTag(tagName), new SourceSpan(SourceLocationTracker.Advance(tagStart, "</"), tagName.Length), tagName));
tagName.Length);
} }
return false; return false;
} }
@ -1360,9 +1359,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
} }
var tag = tags.Pop(); var tag = tags.Pop();
Context.ErrorSink.OnError( Context.ErrorSink.OnError(
SourceLocationTracker.Advance(tag.Item2, "<"), RazorDiagnosticFactory.CreateParsing_MissingEndTag(
LegacyResources.FormatParseError_MissingEndTag(tag.Item1.Content), new SourceSpan(
tag.Item1.Content.Length); SourceLocationTracker.Advance(tag.Item2, "<"),
tag.Item1.Content.Length),
tag.Item1.Content));
} }
else if (complete) else if (complete)
{ {

View File

@ -250,6 +250,66 @@ namespace Microsoft.AspNetCore.Razor.Language
return RazorDiagnostic.Create(Parsing_InvalidTagHelperLookupText, location, lookupText); return RazorDiagnostic.Create(Parsing_InvalidTagHelperLookupText, location, lookupText);
} }
internal static readonly RazorDiagnosticDescriptor Parsing_MarkupBlockMustStartWithTag =
new RazorDiagnosticDescriptor(
$"{DiagnosticPrefix}1021",
() => LegacyResources.ParseError_MarkupBlock_Must_Start_With_Tag,
RazorDiagnosticSeverity.Error);
public static RazorDiagnostic CreateParsing_MarkupBlockMustStartWithTag(SourceSpan location)
{
return RazorDiagnostic.Create(Parsing_MarkupBlockMustStartWithTag, location);
}
internal static readonly RazorDiagnosticDescriptor Parsing_OuterTagMissingName =
new RazorDiagnosticDescriptor(
$"{DiagnosticPrefix}1022",
() => LegacyResources.ParseError_OuterTagMissingName,
RazorDiagnosticSeverity.Error);
public static RazorDiagnostic CreateParsing_OuterTagMissingName(SourceSpan location)
{
return RazorDiagnostic.Create(Parsing_OuterTagMissingName, location);
}
internal static readonly RazorDiagnosticDescriptor Parsing_TextTagCannotContainAttributes =
new RazorDiagnosticDescriptor(
$"{DiagnosticPrefix}1023",
() => LegacyResources.ParseError_TextTagCannotContainAttributes,
RazorDiagnosticSeverity.Error);
public static RazorDiagnostic CreateParsing_TextTagCannotContainAttributes(SourceSpan location)
{
return RazorDiagnostic.Create(Parsing_TextTagCannotContainAttributes, location);
}
internal static readonly RazorDiagnosticDescriptor Parsing_UnfinishedTag =
new RazorDiagnosticDescriptor(
$"{DiagnosticPrefix}1024",
() => LegacyResources.ParseError_UnfinishedTag,
RazorDiagnosticSeverity.Error);
public static RazorDiagnostic CreateParsing_UnfinishedTag(SourceSpan location, string tagName)
{
return RazorDiagnostic.Create(Parsing_UnfinishedTag, location, tagName);
}
internal static readonly RazorDiagnosticDescriptor Parsing_MissingEndTag =
new RazorDiagnosticDescriptor(
$"{DiagnosticPrefix}1025",
() => LegacyResources.ParseError_MissingEndTag,
RazorDiagnosticSeverity.Error);
public static RazorDiagnostic CreateParsing_MissingEndTag(SourceSpan location, string tagName)
{
return RazorDiagnostic.Create(Parsing_MissingEndTag, location, tagName);
}
internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedEndTag =
new RazorDiagnosticDescriptor(
$"{DiagnosticPrefix}1026",
() => LegacyResources.ParseError_UnexpectedEndTag,
RazorDiagnosticSeverity.Error);
public static RazorDiagnostic CreateParsing_UnexpectedEndTag(SourceSpan location, string tagName)
{
return RazorDiagnostic.Create(Parsing_UnexpectedEndTag, location, tagName);
}
#endregion #endregion
#region Semantic Errors #region Semantic Errors

View File

@ -1145,10 +1145,8 @@ catch(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code);
Factory.EmptyHtml())); Factory.EmptyHtml()));
var expectedErrors = new RazorDiagnostic[] var expectedErrors = new RazorDiagnostic[]
{ {
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_UnfinishedTag(
@"End of file or an unexpected character was reached before the ""span"" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing (""<br />"") or have matching end tags (""<p>Hello</p>""). If you intended to display a ""<"" character, use the ""&lt;"" HTML entity.", new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 4), "span"),
new SourceLocation(2, 0, 2),
length: 4)),
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(SourceLocation.Zero, contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(SourceLocation.Zero, contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
}; };

View File

@ -149,14 +149,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
.Accepts(AcceptedCharactersInternal.None)), .Accepts(AcceptedCharactersInternal.None)),
Factory.Markup(Environment.NewLine).With(SpanChunkGenerator.Null), Factory.Markup(Environment.NewLine).With(SpanChunkGenerator.Null),
Factory.Markup("}")))), Factory.Markup("}")))),
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_TextTagCannotContainAttributes(
LegacyResources.ParseError_TextTagCannotContainAttributes, new SourceSpan(new SourceLocation(7 + Environment.NewLine.Length, 1, 5), contentLength: 4)),
new SourceLocation(7 + Environment.NewLine.Length, 1, 5), RazorDiagnosticFactory.CreateParsing_MissingEndTag(
length: 4)), new SourceSpan(new SourceLocation(7 + Environment.NewLine.Length, 1, 5), contentLength: 4), "text"),
RazorDiagnostic.Create(new RazorError(
LegacyResources.FormatParseError_MissingEndTag("text"),
new SourceLocation(7 + Environment.NewLine.Length, 1, 5),
length: 4)),
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{")); new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"));
} }

View File

@ -79,10 +79,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
designTime: true, designTime: true,
expectedErrors: new[] expectedErrors: new[]
{ {
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag(
LegacyResources.FormatParseError_UnexpectedEndTag("html"), new SourceSpan(new SourceLocation(5 + Environment.NewLine.Length * 2, 2, 2), contentLength: 4), "html"),
new SourceLocation(5 + Environment.NewLine.Length * 2, 2, 2),
length: 4)),
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
}); });
@ -97,10 +95,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
new MarkupTagBlock( new MarkupTagBlock(
Factory.Markup($"< {Environment.NewLine} "))), Factory.Markup($"< {Environment.NewLine} "))),
designTime: true, designTime: true,
expectedErrors: RazorDiagnostic.Create(new RazorError( expectedErrors: RazorDiagnosticFactory.CreateParsing_UnfinishedTag(
LegacyResources.FormatParseError_UnfinishedTag(string.Empty), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), string.Empty));
new SourceLocation(1, 0, 1),
length: 1)));
} }
[Fact] [Fact]
@ -330,10 +326,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
new MarkupBlock( new MarkupBlock(
new MarkupTagBlock( new MarkupTagBlock(
Factory.Markup("<foo>").Accepts(AcceptedCharactersInternal.None))), Factory.Markup("<foo>").Accepts(AcceptedCharactersInternal.None))),
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_MissingEndTag(
LegacyResources.FormatParseError_MissingEndTag("foo"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 3), "foo"));
new SourceLocation(1, 0, 1),
length: 3)));
} }
[Fact] [Fact]
@ -453,10 +447,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
Factory.Markup("<foo>").Accepts(AcceptedCharactersInternal.None)), Factory.Markup("<foo>").Accepts(AcceptedCharactersInternal.None)),
new MarkupTagBlock( new MarkupTagBlock(
Factory.Markup("</!-- bar -->").Accepts(AcceptedCharactersInternal.None))), Factory.Markup("</!-- bar -->").Accepts(AcceptedCharactersInternal.None))),
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_MissingEndTag(
LegacyResources.FormatParseError_MissingEndTag("foo"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 3), "foo"));
new SourceLocation(1, 0, 1),
length: 3)));
} }
@ -615,10 +607,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
new MarkupBlock( new MarkupBlock(
new MarkupTagBlock( new MarkupTagBlock(
Factory.Markup("<br/"))), Factory.Markup("<br/"))),
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_UnfinishedTag(
LegacyResources.FormatParseError_UnfinishedTag("br"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 2), "br"));
new SourceLocation(1, 0, 1),
length: 2)));
} }
[Fact] [Fact]

View File

@ -28,10 +28,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
Factory.MarkupTransition("<text foo bar>").Accepts(AcceptedCharactersInternal.Any)), Factory.MarkupTransition("<text foo bar>").Accepts(AcceptedCharactersInternal.Any)),
new MarkupTagBlock( new MarkupTagBlock(
Factory.MarkupTransition("</text>"))), Factory.MarkupTransition("</text>"))),
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_TextTagCannotContainAttributes(
LegacyResources.ParseError_TextTagCannotContainAttributes, new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 4)));
new SourceLocation(1, 0, 1),
length: 4)));
} }
[Fact] [Fact]
@ -43,10 +41,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
Factory.MarkupTransition("<text>")), Factory.MarkupTransition("<text>")),
new MarkupTagBlock( new MarkupTagBlock(
Factory.MarkupTransition("</text foo bar>").Accepts(AcceptedCharactersInternal.Any))), Factory.MarkupTransition("</text foo bar>").Accepts(AcceptedCharactersInternal.Any))),
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_TextTagCannotContainAttributes(
LegacyResources.ParseError_TextTagCannotContainAttributes, new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 4)));
new SourceLocation(8, 0, 8),
length: 4)));
} }
[Fact] [Fact]
@ -54,10 +50,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
ParseBlockTest("foo bar <baz>", ParseBlockTest("foo bar <baz>",
new MarkupBlock(), new MarkupBlock(),
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_MarkupBlockMustStartWithTag(
LegacyResources.ParseError_MarkupBlock_Must_Start_With_Tag, new SourceSpan(SourceLocation.Zero, contentLength: 3)));
SourceLocation.Zero,
length: 3)));
} }
[Fact] [Fact]
@ -68,10 +62,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
new MarkupTagBlock( new MarkupTagBlock(
Factory.Markup("</foo>").Accepts(AcceptedCharactersInternal.None)), Factory.Markup("</foo>").Accepts(AcceptedCharactersInternal.None)),
Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)),
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag(
LegacyResources.FormatParseError_UnexpectedEndTag("foo"), new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 3), "foo"));
new SourceLocation(2, 0, 2),
length: 3)));
} }
[Fact] [Fact]
@ -85,10 +77,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
Factory.Markup("<foo>").Accepts(AcceptedCharactersInternal.None)), Factory.Markup("<foo>").Accepts(AcceptedCharactersInternal.None)),
new MarkupTagBlock( new MarkupTagBlock(
Factory.Markup("</bar>").Accepts(AcceptedCharactersInternal.None))), Factory.Markup("</bar>").Accepts(AcceptedCharactersInternal.None))),
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_MissingEndTag(
LegacyResources.FormatParseError_MissingEndTag("p"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"));
new SourceLocation(1, 0, 1),
length: 1)));
} }
[Fact] [Fact]
@ -99,10 +89,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
new MarkupTagBlock( new MarkupTagBlock(
Factory.Markup("<foo>").Accepts(AcceptedCharactersInternal.None)), Factory.Markup("<foo>").Accepts(AcceptedCharactersInternal.None)),
Factory.Markup("blah blah blah blah blah")), Factory.Markup("blah blah blah blah blah")),
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_MissingEndTag(
LegacyResources.FormatParseError_MissingEndTag("foo"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 3), "foo"));
new SourceLocation(1, 0, 1),
length: 3)));
} }
[Fact] [Fact]
@ -115,10 +103,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
new MarkupBlock(new AttributeBlockChunkGenerator("bar", new LocationTagged<string>(" bar=", 4, 0, 4), new LocationTagged<string>(string.Empty, 12, 0, 12)), new MarkupBlock(new AttributeBlockChunkGenerator("bar", new LocationTagged<string>(" bar=", 4, 0, 4), new LocationTagged<string>(string.Empty, 12, 0, 12)),
Factory.Markup(" bar=").With(SpanChunkGenerator.Null), Factory.Markup(" bar=").With(SpanChunkGenerator.Null),
Factory.Markup("baz").With(new LiteralAttributeChunkGenerator(new LocationTagged<string>(string.Empty, 9, 0, 9), new LocationTagged<string>("baz", 9, 0, 9)))))), Factory.Markup("baz").With(new LiteralAttributeChunkGenerator(new LocationTagged<string>(string.Empty, 9, 0, 9), new LocationTagged<string>("baz", 9, 0, 9)))))),
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_UnfinishedTag(
LegacyResources.FormatParseError_UnfinishedTag("foo"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 3), "foo"));
new SourceLocation(1, 0, 1),
length: 3)));
} }
} }
} }

View File

@ -39,10 +39,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
BlockFactory.MarkupTagBlock("<p>", AcceptedCharactersInternal.None), BlockFactory.MarkupTagBlock("<p>", AcceptedCharactersInternal.None),
BlockFactory.MarkupTagBlock("</>", AcceptedCharactersInternal.None), BlockFactory.MarkupTagBlock("</>", AcceptedCharactersInternal.None),
Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)),
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_MissingEndTag(
LegacyResources.FormatParseError_MissingEndTag("p"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), "p"));
new SourceLocation(1, 0, 1),
length: 1)));
} }
[Fact] [Fact]

View File

@ -742,9 +742,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
absoluteIndex: 3, lineIndex: 0 , columnIndex: 3, length: 30)), absoluteIndex: 3, lineIndex: 0 , columnIndex: 3, length: 30)),
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 1), "do", "}", "{"), new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 1), "do", "}", "{"),
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag(
LegacyResources.FormatParseError_UnexpectedEndTag("p"), new SourceSpan(filePath: null, absoluteIndex: 31, lineIndex: 0, characterIndex: 31, length: 1), "p")
absoluteIndex: 31, lineIndex: 0, columnIndex: 31, length: 1))
} }
}, },
{ {

View File

@ -2343,9 +2343,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
var factory = new SpanFactory(); var factory = new SpanFactory();
var blockFactory = new BlockFactory(factory); var blockFactory = new BlockFactory(factory);
var errorFormatNormalUnclosed =
"The \"{0}\" element was not closed. All elements must be either self-closing or have a " +
"matching end tag.";
Func<Func<MarkupBlock>, MarkupBlock> buildStatementBlock = (insideBuilder) => Func<Func<MarkupBlock>, MarkupBlock> buildStatementBlock = (insideBuilder) =>
{ {
@ -2392,9 +2389,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_MissingEndTag(
string.Format(errorFormatNormalUnclosed, "!text"), new SourceSpan(filePath: null, absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: 5), "!text"),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5))
} }
}, },
{ {
@ -2530,12 +2526,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
var errorFormatMalformed = var errorFormatMalformed =
"Found a malformed '{0}' tag helper. Tag helpers must have a start and end tag or be self " + "Found a malformed '{0}' tag helper. Tag helpers must have a start and end tag or be self " +
"closing."; "closing.";
var errorFormatNormalUnclosed =
"The \"{0}\" element was not closed. All elements must be either self-closing or have a " + RazorDiagnostic MissingEndTagError(string tagName)
"matching end tag."; {
var errorFormatNormalNotStarted = return RazorDiagnosticFactory.CreateParsing_MissingEndTag(
"Encountered end tag \"{0}\" with no matching start tag. Are your start/end tags properly " + new SourceSpan(filePath: null, absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: tagName.Length), tagName);
"balanced?"; }
Func<Func<MarkupBlock>, MarkupBlock> buildStatementBlock = (insideBuilder) => Func<Func<MarkupBlock>, MarkupBlock> buildStatementBlock = (insideBuilder) =>
{ {
@ -2567,9 +2563,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
RazorDiagnostic.Create(new RazorError( MissingEndTagError("!text"),
string.Format(errorFormatNormalUnclosed, "!text", CultureInfo.InvariantCulture),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5)),
} }
}, },
{ {
@ -2579,9 +2573,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
blockFactory.EscapedMarkupTagBlock("</", "text>", AcceptedCharactersInternal.None))), blockFactory.EscapedMarkupTagBlock("</", "text>", AcceptedCharactersInternal.None))),
new [] new []
{ {
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag(
string.Format(errorFormatNormalNotStarted, "!text", CultureInfo.InvariantCulture), new SourceSpan(filePath: null, absoluteIndex: 4, lineIndex: 0, characterIndex: 4, length: 5), "!text"),
absoluteIndex: 4, lineIndex: 0, columnIndex: 4, length: 5)),
} }
}, },
{ {
@ -2609,9 +2602,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
blockFactory.MarkupTagBlock("</text>", AcceptedCharactersInternal.None))), blockFactory.MarkupTagBlock("</text>", AcceptedCharactersInternal.None))),
new [] new []
{ {
RazorDiagnostic.Create(new RazorError( MissingEndTagError("!text"),
string.Format(errorFormatNormalUnclosed, "!text", CultureInfo.InvariantCulture),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5)),
RazorDiagnostic.Create(new RazorError( RazorDiagnostic.Create(new RazorError(
string.Format(errorFormatMalformed, "text", CultureInfo.InvariantCulture), string.Format(errorFormatMalformed, "text", CultureInfo.InvariantCulture),
absoluteIndex: 11, lineIndex: 0, columnIndex: 11, length: 4)) absoluteIndex: 11, lineIndex: 0, columnIndex: 11, length: 4))
@ -2628,9 +2619,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
factory.Markup("text>").Accepts(AcceptedCharactersInternal.None)))), factory.Markup("text>").Accepts(AcceptedCharactersInternal.None)))),
new [] new []
{ {
RazorDiagnostic.Create(new RazorError( MissingEndTagError("text"),
string.Format(errorFormatNormalUnclosed, "text", CultureInfo.InvariantCulture),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 4))
} }
}, },
{ {
@ -2661,9 +2650,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
RazorDiagnostic.Create(new RazorError( MissingEndTagError("text"),
string.Format(errorFormatNormalUnclosed, "text", CultureInfo.InvariantCulture),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 4))
} }
}, },
{ {
@ -2683,9 +2670,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
factory.EmptyHtml()), factory.EmptyHtml()),
new [] new []
{ {
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag(
string.Format(errorFormatNormalNotStarted, "text", CultureInfo.InvariantCulture), new SourceSpan(filePath: null, absoluteIndex: 19, lineIndex: 0, characterIndex: 19, length: 4), "text"),
absoluteIndex: 19, lineIndex: 0, columnIndex: 19, length: 4)),
RazorDiagnostic.Create(new RazorError( RazorDiagnostic.Create(new RazorError(
string.Format(errorFormatMalformed, "text", CultureInfo.InvariantCulture), string.Format(errorFormatMalformed, "text", CultureInfo.InvariantCulture),
absoluteIndex: 19, lineIndex: 0, columnIndex: 19, length: 4)) absoluteIndex: 19, lineIndex: 0, columnIndex: 19, length: 4))
@ -2712,11 +2698,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
var factory = new SpanFactory(); var factory = new SpanFactory();
var blockFactory = new BlockFactory(factory); var blockFactory = new BlockFactory(factory);
var errorEOFMatchingBrace =
"End of file or an unexpected character was reached before the \"{0}\" tag could be parsed. " + RazorDiagnostic UnfinishedTagError(string tagName, int length)
"Elements inside markup blocks must be complete. They must either be self-closing " + {
"(\"<br />\") or have matching end tags (\"<p>Hello</p>\"). If you intended " + return RazorDiagnosticFactory.CreateParsing_UnfinishedTag(
"to display a \"<\" character, use the \"&lt;\" HTML entity."; new SourceSpan(filePath: null, absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: length),
tagName);
}
Func<Func<MarkupBlock>, MarkupBlock> buildPartialStatementBlock = (insideBuilder) => Func<Func<MarkupBlock>, MarkupBlock> buildPartialStatementBlock = (insideBuilder) =>
{ {
@ -2739,9 +2727,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
RazorDiagnostic.Create(new RazorError( UnfinishedTagError("!text}", 6),
string.Format(errorEOFMatchingBrace, "!text}"),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 6))
} }
}, },
{ {
@ -2756,9 +2742,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
RazorDiagnostic.Create(new RazorError( UnfinishedTagError("!text", 5),
string.Format(errorEOFMatchingBrace, "!text"),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5))
} }
}, },
{ {
@ -2783,9 +2767,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
RazorDiagnostic.Create(new RazorError( UnfinishedTagError("!text", 5),
string.Format(errorEOFMatchingBrace, "!text"),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5))
} }
}, },
{ {
@ -2810,9 +2792,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
RazorDiagnostic.Create(new RazorError( UnfinishedTagError("!text", 5),
string.Format(errorEOFMatchingBrace, "!text"),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5))
} }
}, },
{ {
@ -2840,9 +2820,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
RazorDiagnostic.Create(new RazorError( UnfinishedTagError("!text", 5),
string.Format(errorEOFMatchingBrace, "!text"),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5))
} }
}, },
{ {
@ -2871,9 +2849,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
RazorDiagnostic.Create(new RazorError( UnfinishedTagError("!text", 5),
string.Format(errorEOFMatchingBrace, "!text"),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5))
} }
} }
}; };
@ -2896,11 +2872,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
var factory = new SpanFactory(); var factory = new SpanFactory();
var blockFactory = new BlockFactory(factory); var blockFactory = new BlockFactory(factory);
var errorEOFMatchingBrace =
"End of file or an unexpected character was reached before the \"{0}\" tag could be parsed. " + RazorDiagnostic UnfinishedTagError(string tagName)
"Elements inside markup blocks must be complete. They must either be self-closing " + {
"(\"<br />\") or have matching end tags (\"<p>Hello</p>\"). If you intended " + return RazorDiagnosticFactory.CreateParsing_UnfinishedTag(
"to display a \"<\" character, use the \"&lt;\" HTML entity."; new SourceSpan(filePath: null, absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: tagName.Length),
tagName);
}
Func<Func<MarkupBlock>, MarkupBlock> buildPartialStatementBlock = (insideBuilder) => Func<Func<MarkupBlock>, MarkupBlock> buildPartialStatementBlock = (insideBuilder) =>
{ {
@ -2923,9 +2901,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
RazorDiagnostic.Create(new RazorError( UnfinishedTagError("!}"),
string.Format(errorEOFMatchingBrace, "!}"),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2))
} }
}, },
{ {
@ -2936,9 +2912,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
RazorDiagnostic.Create(new RazorError( UnfinishedTagError("!p}"),
string.Format(errorEOFMatchingBrace, "!p}"),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 3))
} }
}, },
{ {
@ -2950,9 +2924,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
RazorDiagnostic.Create(new RazorError( UnfinishedTagError("!p"),
string.Format(errorEOFMatchingBrace, "!p"),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2))
} }
}, },
{ {
@ -2977,9 +2949,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
RazorDiagnostic.Create(new RazorError( UnfinishedTagError("!p"),
string.Format(errorEOFMatchingBrace, "!p"),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2))
} }
}, },
{ {
@ -3004,9 +2974,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
RazorDiagnostic.Create(new RazorError( UnfinishedTagError("!p"),
string.Format(errorEOFMatchingBrace, "!p"),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2))
} }
}, },
{ {
@ -3038,9 +3006,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
RazorDiagnostic.Create(new RazorError( UnfinishedTagError("!p"),
string.Format(errorEOFMatchingBrace, "!p"),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2))
} }
}, },
{ {
@ -3068,9 +3034,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
RazorDiagnostic.Create(new RazorError( UnfinishedTagError("!p"),
string.Format(errorEOFMatchingBrace, "!p"),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2))
} }
}, },
{ {
@ -3100,9 +3064,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
RazorDiagnostic.Create(new RazorError( UnfinishedTagError("!p"),
string.Format(errorEOFMatchingBrace, "!p"),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2))
} }
} }
}; };
@ -3235,12 +3197,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
var errorFormatMalformed = var errorFormatMalformed =
"Found a malformed '{0}' tag helper. Tag helpers must have a start and end tag or be self " + "Found a malformed '{0}' tag helper. Tag helpers must have a start and end tag or be self " +
"closing."; "closing.";
var errorFormatNormalUnclosed =
"The \"{0}\" element was not closed. All elements must be either self-closing or have a " + RazorDiagnostic MissingEndTagError(string tagName, int index = 3)
"matching end tag."; {
var errorFormatNormalNotStarted = return RazorDiagnosticFactory.CreateParsing_MissingEndTag(
"Encountered end tag \"{0}\" with no matching start tag. Are your start/end tags properly " + new SourceSpan(filePath: null, absoluteIndex: index, lineIndex: 0, characterIndex: index, length: tagName.Length), tagName);
"balanced?"; }
Func<Func<MarkupBlock>, MarkupBlock> buildStatementBlock = (insideBuilder) => Func<Func<MarkupBlock>, MarkupBlock> buildStatementBlock = (insideBuilder) =>
{ {
@ -3272,9 +3234,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
RazorDiagnostic.Create(new RazorError( MissingEndTagError("!p"),
string.Format(errorFormatNormalUnclosed, "!p", CultureInfo.InvariantCulture),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)),
} }
}, },
{ {
@ -3284,9 +3244,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
blockFactory.EscapedMarkupTagBlock("</", "p>", AcceptedCharactersInternal.None))), blockFactory.EscapedMarkupTagBlock("</", "p>", AcceptedCharactersInternal.None))),
new [] new []
{ {
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag(
string.Format(errorFormatNormalNotStarted, "!p", CultureInfo.InvariantCulture), new SourceSpan(filePath: null, absoluteIndex: 4, lineIndex: 0, characterIndex: 4, length: 2), "!p"),
absoluteIndex: 4, lineIndex: 0, columnIndex: 4, length: 2)),
} }
}, },
{ {
@ -3314,9 +3273,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
blockFactory.MarkupTagBlock("</p>", AcceptedCharactersInternal.None))), blockFactory.MarkupTagBlock("</p>", AcceptedCharactersInternal.None))),
new [] new []
{ {
RazorDiagnostic.Create(new RazorError( MissingEndTagError("!p"),
string.Format(errorFormatNormalUnclosed, "!p", CultureInfo.InvariantCulture),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)),
RazorDiagnostic.Create(new RazorError( RazorDiagnostic.Create(new RazorError(
string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture), string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture),
absoluteIndex: 8, lineIndex: 0, columnIndex: 8, length: 1)) absoluteIndex: 8, lineIndex: 0, columnIndex: 8, length: 1))
@ -3330,9 +3287,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
blockFactory.EscapedMarkupTagBlock("</", "p>", AcceptedCharactersInternal.None)))), blockFactory.EscapedMarkupTagBlock("</", "p>", AcceptedCharactersInternal.None)))),
new [] new []
{ {
RazorDiagnostic.Create(new RazorError( MissingEndTagError("p"),
string.Format(errorFormatNormalUnclosed, "p", CultureInfo.InvariantCulture),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1)),
RazorDiagnostic.Create(new RazorError( RazorDiagnostic.Create(new RazorError(
string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture), string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1)) absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1))
@ -3363,9 +3318,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
RazorDiagnostic.Create(new RazorError( MissingEndTagError("p"),
string.Format(errorFormatNormalUnclosed, "p", CultureInfo.InvariantCulture),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1)),
RazorDiagnostic.Create(new RazorError( RazorDiagnostic.Create(new RazorError(
string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture), string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1)) absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1))
@ -3388,9 +3341,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
factory.EmptyHtml()), factory.EmptyHtml()),
new [] new []
{ {
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag(
string.Format(errorFormatNormalNotStarted, "p", CultureInfo.InvariantCulture), new SourceSpan(filePath: null, absoluteIndex: 13, lineIndex: 0, characterIndex: 13, length: 1), "p"),
absoluteIndex: 13, lineIndex: 0, columnIndex: 13, length: 1)),
RazorDiagnostic.Create(new RazorError( RazorDiagnostic.Create(new RazorError(
string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture), string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture),
absoluteIndex: 13, lineIndex: 0, columnIndex: 13, length: 1)) absoluteIndex: 13, lineIndex: 0, columnIndex: 13, length: 1))
@ -3413,15 +3365,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
factory.EmptyHtml()), factory.EmptyHtml()),
new [] new []
{ {
RazorDiagnostic.Create(new RazorError( MissingEndTagError("strong"),
string.Format(errorFormatNormalUnclosed, "strong", CultureInfo.InvariantCulture),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 6)),
RazorDiagnostic.Create(new RazorError( RazorDiagnostic.Create(new RazorError(
string.Format(errorFormatMalformed, "strong", CultureInfo.InvariantCulture), string.Format(errorFormatMalformed, "strong", CultureInfo.InvariantCulture),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 6)), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 6)),
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag(
string.Format(errorFormatNormalNotStarted, "strong", CultureInfo.InvariantCulture), new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 6), "strong"),
absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 6)),
RazorDiagnostic.Create(new RazorError( RazorDiagnostic.Create(new RazorError(
string.Format(errorFormatMalformed, "strong", CultureInfo.InvariantCulture), string.Format(errorFormatMalformed, "strong", CultureInfo.InvariantCulture),
absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 6)) absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 6))
@ -3465,24 +3414,19 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
factory.EmptyHtml()), factory.EmptyHtml()),
new [] new []
{ {
RazorDiagnostic.Create(new RazorError( MissingEndTagError("p"),
string.Format(errorFormatNormalUnclosed, "p", CultureInfo.InvariantCulture),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1)),
RazorDiagnostic.Create(new RazorError( RazorDiagnostic.Create(new RazorError(
string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture), string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1)), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1)),
RazorDiagnostic.Create(new RazorError( RazorDiagnostic.Create(new RazorError(
string.Format(errorFormatMalformed, "strong", CultureInfo.InvariantCulture), string.Format(errorFormatMalformed, "strong", CultureInfo.InvariantCulture),
absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 6)), absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 6)),
RazorDiagnostic.Create(new RazorError( MissingEndTagError("!p", index: 24),
string.Format(errorFormatNormalUnclosed, "!p", CultureInfo.InvariantCulture),
absoluteIndex: 24, lineIndex: 0, columnIndex: 24, length: 2)),
RazorDiagnostic.Create(new RazorError( RazorDiagnostic.Create(new RazorError(
string.Format(errorFormatMalformed, "strong", CultureInfo.InvariantCulture), string.Format(errorFormatMalformed, "strong", CultureInfo.InvariantCulture),
absoluteIndex: 29, lineIndex: 0, columnIndex: 29, length: 6)), absoluteIndex: 29, lineIndex: 0, columnIndex: 29, length: 6)),
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag(
string.Format(errorFormatNormalNotStarted, "!p", CultureInfo.InvariantCulture), new SourceSpan(filePath: null, absoluteIndex: 38, lineIndex: 0, characterIndex: 38, length: 2), "!p"),
absoluteIndex: 38, lineIndex: 0, columnIndex: 38, length: 2)),
} }
}, },
}; };
@ -3495,9 +3439,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
var factory = new SpanFactory(); var factory = new SpanFactory();
var blockFactory = new BlockFactory(factory); var blockFactory = new BlockFactory(factory);
var errorFormatNormalUnclosed =
"The \"{0}\" element was not closed. All elements must be either self-closing or have a " +
"matching end tag.";
Func<Func<MarkupBlock>, MarkupBlock> buildStatementBlock = (insideBuilder) => Func<Func<MarkupBlock>, MarkupBlock> buildStatementBlock = (insideBuilder) =>
{ {
@ -3544,9 +3485,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{ {
RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF(
new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"),
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_MissingEndTag(
string.Format(errorFormatNormalUnclosed, "!p"), new SourceSpan(filePath: null, absoluteIndex: 3, lineIndex: 0, characterIndex: 3, length: 2), "!p"),
absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2))
} }
}, },
{ {
@ -4261,10 +4201,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
Factory.EmptyHtml()); Factory.EmptyHtml());
var expectedErrors = new[] var expectedErrors = new[]
{ {
RazorDiagnostic.Create(new RazorError( RazorDiagnosticFactory.CreateParsing_UnexpectedEndTag(
"Encountered end tag \"div\" with no matching start tag. Are your start/end tags properly balanced?", new SourceSpan(new SourceLocation(9, 0, 9), contentLength: 3), "div"),
new SourceLocation(9, 0, 9),
3)),
}; };
RunParseTreeRewriterTest(documentContent, expectedOutput, expectedErrors); RunParseTreeRewriterTest(documentContent, expectedOutput, expectedErrors);

View File

@ -1,2 +1,2 @@
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,11): Error RZ9999: Encountered end tag "div" with no matching start tag. Are your start/end tags properly balanced? TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,11): Error RZ1026: Encountered end tag "div" with no matching start tag. Are your start/end tags properly balanced?
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,7): 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. TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,7): 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.

View File

@ -1,2 +1,2 @@
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,11): Error RZ9999: Encountered end tag "div" with no matching start tag. Are your start/end tags properly balanced? TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,11): Error RZ1026: Encountered end tag "div" with no matching start tag. Are your start/end tags properly balanced?
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,7): 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. TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,7): 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.

View File

@ -1,3 +1,3 @@
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(4,3): Error RZ9999: Encountered end tag "body" with no matching start tag. Are your start/end tags properly balanced? TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(4,3): Error RZ1026: Encountered end tag "body" with no matching start tag. Are your start/end tags properly balanced?
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(5,3): Error RZ9999: Encountered end tag "html" with no matching start tag. Are your start/end tags properly balanced? TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(5,3): Error RZ1026: Encountered end tag "html" with no matching start tag. Are your start/end tags properly balanced?
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(3,2): 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. TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(3,2): 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.

View File

@ -1,3 +1,3 @@
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(4,3): Error RZ9999: Encountered end tag "body" with no matching start tag. Are your start/end tags properly balanced? TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(4,3): Error RZ1026: Encountered end tag "body" with no matching start tag. Are your start/end tags properly balanced?
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(5,3): Error RZ9999: Encountered end tag "html" with no matching start tag. Are your start/end tags properly balanced? TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(5,3): Error RZ1026: Encountered end tag "html" with no matching start tag. Are your start/end tags properly balanced?
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(3,2): 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. TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(3,2): 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.