Handle single line directives properly
This commit is contained in:
parent
d293547f24
commit
02675da467
|
|
@ -1568,6 +1568,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
|
|||
{
|
||||
case DirectiveDescriptorKind.SingleLine:
|
||||
Optional(CSharpSymbolType.Semicolon);
|
||||
AcceptWhile(IsSpacingToken(includeNewLines: false, includeComments: true));
|
||||
|
||||
if (At(CSharpSymbolType.NewLine))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -218,6 +218,27 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
|
|||
expectedErorr);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DirectiveDescriptor_NoErrorsSemicolonAfterDirective()
|
||||
{
|
||||
// Arrange
|
||||
var descriptor = DirectiveDescriptorBuilder.Create("custom").AddString().Build();
|
||||
|
||||
// Act & Assert
|
||||
ParseCodeBlockTest(
|
||||
"@custom hello ; ",
|
||||
new[] { descriptor },
|
||||
new DirectiveBlock(
|
||||
new DirectiveChunkGenerator(descriptor),
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("custom").Accepts(AcceptedCharacters.None),
|
||||
Factory.Span(SpanKind.Markup, " ", markup: false).Accepts(AcceptedCharacters.WhiteSpace),
|
||||
Factory.Span(SpanKind.Markup, "hello", markup: false)
|
||||
.With(new DirectiveTokenChunkGenerator(descriptor.Tokens[0]))
|
||||
.Accepts(AcceptedCharacters.NonWhiteSpace),
|
||||
Factory.Span(SpanKind.Markup, " ; ", markup: false).Accepts(AcceptedCharacters.WhiteSpace)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DirectiveDescriptor_ErrorsExtraContentAfterDirective()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue