[Fixes #698] Removed unnecessary Debug.Assert in TagHelperBlockRewriter

This commit is contained in:
Ajay Bhargav Baaskaran 2016-02-25 16:08:44 -08:00
parent 23e7d85ccf
commit 32c75fc78e
2 changed files with 22 additions and 5 deletions

View File

@ -105,6 +105,11 @@ namespace Microsoft.AspNetCore.Razor.Parser.TagHelpers.Internal
attributes.Add(
new KeyValuePair<string, SyntaxTreeNode>(result.AttributeName, result.AttributeValueNode));
}
else
{
// Error occured while parsing the attribute. Don't try parsing the rest to avoid misleading errors.
break;
}
}
return attributes;
@ -205,10 +210,6 @@ namespace Microsoft.AspNetCore.Razor.Parser.TagHelpers.Internal
}
else if (symbol.Type == HtmlSymbolType.Equals)
{
Debug.Assert(
name != null,
"Name should never be null here. The parser should guarantee an attribute has a name.");
// We've captured all leading whitespace and the attribute name.
// We're now at: " asp-for|='...'" or " asp-for|=..."
// The goal here is to consume the equal sign and the optional single/double-quote.

View File

@ -757,7 +757,23 @@ namespace Microsoft.AspNetCore.Razor.Compilation.TagHelpers
RazorResources.FormatParseError_UnexpectedEndTag("p"),
absoluteIndex: 31, lineIndex: 0, columnIndex: 31, length: 1)
}
}
},
{
"<p class=some=thing attr=\"@value\"></p>",
new MarkupBlock(
new MarkupTagHelperBlock("p",
new List<KeyValuePair<string, SyntaxTreeNode>>
{
new KeyValuePair<string, SyntaxTreeNode>("class", factory.Markup("some"))
})),
new []
{
new RazorError(
"TagHelper attributes must be well-formed.",
new SourceLocation(13, 0, 13),
length: 13)
}
},
};
}
}