Moved the test infrastructure to depend on RazorDiagnostic instead of RazorError
This commit is contained in:
parent
7234850c9a
commit
8fcb046345
|
|
@ -71,11 +71,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.AsStatement()
|
.AsStatement()
|
||||||
.With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" })
|
.With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" })
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(
|
||||||
LegacyResources.BlockName_Code, "}", "{"),
|
LegacyResources.BlockName_Code, "}", "{"),
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -152,11 +152,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.Span(SpanKindInternal.Code, new CSharpSymbol(string.Empty, CSharpSymbolType.Unknown))
|
Factory.Span(SpanKindInternal.Code, new CSharpSymbol(string.Empty, CSharpSymbolType.Unknown))
|
||||||
.With(new StatementChunkGenerator())
|
.With(new StatementChunkGenerator())
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(
|
||||||
LegacyResources.BlockName_Code, "}", "{"),
|
LegacyResources.BlockName_Code, "}", "{"),
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -148,10 +148,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
ImplicitExpressionTest(
|
ImplicitExpressionTest(
|
||||||
"Html.En(code()", "Html.En(code()",
|
"Html.En(code()", "Html.En(code()",
|
||||||
AcceptedCharactersInternal.Any,
|
AcceptedCharactersInternal.Any,
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
||||||
new SourceLocation(8, 0, 8),
|
new SourceLocation(8, 0, 8),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -499,10 +499,10 @@ while(true);", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedChara
|
||||||
document,
|
document,
|
||||||
BlockKindInternal.Statement,
|
BlockKindInternal.Statement,
|
||||||
SpanKindInternal.Code,
|
SpanKindInternal.Code,
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'),
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'),
|
||||||
SourceLocation.Zero,
|
SourceLocation.Zero,
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -514,14 +514,14 @@ while(true);", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedChara
|
||||||
document,
|
document,
|
||||||
BlockKindInternal.Statement,
|
BlockKindInternal.Statement,
|
||||||
SpanKindInternal.Code,
|
SpanKindInternal.Code,
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_BlockComment_Not_Terminated,
|
LegacyResources.ParseError_BlockComment_Not_Terminated,
|
||||||
new SourceLocation(24, 0, 24),
|
new SourceLocation(24, 0, 24),
|
||||||
length: 1),
|
length: 1)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'),
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'),
|
||||||
SourceLocation.Zero,
|
SourceLocation.Zero,
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -533,10 +533,10 @@ while(true);", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedChara
|
||||||
document,
|
document,
|
||||||
BlockKindInternal.Statement,
|
BlockKindInternal.Statement,
|
||||||
SpanKindInternal.Code,
|
SpanKindInternal.Code,
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'),
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'),
|
||||||
SourceLocation.Zero,
|
SourceLocation.Zero,
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -1151,16 +1151,16 @@ catch(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code);
|
||||||
Factory.Markup("@").With(new LiteralAttributeChunkGenerator(new LocationTagged<string>(string.Empty, 12, 0, 12), new LocationTagged<string>("@", 12, 0, 12))).Accepts(AcceptedCharactersInternal.None),
|
Factory.Markup("@").With(new LiteralAttributeChunkGenerator(new LocationTagged<string>(string.Empty, 12, 0, 12), new LocationTagged<string>("@", 12, 0, 12))).Accepts(AcceptedCharactersInternal.None),
|
||||||
Factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)))),
|
Factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)))),
|
||||||
Factory.EmptyHtml()));
|
Factory.EmptyHtml()));
|
||||||
var expectedErrors = new RazorError[]
|
var expectedErrors = new RazorDiagnostic[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
@"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 ""<"" HTML entity.",
|
@"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 ""<"" HTML entity.",
|
||||||
new SourceLocation(2, 0, 2),
|
new SourceLocation(2, 0, 2),
|
||||||
length: 4),
|
length: 4)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
@"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.",
|
@"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.",
|
||||||
SourceLocation.Zero,
|
SourceLocation.Zero,
|
||||||
length: 1),
|
length: 1)),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
|
|
@ -1194,16 +1194,16 @@ catch(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code);
|
||||||
Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None))),
|
Factory.Markup(" />").Accepts(AcceptedCharactersInternal.None))),
|
||||||
Factory.EmptyCSharp().AsStatement(),
|
Factory.EmptyCSharp().AsStatement(),
|
||||||
Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None));
|
Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None));
|
||||||
var expectedErrors = new RazorError[]
|
var expectedErrors = new RazorDiagnostic[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
@"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.",
|
@"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.",
|
||||||
new SourceLocation(13, 0, 13),
|
new SourceLocation(13, 0, 13),
|
||||||
length: 1),
|
length: 1)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
@"""' />}"" is not valid at the start of a code block. Only identifiers, keywords, comments, ""("" and ""{"" are valid.",
|
@"""' />}"" is not valid at the start of a code block. Only identifiers, keywords, comments, ""("" and ""{"" are valid.",
|
||||||
new SourceLocation(15, 0, 15),
|
new SourceLocation(15, 0, 15),
|
||||||
length: 5),
|
length: 5)),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
|
|
@ -1253,12 +1253,12 @@ catch(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code);
|
||||||
|
|
||||||
private void NamespaceImportTest(string content, string expectedNS, AcceptedCharactersInternal acceptedCharacters = AcceptedCharactersInternal.None, string errorMessage = null, SourceLocation? location = null)
|
private void NamespaceImportTest(string content, string expectedNS, AcceptedCharactersInternal acceptedCharacters = AcceptedCharactersInternal.None, string errorMessage = null, SourceLocation? location = null)
|
||||||
{
|
{
|
||||||
var errors = new RazorError[0];
|
var errors = new RazorDiagnostic[0];
|
||||||
if (!string.IsNullOrEmpty(errorMessage) && location.HasValue)
|
if (!string.IsNullOrEmpty(errorMessage) && location.HasValue)
|
||||||
{
|
{
|
||||||
errors = new RazorError[]
|
errors = new RazorDiagnostic[]
|
||||||
{
|
{
|
||||||
new RazorError(errorMessage, location.Value, length: 1)
|
RazorDiagnostic.Create(new RazorError(errorMessage, location.Value, length: 1))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
ParseBlockTest(content,
|
ParseBlockTest(content,
|
||||||
|
|
|
||||||
|
|
@ -386,7 +386,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
"*, Foo",
|
"*, Foo",
|
||||||
"*",
|
"*",
|
||||||
"Foo",
|
"Foo",
|
||||||
new RazorError(Resources.FormatDirectiveMustAppearAtStartOfLine("addTagHelper"), new SourceLocation(4, 0, 4), 12))),
|
RazorDiagnostic.Create(new RazorError(Resources.FormatDirectiveMustAppearAtStartOfLine("addTagHelper"), new SourceLocation(4, 0, 4), 12)))),
|
||||||
Factory.Code(Environment.NewLine).AsStatement(),
|
Factory.Code(Environment.NewLine).AsStatement(),
|
||||||
Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)));
|
Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)));
|
||||||
}
|
}
|
||||||
|
|
@ -1068,9 +1068,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
public void TagHelperPrefixDirective_RequiresValue()
|
public void TagHelperPrefixDirective_RequiresValue()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedError = new RazorError(
|
var expectedError = RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_DirectiveMustHaveValue(SyntaxConstants.CSharp.TagHelperPrefixKeyword),
|
LegacyResources.FormatParseError_DirectiveMustHaveValue(SyntaxConstants.CSharp.TagHelperPrefixKeyword),
|
||||||
absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 15);
|
absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 15));
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ParseBlockTest("@tagHelperPrefix ",
|
ParseBlockTest("@tagHelperPrefix ",
|
||||||
|
|
@ -1093,15 +1093,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedErrors = new[]
|
var expectedErrors = new[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_Unterminated_String_Literal,
|
LegacyResources.ParseError_Unterminated_String_Literal,
|
||||||
absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 1),
|
absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 1)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.TagHelperPrefixKeyword),
|
LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.TagHelperPrefixKeyword),
|
||||||
absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 4),
|
absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 4)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
Resources.FormatInvalidTagHelperPrefixValue(SyntaxConstants.CSharp.TagHelperPrefixKeyword, '"', "\"Foo"),
|
Resources.FormatInvalidTagHelperPrefixValue(SyntaxConstants.CSharp.TagHelperPrefixKeyword, '"', "\"Foo"),
|
||||||
absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 4)
|
absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 4))
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
|
|
@ -1124,15 +1124,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedErrors = new[]
|
var expectedErrors = new[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_Unterminated_String_Literal,
|
LegacyResources.ParseError_Unterminated_String_Literal,
|
||||||
absoluteIndex: 23, lineIndex: 0, columnIndex: 23, length: 1),
|
absoluteIndex: 23, lineIndex: 0, columnIndex: 23, length: 1)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.TagHelperPrefixKeyword),
|
LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.TagHelperPrefixKeyword),
|
||||||
absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 7),
|
absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 7)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
Resources.FormatInvalidTagHelperPrefixValue(SyntaxConstants.CSharp.TagHelperPrefixKeyword, ' ', "Foo \""),
|
Resources.FormatInvalidTagHelperPrefixValue(SyntaxConstants.CSharp.TagHelperPrefixKeyword, ' ', "Foo \""),
|
||||||
absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 7)
|
absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 7))
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
|
|
@ -1154,10 +1154,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
{
|
{
|
||||||
var expectedErrors = new[]
|
var expectedErrors = new[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
Resources.FormatInvalidTagHelperLookupText(string.Empty),
|
Resources.FormatInvalidTagHelperLookupText(string.Empty),
|
||||||
new SourceLocation(18, 0, 18),
|
new SourceLocation(18, 0, 18),
|
||||||
length: 1)
|
length: 1))
|
||||||
};
|
};
|
||||||
|
|
||||||
ParseBlockTest("@removeTagHelper \"\"",
|
ParseBlockTest("@removeTagHelper \"\"",
|
||||||
|
|
@ -1173,7 +1173,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.AsRemoveTagHelper(
|
.AsRemoveTagHelper(
|
||||||
"\"\"",
|
"\"\"",
|
||||||
string.Empty,
|
string.Empty,
|
||||||
legacyErrors: expectedErrors)));
|
errors: expectedErrors)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -1181,10 +1181,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
{
|
{
|
||||||
var expectedErrors = new[]
|
var expectedErrors = new[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
Resources.FormatInvalidTagHelperLookupText("Foo"),
|
Resources.FormatInvalidTagHelperLookupText("Foo"),
|
||||||
new SourceLocation(17, 0, 17),
|
new SourceLocation(17, 0, 17),
|
||||||
length: 3)
|
length: 3))
|
||||||
};
|
};
|
||||||
|
|
||||||
ParseBlockTest("@removeTagHelper Foo",
|
ParseBlockTest("@removeTagHelper Foo",
|
||||||
|
|
@ -1200,7 +1200,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.AsRemoveTagHelper(
|
.AsRemoveTagHelper(
|
||||||
"Foo",
|
"Foo",
|
||||||
"Foo",
|
"Foo",
|
||||||
legacyErrors: expectedErrors)));
|
errors: expectedErrors)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -1208,10 +1208,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
{
|
{
|
||||||
var expectedErrors = new[]
|
var expectedErrors = new[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
Resources.FormatInvalidTagHelperLookupText("'*, Foo'"),
|
Resources.FormatInvalidTagHelperLookupText("'*, Foo'"),
|
||||||
new SourceLocation(17, 0, 17),
|
new SourceLocation(17, 0, 17),
|
||||||
length: 8)
|
length: 8))
|
||||||
};
|
};
|
||||||
|
|
||||||
ParseBlockTest("@removeTagHelper '*, Foo'",
|
ParseBlockTest("@removeTagHelper '*, Foo'",
|
||||||
|
|
@ -1225,7 +1225,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.AsRemoveTagHelper(
|
.AsRemoveTagHelper(
|
||||||
"'*, Foo'",
|
"'*, Foo'",
|
||||||
"'*, Foo'",
|
"'*, Foo'",
|
||||||
legacyErrors: expectedErrors)));
|
errors: expectedErrors)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -1233,10 +1233,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
{
|
{
|
||||||
var expectedErrors = new[]
|
var expectedErrors = new[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
Resources.FormatInvalidTagHelperLookupText("Foo"),
|
Resources.FormatInvalidTagHelperLookupText("Foo"),
|
||||||
new SourceLocation(18, 0, 18),
|
new SourceLocation(18, 0, 18),
|
||||||
length: 3)
|
length: 3))
|
||||||
};
|
};
|
||||||
|
|
||||||
ParseBlockTest("@removeTagHelper \"Foo\"",
|
ParseBlockTest("@removeTagHelper \"Foo\"",
|
||||||
|
|
@ -1252,7 +1252,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.AsRemoveTagHelper(
|
.AsRemoveTagHelper(
|
||||||
"\"Foo\"",
|
"\"Foo\"",
|
||||||
"Foo",
|
"Foo",
|
||||||
legacyErrors: expectedErrors)));
|
errors: expectedErrors)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -1280,13 +1280,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedErrors = new[]
|
var expectedErrors = new[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_DirectiveMustHaveValue(SyntaxConstants.CSharp.RemoveTagHelperKeyword),
|
LegacyResources.FormatParseError_DirectiveMustHaveValue(SyntaxConstants.CSharp.RemoveTagHelperKeyword),
|
||||||
absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 15),
|
absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 15)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
Resources.FormatInvalidTagHelperLookupText(string.Empty),
|
Resources.FormatInvalidTagHelperLookupText(string.Empty),
|
||||||
new SourceLocation(17, 0, 17),
|
new SourceLocation(17, 0, 17),
|
||||||
length: 1),
|
length: 1)),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
|
|
@ -1298,7 +1298,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.Span(SpanKindInternal.Markup, " ", markup: false)
|
Factory.Span(SpanKindInternal.Markup, " ", markup: false)
|
||||||
.Accepts(AcceptedCharactersInternal.None),
|
.Accepts(AcceptedCharactersInternal.None),
|
||||||
Factory.EmptyCSharp()
|
Factory.EmptyCSharp()
|
||||||
.AsRemoveTagHelper(string.Empty, string.Empty, legacyErrors: expectedErrors)
|
.AsRemoveTagHelper(string.Empty, string.Empty, errors: expectedErrors)
|
||||||
.Accepts(AcceptedCharactersInternal.AnyExceptNewline)));
|
.Accepts(AcceptedCharactersInternal.AnyExceptNewline)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1308,16 +1308,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedErrors = new[]
|
var expectedErrors = new[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_Unterminated_String_Literal,
|
LegacyResources.ParseError_Unterminated_String_Literal,
|
||||||
absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 1),
|
absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 1)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.RemoveTagHelperKeyword),
|
LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.RemoveTagHelperKeyword),
|
||||||
absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 4),
|
absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 4)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
Resources.FormatInvalidTagHelperLookupText("\"Foo"),
|
Resources.FormatInvalidTagHelperLookupText("\"Foo"),
|
||||||
new SourceLocation(17, 0, 17),
|
new SourceLocation(17, 0, 17),
|
||||||
length: 4),
|
length: 4)),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
|
|
@ -1331,7 +1331,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.Span(SpanKindInternal.Markup, " ", markup: false)
|
.Span(SpanKindInternal.Markup, " ", markup: false)
|
||||||
.Accepts(AcceptedCharactersInternal.None),
|
.Accepts(AcceptedCharactersInternal.None),
|
||||||
Factory.Code("\"Foo")
|
Factory.Code("\"Foo")
|
||||||
.AsRemoveTagHelper("\"Foo", "\"Foo", legacyErrors: expectedErrors)));
|
.AsRemoveTagHelper("\"Foo", "\"Foo", errors: expectedErrors)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -1340,16 +1340,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedErrors = new[]
|
var expectedErrors = new[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_Unterminated_String_Literal,
|
LegacyResources.ParseError_Unterminated_String_Literal,
|
||||||
absoluteIndex: 20, lineIndex: 0, columnIndex: 20, length: 1),
|
absoluteIndex: 20, lineIndex: 0, columnIndex: 20, length: 1)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.RemoveTagHelperKeyword),
|
LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.RemoveTagHelperKeyword),
|
||||||
absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 4),
|
absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 4)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
Resources.FormatInvalidTagHelperLookupText("Foo\""),
|
Resources.FormatInvalidTagHelperLookupText("Foo\""),
|
||||||
new SourceLocation(17, 0, 17),
|
new SourceLocation(17, 0, 17),
|
||||||
length: 4),
|
length: 4)),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
|
|
@ -1363,7 +1363,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.Span(SpanKindInternal.Markup, " ", markup: false)
|
.Span(SpanKindInternal.Markup, " ", markup: false)
|
||||||
.Accepts(AcceptedCharactersInternal.None),
|
.Accepts(AcceptedCharactersInternal.None),
|
||||||
Factory.Code("Foo\"")
|
Factory.Code("Foo\"")
|
||||||
.AsRemoveTagHelper("Foo\"", "Foo\"", legacyErrors: expectedErrors)
|
.AsRemoveTagHelper("Foo\"", "Foo\"", errors: expectedErrors)
|
||||||
.Accepts(AcceptedCharactersInternal.AnyExceptNewline)));
|
.Accepts(AcceptedCharactersInternal.AnyExceptNewline)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1372,10 +1372,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
{
|
{
|
||||||
var expectedErrors = new[]
|
var expectedErrors = new[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
Resources.FormatInvalidTagHelperLookupText(string.Empty),
|
Resources.FormatInvalidTagHelperLookupText(string.Empty),
|
||||||
new SourceLocation(15, 0, 15),
|
new SourceLocation(15, 0, 15),
|
||||||
length: 1)
|
length: 1))
|
||||||
};
|
};
|
||||||
|
|
||||||
ParseBlockTest("@addTagHelper \"\"",
|
ParseBlockTest("@addTagHelper \"\"",
|
||||||
|
|
@ -1391,7 +1391,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.AsAddTagHelper(
|
.AsAddTagHelper(
|
||||||
"\"\"",
|
"\"\"",
|
||||||
string.Empty,
|
string.Empty,
|
||||||
legacyErrors: expectedErrors)));
|
errors: expectedErrors)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -1399,10 +1399,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
{
|
{
|
||||||
var expectedErrors = new[]
|
var expectedErrors = new[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
Resources.FormatInvalidTagHelperLookupText("Foo"),
|
Resources.FormatInvalidTagHelperLookupText("Foo"),
|
||||||
new SourceLocation(14, 0, 14),
|
new SourceLocation(14, 0, 14),
|
||||||
length: 3)
|
length: 3))
|
||||||
};
|
};
|
||||||
|
|
||||||
ParseBlockTest("@addTagHelper Foo",
|
ParseBlockTest("@addTagHelper Foo",
|
||||||
|
|
@ -1416,7 +1416,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.AsAddTagHelper(
|
.AsAddTagHelper(
|
||||||
"Foo",
|
"Foo",
|
||||||
"Foo",
|
"Foo",
|
||||||
legacyErrors: expectedErrors)));
|
errors: expectedErrors)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -1424,10 +1424,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
{
|
{
|
||||||
var expectedErrors = new[]
|
var expectedErrors = new[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
Resources.FormatInvalidTagHelperLookupText("Foo"),
|
Resources.FormatInvalidTagHelperLookupText("Foo"),
|
||||||
new SourceLocation(15, 0, 15),
|
new SourceLocation(15, 0, 15),
|
||||||
length: 3)
|
length: 3))
|
||||||
};
|
};
|
||||||
|
|
||||||
ParseBlockTest("@addTagHelper \"Foo\"",
|
ParseBlockTest("@addTagHelper \"Foo\"",
|
||||||
|
|
@ -1443,7 +1443,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.AsAddTagHelper(
|
.AsAddTagHelper(
|
||||||
"\"Foo\"",
|
"\"Foo\"",
|
||||||
"Foo",
|
"Foo",
|
||||||
legacyErrors: expectedErrors)));
|
errors: expectedErrors)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -1451,10 +1451,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
{
|
{
|
||||||
var expectedErrors = new[]
|
var expectedErrors = new[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
Resources.FormatInvalidTagHelperLookupText("'*, Foo'"),
|
Resources.FormatInvalidTagHelperLookupText("'*, Foo'"),
|
||||||
new SourceLocation(14, 0, 14),
|
new SourceLocation(14, 0, 14),
|
||||||
length: 8)
|
length: 8))
|
||||||
};
|
};
|
||||||
|
|
||||||
ParseBlockTest("@addTagHelper '*, Foo'",
|
ParseBlockTest("@addTagHelper '*, Foo'",
|
||||||
|
|
@ -1468,7 +1468,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.AsAddTagHelper(
|
.AsAddTagHelper(
|
||||||
"'*, Foo'",
|
"'*, Foo'",
|
||||||
"'*, Foo'",
|
"'*, Foo'",
|
||||||
legacyErrors: expectedErrors)));
|
errors: expectedErrors)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -1498,13 +1498,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedErrors = new[]
|
var expectedErrors = new[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_DirectiveMustHaveValue(SyntaxConstants.CSharp.AddTagHelperKeyword),
|
LegacyResources.FormatParseError_DirectiveMustHaveValue(SyntaxConstants.CSharp.AddTagHelperKeyword),
|
||||||
absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 12),
|
absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 12)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
Resources.FormatInvalidTagHelperLookupText(string.Empty),
|
Resources.FormatInvalidTagHelperLookupText(string.Empty),
|
||||||
new SourceLocation(14, 0, 14),
|
new SourceLocation(14, 0, 14),
|
||||||
length: 1),
|
length: 1)),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
|
|
@ -1518,7 +1518,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.Span(SpanKindInternal.Markup, " ", markup: false)
|
.Span(SpanKindInternal.Markup, " ", markup: false)
|
||||||
.Accepts(AcceptedCharactersInternal.None),
|
.Accepts(AcceptedCharactersInternal.None),
|
||||||
Factory.EmptyCSharp()
|
Factory.EmptyCSharp()
|
||||||
.AsAddTagHelper(string.Empty, string.Empty, legacyErrors: expectedErrors)
|
.AsAddTagHelper(string.Empty, string.Empty, errors: expectedErrors)
|
||||||
.Accepts(AcceptedCharactersInternal.AnyExceptNewline)));
|
.Accepts(AcceptedCharactersInternal.AnyExceptNewline)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1528,16 +1528,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedErrors = new[]
|
var expectedErrors = new[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_Unterminated_String_Literal,
|
LegacyResources.ParseError_Unterminated_String_Literal,
|
||||||
absoluteIndex: 14, lineIndex: 0, columnIndex: 14, length: 1),
|
absoluteIndex: 14, lineIndex: 0, columnIndex: 14, length: 1)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.AddTagHelperKeyword),
|
LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.AddTagHelperKeyword),
|
||||||
absoluteIndex: 14, lineIndex: 0, columnIndex: 14, length: 4),
|
absoluteIndex: 14, lineIndex: 0, columnIndex: 14, length: 4)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
Resources.FormatInvalidTagHelperLookupText("\"Foo"),
|
Resources.FormatInvalidTagHelperLookupText("\"Foo"),
|
||||||
new SourceLocation(14, 0, 14),
|
new SourceLocation(14, 0, 14),
|
||||||
length: 4),
|
length: 4)),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
|
|
@ -1551,7 +1551,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.Span(SpanKindInternal.Markup, " ", markup: false)
|
.Span(SpanKindInternal.Markup, " ", markup: false)
|
||||||
.Accepts(AcceptedCharactersInternal.None),
|
.Accepts(AcceptedCharactersInternal.None),
|
||||||
Factory.Code("\"Foo")
|
Factory.Code("\"Foo")
|
||||||
.AsAddTagHelper("\"Foo", "\"Foo", legacyErrors: expectedErrors)));
|
.AsAddTagHelper("\"Foo", "\"Foo", errors: expectedErrors)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -1560,16 +1560,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedErrors = new[]
|
var expectedErrors = new[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_Unterminated_String_Literal,
|
LegacyResources.ParseError_Unterminated_String_Literal,
|
||||||
absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 1),
|
absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 1)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.AddTagHelperKeyword),
|
LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.AddTagHelperKeyword),
|
||||||
absoluteIndex: 14, lineIndex: 0, columnIndex: 14, length: 4),
|
absoluteIndex: 14, lineIndex: 0, columnIndex: 14, length: 4)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
Resources.FormatInvalidTagHelperLookupText("Foo\""),
|
Resources.FormatInvalidTagHelperLookupText("Foo\""),
|
||||||
new SourceLocation(14, 0, 14),
|
new SourceLocation(14, 0, 14),
|
||||||
length: 4),
|
length: 4)),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
|
|
@ -1583,7 +1583,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.Span(SpanKindInternal.Markup, " ", markup: false)
|
.Span(SpanKindInternal.Markup, " ", markup: false)
|
||||||
.Accepts(AcceptedCharactersInternal.None),
|
.Accepts(AcceptedCharactersInternal.None),
|
||||||
Factory.Code("Foo\"")
|
Factory.Code("Foo\"")
|
||||||
.AsAddTagHelper("Foo\"", "Foo\"", legacyErrors: expectedErrors)
|
.AsAddTagHelper("Foo\"", "Foo\"", errors: expectedErrors)
|
||||||
.Accepts(AcceptedCharactersInternal.AnyExceptNewline)));
|
.Accepts(AcceptedCharactersInternal.AnyExceptNewline)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.AsImplicitExpression(KeywordSet)
|
.AsImplicitExpression(KeywordSet)
|
||||||
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)
|
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS('"'),
|
LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS('"'),
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -34,10 +34,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.Code("helper")
|
Factory.Code("helper")
|
||||||
.AsImplicitExpression(KeywordSet)
|
.AsImplicitExpression(KeywordSet)
|
||||||
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_HelperDirectiveNotAvailable(SyntaxConstants.CSharp.HelperKeyword),
|
LegacyResources.FormatParseError_HelperDirectiveNotAvailable(SyntaxConstants.CSharp.HelperKeyword),
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 6));
|
length: 6)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -60,10 +60,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.AsStatement()
|
.AsStatement()
|
||||||
.With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" })
|
.With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" })
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_Code, "}", "{"),
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_Code, "}", "{"),
|
||||||
SourceLocation.Zero,
|
SourceLocation.Zero,
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -88,10 +88,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.EmptyCSharp()
|
Factory.EmptyCSharp()
|
||||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||||
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS,
|
LegacyResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS,
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
Environment.NewLine.Length));
|
Environment.NewLine.Length)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -113,10 +113,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.Code(" {}" + Environment.NewLine).AsStatement(),
|
Factory.Code(" {}" + Environment.NewLine).AsStatement(),
|
||||||
Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)
|
Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS,
|
LegacyResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS,
|
||||||
new SourceLocation(6 + Environment.NewLine.Length, 1, 5),
|
new SourceLocation(6 + Environment.NewLine.Length, 1, 5),
|
||||||
length: 3));
|
length: 3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -136,13 +136,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
||||||
Factory.EmptyCSharp().AsStatement()
|
Factory.EmptyCSharp().AsStatement()
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock,
|
LegacyResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock,
|
||||||
6 + Environment.NewLine.Length, 1, 5, length: 1),
|
6 + Environment.NewLine.Length, 1, 5, length: 1)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_Code, "}", "{"),
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_Code, "}", "{"),
|
||||||
SourceLocation.Zero,
|
SourceLocation.Zero,
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -154,10 +154,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.EmptyCSharp()
|
Factory.EmptyCSharp()
|
||||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||||
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("!"),
|
LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("!"),
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -169,10 +169,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None),
|
Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None),
|
||||||
Factory.Code($"foo bar{Environment.NewLine}baz").AsExpression()
|
Factory.Code($"foo bar{Environment.NewLine}baz").AsExpression()
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_ExplicitExpression, ')', '('),
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_ExplicitExpression, ')', '('),
|
||||||
SourceLocation.Zero,
|
SourceLocation.Zero,
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -186,10 +186,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None),
|
Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None),
|
||||||
Factory.Code($"foo bar{Environment.NewLine}").AsExpression()
|
Factory.Code($"foo bar{Environment.NewLine}").AsExpression()
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_ExplicitExpression, ')', '('),
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_ExplicitExpression, ')', '('),
|
||||||
SourceLocation.Zero,
|
SourceLocation.Zero,
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -201,10 +201,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.Code("Href(" + Environment.NewLine)
|
Factory.Code("Href(" + Environment.NewLine)
|
||||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
||||||
new SourceLocation(4, 0, 4),
|
new SourceLocation(4, 0, 4),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -218,10 +218,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.Code($"Foo(Bar(Baz){Environment.NewLine}Biz{Environment.NewLine}Boz")
|
Factory.Code($"Foo(Bar(Baz){Environment.NewLine}Biz{Environment.NewLine}Boz")
|
||||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
||||||
new SourceLocation(3, 0, 3),
|
new SourceLocation(3, 0, 3),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -237,10 +237,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.Code($"Foo(Bar(Baz){Environment.NewLine}Biz{Environment.NewLine}")
|
Factory.Code($"Foo(Bar(Baz){Environment.NewLine}Biz{Environment.NewLine}")
|
||||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
||||||
new SourceLocation(3, 0, 3),
|
new SourceLocation(3, 0, 3),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -254,10 +254,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.Code($"Foo[Bar[Baz]{Environment.NewLine}Biz{Environment.NewLine}Boz")
|
Factory.Code($"Foo[Bar[Baz]{Environment.NewLine}Biz{Environment.NewLine}Boz")
|
||||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("[", "]"),
|
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("[", "]"),
|
||||||
new SourceLocation(3, 0, 3),
|
new SourceLocation(3, 0, 3),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -273,10 +273,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.Code($"Foo[Bar[Baz]{Environment.NewLine}Biz{Environment.NewLine}")
|
Factory.Code($"Foo[Bar[Baz]{Environment.NewLine}Biz{Environment.NewLine}")
|
||||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("[", "]"),
|
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("[", "]"),
|
||||||
new SourceLocation(3, 0, 3),
|
new SourceLocation(3, 0, 3),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple EOF handling errors:
|
// Simple EOF handling errors:
|
||||||
|
|
@ -289,11 +289,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.Code(" var foo = bar; if(foo != null) { bar(); } ")
|
Factory.Code(" var foo = bar; if(foo != null) { bar(); } ")
|
||||||
.AsStatement()
|
.AsStatement()
|
||||||
.AutoCompleteWith("}")),
|
.AutoCompleteWith("}")),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(
|
||||||
LegacyResources.BlockName_Code, '}', '{'),
|
LegacyResources.BlockName_Code, '}', '{'),
|
||||||
SourceLocation.Zero,
|
SourceLocation.Zero,
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -302,8 +302,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
// Arrange
|
// Arrange
|
||||||
var chunkGenerator = new DirectiveChunkGenerator(FunctionsDirective.Directive);
|
var chunkGenerator = new DirectiveChunkGenerator(FunctionsDirective.Directive);
|
||||||
chunkGenerator.Diagnostics.Add(
|
chunkGenerator.Diagnostics.Add(
|
||||||
RazorDiagnostic.Create(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
new RazorError(
|
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("functions", '}', '{'),
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("functions", '}', '{'),
|
||||||
new SourceLocation(10, 0, 10),
|
new SourceLocation(10, 0, 10),
|
||||||
length: 1)));
|
length: 1)));
|
||||||
|
|
@ -332,10 +331,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
new StatementBlock(
|
new StatementBlock(
|
||||||
Factory.Code("if(foo) { baz(); } else { var foo = bar; if(foo != null) { bar(); } ").AsStatement()
|
Factory.Code("if(foo) { baz(); } else { var foo = bar; if(foo != null) { bar(); } ").AsStatement()
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("else", '}', '{'),
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("else", '}', '{'),
|
||||||
new SourceLocation(19, 0, 19),
|
new SourceLocation(19, 0, 19),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -345,10 +344,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
new StatementBlock(
|
new StatementBlock(
|
||||||
Factory.Code("if(foo) { baz(); } else if { var foo = bar; if(foo != null) { bar(); } ").AsStatement()
|
Factory.Code("if(foo) { baz(); } else if { var foo = bar; if(foo != null) { bar(); } ").AsStatement()
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("else if", '}', '{'),
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("else if", '}', '{'),
|
||||||
new SourceLocation(19, 0, 19),
|
new SourceLocation(19, 0, 19),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -358,10 +357,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
new StatementBlock(
|
new StatementBlock(
|
||||||
Factory.Code("do { var foo = bar; if(foo != null) { bar(); } ").AsStatement()
|
Factory.Code("do { var foo = bar; if(foo != null) { bar(); } ").AsStatement()
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("do", '}', '{'),
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("do", '}', '{'),
|
||||||
SourceLocation.Zero,
|
SourceLocation.Zero,
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -371,10 +370,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
new StatementBlock(
|
new StatementBlock(
|
||||||
Factory.Code("try { var foo = bar; if(foo != null) { bar(); } ").AsStatement()
|
Factory.Code("try { var foo = bar; if(foo != null) { bar(); } ").AsStatement()
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("try", '}', '{'),
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("try", '}', '{'),
|
||||||
SourceLocation.Zero,
|
SourceLocation.Zero,
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -384,10 +383,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
new StatementBlock(
|
new StatementBlock(
|
||||||
Factory.Code("try { baz(); } catch(Foo) { var foo = bar; if(foo != null) { bar(); } ").AsStatement()
|
Factory.Code("try { baz(); } catch(Foo) { var foo = bar; if(foo != null) { bar(); } ").AsStatement()
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("catch", '}', '{'),
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("catch", '}', '{'),
|
||||||
new SourceLocation(15, 0, 15),
|
new SourceLocation(15, 0, 15),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -397,10 +396,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
new StatementBlock(
|
new StatementBlock(
|
||||||
Factory.Code("try { baz(); } finally { var foo = bar; if(foo != null) { bar(); } ").AsStatement()
|
Factory.Code("try { baz(); } finally { var foo = bar; if(foo != null) { bar(); } ").AsStatement()
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("finally", '}', '{'),
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("finally", '}', '{'),
|
||||||
new SourceLocation(15, 0, 15),
|
new SourceLocation(15, 0, 15),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -464,9 +463,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
BlockFactory.MarkupTagBlock("</p>", AcceptedCharactersInternal.None)),
|
BlockFactory.MarkupTagBlock("</p>", AcceptedCharactersInternal.None)),
|
||||||
Factory.EmptyCSharp().AsStatement()
|
Factory.EmptyCSharp().AsStatement()
|
||||||
),
|
),
|
||||||
new RazorError(expectedMessage, 8, 0, 8, 1),
|
RazorDiagnostic.Create(new RazorError(expectedMessage, 8, 0, 8, 1)),
|
||||||
new RazorError(expectedMessage, 32, 0, 32, 1),
|
RazorDiagnostic.Create(new RazorError(expectedMessage, 32, 0, 32, 1)),
|
||||||
new RazorError(expectedMessage, 48, 0, 48, 1));
|
RazorDiagnostic.Create(new RazorError(expectedMessage, 48, 0, 48, 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -476,10 +475,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
new StatementBlock(
|
new StatementBlock(
|
||||||
Factory.Code("if(foo)) { var bar = foo; }").AsStatement()
|
Factory.Code("if(foo)) { var bar = foo; }").AsStatement()
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_SingleLine_ControlFlowStatements_Not_Allowed("{", ")"),
|
LegacyResources.FormatParseError_SingleLine_ControlFlowStatements_Not_Allowed("{", ")"),
|
||||||
new SourceLocation(7, 0, 7),
|
new SourceLocation(7, 0, 7),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -497,10 +496,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)),
|
Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)),
|
||||||
Factory.Code("}").AsStatement()
|
Factory.Code("}").AsStatement()
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start,
|
LegacyResources.ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start,
|
||||||
new SourceLocation(10, 0, 10),
|
new SourceLocation(10, 0, 10),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -511,10 +510,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
new StatementBlock(
|
new StatementBlock(
|
||||||
Factory.Code("if(foo bar" + Environment.NewLine).AsStatement()
|
Factory.Code("if(foo bar" + Environment.NewLine).AsStatement()
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
||||||
new SourceLocation(2, 0, 2),
|
new SourceLocation(2, 0, 2),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -525,10 +524,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
new StatementBlock(
|
new StatementBlock(
|
||||||
Factory.Code("foreach(foo bar" + Environment.NewLine).AsStatement()
|
Factory.Code("foreach(foo bar" + Environment.NewLine).AsStatement()
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
||||||
new SourceLocation(7, 0, 7),
|
new SourceLocation(7, 0, 7),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -539,10 +538,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
new StatementBlock(
|
new StatementBlock(
|
||||||
Factory.Code("do { } while(foo bar" + Environment.NewLine).AsStatement()
|
Factory.Code("do { } while(foo bar" + Environment.NewLine).AsStatement()
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
||||||
new SourceLocation(12, 0, 12),
|
new SourceLocation(12, 0, 12),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -553,10 +552,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
new StatementBlock(
|
new StatementBlock(
|
||||||
Factory.Code("using(foo bar" + Environment.NewLine).AsStatement()
|
Factory.Code("using(foo bar" + Environment.NewLine).AsStatement()
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
||||||
new SourceLocation(5, 0, 5),
|
new SourceLocation(5, 0, 5),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -574,10 +573,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)),
|
Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)),
|
||||||
Factory.Code("}").AsStatement().Accepts(AcceptedCharactersInternal.None)
|
Factory.Code("}").AsStatement().Accepts(AcceptedCharactersInternal.None)
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
||||||
new SourceLocation(2, 0, 2),
|
new SourceLocation(2, 0, 2),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -588,24 +587,24 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
+ ";" + Environment.NewLine
|
+ ";" + Environment.NewLine
|
||||||
+ "}",
|
+ "}",
|
||||||
BlockKindInternal.Statement, SpanKindInternal.Code,
|
BlockKindInternal.Statement, SpanKindInternal.Code,
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_Unterminated_String_Literal,
|
LegacyResources.ParseError_Unterminated_String_Literal,
|
||||||
new SourceLocation(21 + Environment.NewLine.Length, 1, 12),
|
new SourceLocation(21 + Environment.NewLine.Length, 1, 12),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesNormalStringAtEndOfFile()
|
public void ParseBlockTerminatesNormalStringAtEndOfFile()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest("if(foo) { var foo = \"blah blah blah blah blah", BlockKindInternal.Statement, SpanKindInternal.Code,
|
SingleSpanBlockTest("if(foo) { var foo = \"blah blah blah blah blah", BlockKindInternal.Statement, SpanKindInternal.Code,
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_Unterminated_String_Literal,
|
LegacyResources.ParseError_Unterminated_String_Literal,
|
||||||
new SourceLocation(20, 0, 20),
|
new SourceLocation(20, 0, 20),
|
||||||
length: 1),
|
length: 1)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("if", '}', '{'),
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("if", '}', '{'),
|
||||||
SourceLocation.Zero,
|
SourceLocation.Zero,
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -617,14 +616,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
+ "blah " + Environment.NewLine
|
+ "blah " + Environment.NewLine
|
||||||
+ "blah",
|
+ "blah",
|
||||||
BlockKindInternal.Statement, SpanKindInternal.Code,
|
BlockKindInternal.Statement, SpanKindInternal.Code,
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_Unterminated_String_Literal,
|
LegacyResources.ParseError_Unterminated_String_Literal,
|
||||||
new SourceLocation(20, 0, 20),
|
new SourceLocation(20, 0, 20),
|
||||||
length: 1),
|
length: 1)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("if", '}', '{'),
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("if", '}', '{'),
|
||||||
SourceLocation.Zero,
|
SourceLocation.Zero,
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -648,10 +647,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None)),
|
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharactersInternal.None)),
|
||||||
Factory.Code("}").AsStatement()
|
Factory.Code("}").AsStatement()
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_Unterminated_String_Literal,
|
LegacyResources.ParseError_Unterminated_String_Literal,
|
||||||
new SourceLocation(23 + Environment.NewLine.Length, 1, 14),
|
new SourceLocation(23 + Environment.NewLine.Length, 1, 14),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -681,12 +680,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)),
|
Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)),
|
||||||
expectedErrors: new[]
|
expectedErrors: new[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
||||||
new SourceLocation(14, 0, 14),
|
new SourceLocation(14, 0, 14),
|
||||||
length: 1)
|
length: 1)),
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RunUnterminatedSimpleKeywordBlock(string keyword)
|
private void RunUnterminatedSimpleKeywordBlock(string keyword)
|
||||||
|
|
@ -695,10 +693,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
keyword + " (foo) { var foo = bar; if(foo != null) { bar(); } ",
|
keyword + " (foo) { var foo = bar; if(foo != null) { bar(); } ",
|
||||||
BlockKindInternal.Statement,
|
BlockKindInternal.Statement,
|
||||||
SpanKindInternal.Code,
|
SpanKindInternal.Code,
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(keyword, '}', '{'),
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(keyword, '}', '{'),
|
||||||
SourceLocation.Zero,
|
SourceLocation.Zero,
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None),
|
Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None),
|
||||||
Factory.EmptyCSharp().AsExpression()
|
Factory.EmptyCSharp().AsExpression()
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(
|
||||||
LegacyResources.BlockName_ExplicitExpression, ")", "("),
|
LegacyResources.BlockName_ExplicitExpression, ")", "("),
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
|
|
@ -14,26 +14,26 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var noErrors = new RazorError[0];
|
var noErrors = new RazorDiagnostic[0];
|
||||||
Func<int, RazorError[]> missingEndParenError = (index) =>
|
Func<int, RazorDiagnostic[]> missingEndParenError = (index) =>
|
||||||
new RazorError[1]
|
new RazorDiagnostic[1]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
"An opening \"(\" is missing the corresponding closing \")\".",
|
"An opening \"(\" is missing the corresponding closing \")\".",
|
||||||
new SourceLocation(index, 0, index),
|
new SourceLocation(index, 0, index),
|
||||||
length: 1)
|
length: 1))
|
||||||
};
|
};
|
||||||
Func<int, RazorError[]> missingEndBracketError = (index) =>
|
Func<int, RazorDiagnostic[]> missingEndBracketError = (index) =>
|
||||||
new RazorError[1]
|
new RazorDiagnostic[1]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
"An opening \"[\" is missing the corresponding closing \"]\".",
|
"An opening \"[\" is missing the corresponding closing \"]\".",
|
||||||
new SourceLocation(index, 0, index),
|
new SourceLocation(index, 0, index),
|
||||||
length: 1)
|
length: 1))
|
||||||
};
|
};
|
||||||
|
|
||||||
// implicitExpression, expectedImplicitExpression, acceptedCharacters, expectedErrors
|
// implicitExpression, expectedImplicitExpression, acceptedCharacters, expectedErrors
|
||||||
return new TheoryData<string, string, AcceptedCharactersInternal, RazorError[]>
|
return new TheoryData<string, string, AcceptedCharactersInternal, RazorDiagnostic[]>
|
||||||
{
|
{
|
||||||
{ "val??[", "val", AcceptedCharactersInternal.NonWhiteSpace, noErrors },
|
{ "val??[", "val", AcceptedCharactersInternal.NonWhiteSpace, noErrors },
|
||||||
{ "val??[0", "val", AcceptedCharactersInternal.NonWhiteSpace, noErrors },
|
{ "val??[0", "val", AcceptedCharactersInternal.NonWhiteSpace, noErrors },
|
||||||
|
|
@ -68,7 +68,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
implicitExpresison,
|
implicitExpresison,
|
||||||
expectedImplicitExpression,
|
expectedImplicitExpression,
|
||||||
(AcceptedCharactersInternal)acceptedCharacters,
|
(AcceptedCharactersInternal)acceptedCharacters,
|
||||||
(RazorError[])expectedErrors);
|
(RazorDiagnostic[])expectedErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TheoryData NullConditionalOperatorData_Dot
|
public static TheoryData NullConditionalOperatorData_Dot
|
||||||
|
|
@ -135,10 +135,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.EmptyCSharp()
|
Factory.EmptyCSharp()
|
||||||
.AsImplicitExpression(KeywordSet)
|
.AsImplicitExpression(KeywordSet)
|
||||||
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("/"),
|
LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("/"),
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -150,10 +150,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.EmptyCSharp()
|
Factory.EmptyCSharp()
|
||||||
.AsImplicitExpression(KeywordSet)
|
.AsImplicitExpression(KeywordSet)
|
||||||
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock,
|
LegacyResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock,
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -253,10 +253,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
ImplicitExpressionTest(
|
ImplicitExpressionTest(
|
||||||
"foo(()", "foo(()",
|
"foo(()", "foo(()",
|
||||||
acceptedCharacters: AcceptedCharactersInternal.Any,
|
acceptedCharacters: AcceptedCharactersInternal.Any,
|
||||||
errors: new RazorError(
|
errors: RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
||||||
new SourceLocation(4, 0, 4),
|
new SourceLocation(4, 0, 4),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
string.Empty,
|
string.Empty,
|
||||||
HtmlSymbolType.Unknown))
|
HtmlSymbolType.Unknown))
|
||||||
.Accepts(AcceptedCharactersInternal.Any))),
|
.Accepts(AcceptedCharactersInternal.Any))),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_RazorComment_Not_Terminated,
|
LegacyResources.ParseError_RazorComment_Not_Terminated,
|
||||||
SourceLocation.Zero,
|
SourceLocation.Zero,
|
||||||
length: 2));
|
length: 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -79,10 +79,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.Accepts(AcceptedCharactersInternal.None)),
|
.Accepts(AcceptedCharactersInternal.None)),
|
||||||
Factory.Code(Environment.NewLine)
|
Factory.Code(Environment.NewLine)
|
||||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords))),
|
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords))),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
||||||
new SourceLocation(4, 0, 4),
|
new SourceLocation(4, 0, 4),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -104,14 +104,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
string.Empty,
|
string.Empty,
|
||||||
CSharpSymbolType.Unknown))
|
CSharpSymbolType.Unknown))
|
||||||
.Accepts(AcceptedCharactersInternal.Any)))),
|
.Accepts(AcceptedCharactersInternal.Any)))),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_RazorComment_Not_Terminated,
|
LegacyResources.ParseError_RazorComment_Not_Terminated,
|
||||||
new SourceLocation(5, 0, 5),
|
new SourceLocation(5, 0, 5),
|
||||||
length: 2),
|
length: 2)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
LegacyResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
|
||||||
new SourceLocation(4, 0, 4),
|
new SourceLocation(4, 0, 4),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -149,18 +149,18 @@ 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("}")))),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_TextTagCannotContainAttributes,
|
LegacyResources.ParseError_TextTagCannotContainAttributes,
|
||||||
new SourceLocation(7 + Environment.NewLine.Length, 1, 5),
|
new SourceLocation(7 + Environment.NewLine.Length, 1, 5),
|
||||||
length: 4),
|
length: 4)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_MissingEndTag("text"),
|
LegacyResources.FormatParseError_MissingEndTag("text"),
|
||||||
new SourceLocation(7 + Environment.NewLine.Length, 1, 5),
|
new SourceLocation(7 + Environment.NewLine.Length, 1, 5),
|
||||||
length: 4),
|
length: 4)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_Code, "}", "{"),
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_Code, "}", "{"),
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -182,15 +182,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.Accepts(AcceptedCharactersInternal.None),
|
.Accepts(AcceptedCharactersInternal.None),
|
||||||
Factory.Span(SpanKindInternal.Comment, new CSharpSymbol(string.Empty, CSharpSymbolType.Unknown))
|
Factory.Span(SpanKindInternal.Comment, new CSharpSymbol(string.Empty, CSharpSymbolType.Unknown))
|
||||||
.Accepts(AcceptedCharactersInternal.Any)))),
|
.Accepts(AcceptedCharactersInternal.Any)))),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_RazorComment_Not_Terminated,
|
LegacyResources.ParseError_RazorComment_Not_Terminated,
|
||||||
new SourceLocation(2, 0, 2),
|
new SourceLocation(2, 0, 2),
|
||||||
length: 2),
|
length: 2)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(
|
||||||
LegacyResources.BlockName_Code, "}", "{"),
|
LegacyResources.BlockName_Code, "}", "{"),
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
new DirectiveBlock(
|
new DirectiveBlock(
|
||||||
Factory.MetaCode(word).Accepts(AcceptedCharactersInternal.None)
|
Factory.MetaCode(word).Accepts(AcceptedCharactersInternal.None)
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_ReservedWord(word),
|
LegacyResources.FormatParseError_ReservedWord(word),
|
||||||
SourceLocation.Zero,
|
SourceLocation.Zero,
|
||||||
word.Length));
|
word.Length)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using Microsoft.AspNetCore.Razor.Language.Extensions;
|
using Microsoft.AspNetCore.Razor.Language.Extensions;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
|
@ -88,10 +87,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.AutoCompleteWith(autoCompleteString: null),
|
.AutoCompleteWith(autoCompleteString: null),
|
||||||
Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)
|
Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock,
|
LegacyResources.ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock,
|
||||||
new SourceLocation(2, 0, 2),
|
new SourceLocation(2, 0, 2),
|
||||||
length: 5));
|
length: 5)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -105,10 +104,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.AutoCompleteWith(autoCompleteString: null),
|
.AutoCompleteWith(autoCompleteString: null),
|
||||||
Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)
|
Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)
|
||||||
),
|
),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock,
|
LegacyResources.ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock,
|
||||||
new SourceLocation(2, 0, 2),
|
new SourceLocation(2, 0, 2),
|
||||||
length: 5));
|
length: 5)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -228,10 +227,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.EmptyCSharp()
|
Factory.EmptyCSharp()
|
||||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||||
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("/"),
|
LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("/"),
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
"and that none of the \"}\" characters are being interpreted as markup.";
|
"and that none of the \"}\" characters are being interpreted as markup.";
|
||||||
|
|
||||||
// document, expectedStatement, expectedErrors
|
// document, expectedStatement, expectedErrors
|
||||||
return new TheoryData<string, StatementBlock, RazorError[]>
|
return new TheoryData<string, StatementBlock, RazorDiagnostic[]>
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"@try { someMethod(); } catch(Exception) when (",
|
"@try { someMethod(); } catch(Exception) when (",
|
||||||
|
|
@ -263,7 +263,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
factory
|
factory
|
||||||
.Code("try { someMethod(); } catch(Exception) when (")
|
.Code("try { someMethod(); } catch(Exception) when (")
|
||||||
.AsStatement()),
|
.AsStatement()),
|
||||||
new[] { new RazorError(unbalancedParenErrorString, 45, 0, 45, 1) }
|
new[] { RazorDiagnostic.Create(new RazorError(unbalancedParenErrorString, 45, 0, 45, 1)) }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"@try { someMethod(); } catch(Exception) when (someMethod(",
|
"@try { someMethod(); } catch(Exception) when (someMethod(",
|
||||||
|
|
@ -272,7 +272,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
factory
|
factory
|
||||||
.Code("try { someMethod(); } catch(Exception) when (someMethod(")
|
.Code("try { someMethod(); } catch(Exception) when (someMethod(")
|
||||||
.AsStatement()),
|
.AsStatement()),
|
||||||
new[] { new RazorError(unbalancedParenErrorString, 45, 0, 45, 1) }
|
new[] { RazorDiagnostic.Create(new RazorError(unbalancedParenErrorString, 45, 0, 45, 1)) }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"@try { someMethod(); } catch(Exception) when (true) {",
|
"@try { someMethod(); } catch(Exception) when (true) {",
|
||||||
|
|
@ -281,7 +281,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
factory
|
factory
|
||||||
.Code("try { someMethod(); } catch(Exception) when (true) {")
|
.Code("try { someMethod(); } catch(Exception) when (true) {")
|
||||||
.AsStatement()),
|
.AsStatement()),
|
||||||
new[] { new RazorError(unbalancedBracketCatchErrorString, 23, 0, 23, 1) }
|
new[] { RazorDiagnostic.Create(new RazorError(unbalancedBracketCatchErrorString, 23, 0, 23, 1)) }
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -297,7 +297,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
FixupSpans = true;
|
FixupSpans = true;
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ParseBlockTest(document, (StatementBlock)expectedStatement, (RazorError[])expectedErrors);
|
ParseBlockTest(document, (StatementBlock)expectedStatement, (RazorDiagnostic[])expectedErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
|
|
@ -312,12 +312,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
ParseBlockTest("{ var foo = bar; Html.ExecuteTemplate(foo," + testTemplateWithDoubleTransitionCode + "); }", expected);
|
ParseBlockTest("{ var foo = bar; Html.ExecuteTemplate(foo," + testTemplateWithDoubleTransitionCode + "); }", expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static RazorError GetNestedTemplateError(int characterIndex)
|
private static RazorDiagnostic GetNestedTemplateError(int characterIndex)
|
||||||
{
|
{
|
||||||
return new RazorError(
|
return RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_InlineMarkup_Blocks_Cannot_Be_Nested,
|
LegacyResources.ParseError_InlineMarkup_Blocks_Cannot_Be_Nested,
|
||||||
new SourceLocation(characterIndex, 0, characterIndex),
|
new SourceLocation(characterIndex, 0, characterIndex),
|
||||||
length: 1);
|
length: 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -111,10 +111,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.Code(" " + Environment.NewLine).AsStatement(),
|
Factory.Code(" " + Environment.NewLine).AsStatement(),
|
||||||
Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)
|
Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)
|
||||||
), true,
|
), true,
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start,
|
LegacyResources.ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start,
|
||||||
new SourceLocation(5 + Environment.NewLine.Length, 1, 4),
|
new SourceLocation(5 + Environment.NewLine.Length, 1, 4),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
designTime: true,
|
designTime: true,
|
||||||
expectedErrors: new[]
|
expectedErrors: new[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("}"),
|
LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("}"),
|
||||||
new SourceLocation(2, 0, 2),
|
new SourceLocation(2, 0, 2),
|
||||||
length: 1)
|
length: 1))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,10 +69,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
designTime: true,
|
designTime: true,
|
||||||
expectedErrors: new[]
|
expectedErrors: new[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("."),
|
LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("."),
|
||||||
new SourceLocation(2, 0, 2),
|
new SourceLocation(2, 0, 2),
|
||||||
length: 1)
|
length: 1))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,10 +94,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.Code(Environment.NewLine).AsStatement(),
|
Factory.Code(Environment.NewLine).AsStatement(),
|
||||||
Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)),
|
Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)),
|
||||||
/* designTimeParser */ true,
|
/* designTimeParser */ true,
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS,
|
LegacyResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS,
|
||||||
new SourceLocation(6 + Environment.NewLine.Length, 1, 5),
|
new SourceLocation(6 + Environment.NewLine.Length, 1, 5),
|
||||||
Environment.NewLine.Length));
|
Environment.NewLine.Length)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
|
|
@ -14,17 +14,17 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
return ParseCodeBlock(document, directives, designTime);
|
return ParseCodeBlock(document, directives, designTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void ImplicitExpressionTest(string input, params RazorError[] errors)
|
internal void ImplicitExpressionTest(string input, params RazorDiagnostic[] errors)
|
||||||
{
|
{
|
||||||
ImplicitExpressionTest(input, AcceptedCharactersInternal.NonWhiteSpace, errors);
|
ImplicitExpressionTest(input, AcceptedCharactersInternal.NonWhiteSpace, errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void ImplicitExpressionTest(string input, AcceptedCharactersInternal acceptedCharacters, params RazorError[] errors)
|
internal void ImplicitExpressionTest(string input, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] errors)
|
||||||
{
|
{
|
||||||
ImplicitExpressionTest(input, input, acceptedCharacters, errors);
|
ImplicitExpressionTest(input, input, acceptedCharacters, errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void ImplicitExpressionTest(string input, string expected, params RazorError[] errors)
|
internal void ImplicitExpressionTest(string input, string expected, params RazorDiagnostic[] errors)
|
||||||
{
|
{
|
||||||
ImplicitExpressionTest(input, expected, AcceptedCharactersInternal.NonWhiteSpace, errors);
|
ImplicitExpressionTest(input, expected, AcceptedCharactersInternal.NonWhiteSpace, errors);
|
||||||
}
|
}
|
||||||
|
|
@ -39,28 +39,28 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
SingleSpanBlockTest(document, spanContent, blockKind, spanType, acceptedCharacters, expectedErrors: null);
|
SingleSpanBlockTest(document, spanContent, blockKind, spanType, acceptedCharacters, expectedErrors: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorError[] expectedError)
|
internal override void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorDiagnostic[] expectedError)
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(document, document, blockKind, spanType, expectedError);
|
SingleSpanBlockTest(document, document, blockKind, spanType, expectedError);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorError[] expectedErrors)
|
internal override void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorDiagnostic[] expectedErrors)
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(document, spanContent, blockKind, spanType, AcceptedCharactersInternal.Any, expectedErrors ?? new RazorError[0]);
|
SingleSpanBlockTest(document, spanContent, blockKind, spanType, AcceptedCharactersInternal.Any, expectedErrors ?? new RazorDiagnostic[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorError[] expectedError)
|
internal override void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] expectedError)
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(document, document, blockKind, spanType, acceptedCharacters, expectedError);
|
SingleSpanBlockTest(document, document, blockKind, spanType, acceptedCharacters, expectedError);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorError[] expectedErrors)
|
internal override void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] expectedErrors)
|
||||||
{
|
{
|
||||||
var b = CreateSimpleBlockAndSpan(spanContent, blockKind, spanType, acceptedCharacters);
|
var b = CreateSimpleBlockAndSpan(spanContent, blockKind, spanType, acceptedCharacters);
|
||||||
ParseBlockTest(document, b, expectedErrors ?? new RazorError[0]);
|
ParseBlockTest(document, b, expectedErrors ?? new RazorDiagnostic[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void ImplicitExpressionTest(string input, string expected, AcceptedCharactersInternal acceptedCharacters, params RazorError[] errors)
|
internal void ImplicitExpressionTest(string input, string expected, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] errors)
|
||||||
{
|
{
|
||||||
var factory = CreateSpanFactory();
|
var factory = CreateSpanFactory();
|
||||||
ParseBlockTest(SyntaxConstants.TransitionString + input,
|
ParseBlockTest(SyntaxConstants.TransitionString + input,
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.EmptyCSharp().AsStatement(),
|
Factory.EmptyCSharp().AsStatement(),
|
||||||
Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)),
|
Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)),
|
||||||
Factory.EmptyHtml()),
|
Factory.EmptyHtml()),
|
||||||
new RazorError[0]);
|
new RazorDiagnostic[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -47,11 +47,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
new MarkupBlock(
|
new MarkupBlock(
|
||||||
new MarkupTagBlock(
|
new MarkupTagBlock(
|
||||||
Factory.Markup("<"))))),
|
Factory.Markup("<"))))),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(
|
||||||
LegacyResources.BlockName_Code, "}", "{"),
|
LegacyResources.BlockName_Code, "}", "{"),
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -82,14 +82,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
designTime: true,
|
designTime: true,
|
||||||
expectedErrors: new[]
|
expectedErrors: new[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_UnexpectedEndTag("html"),
|
LegacyResources.FormatParseError_UnexpectedEndTag("html"),
|
||||||
new SourceLocation(5 + Environment.NewLine.Length * 2, 2, 2),
|
new SourceLocation(5 + Environment.NewLine.Length * 2, 2, 2),
|
||||||
length: 4),
|
length: 4)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("code", "}", "{"),
|
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("code", "}", "{"),
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 1)
|
length: 1))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -102,10 +102,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
new MarkupTagBlock(
|
new MarkupTagBlock(
|
||||||
Factory.Markup($"< {Environment.NewLine} "))),
|
Factory.Markup($"< {Environment.NewLine} "))),
|
||||||
designTime: true,
|
designTime: true,
|
||||||
expectedErrors: new RazorError(
|
expectedErrors: RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_UnfinishedTag(string.Empty),
|
LegacyResources.FormatParseError_UnfinishedTag(string.Empty),
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -335,10 +335,10 @@ 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))),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_MissingEndTag("foo"),
|
LegacyResources.FormatParseError_MissingEndTag("foo"),
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 3));
|
length: 3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -458,10 +458,10 @@ 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))),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_MissingEndTag("foo"),
|
LegacyResources.FormatParseError_MissingEndTag("foo"),
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 3));
|
length: 3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -620,10 +620,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
new MarkupBlock(
|
new MarkupBlock(
|
||||||
new MarkupTagBlock(
|
new MarkupTagBlock(
|
||||||
Factory.Markup("<br/"))),
|
Factory.Markup("<br/"))),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_UnfinishedTag("br"),
|
LegacyResources.FormatParseError_UnfinishedTag("br"),
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 2));
|
length: 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
|
|
@ -64,10 +64,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||||
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
||||||
Factory.EmptyHtml()),
|
Factory.EmptyHtml()),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock,
|
LegacyResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock,
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -159,10 +159,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||||
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
||||||
Factory.EmptyHtml()),
|
Factory.EmptyHtml()),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock,
|
LegacyResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock,
|
||||||
new SourceLocation(5, 0, 5),
|
new SourceLocation(5, 0, 5),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -786,16 +786,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
Factory.EmptyCSharp().AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.NonWhiteSpace))),
|
Factory.EmptyCSharp().AsImplicitExpression(CSharpCodeParser.DefaultKeywords).Accepts(AcceptedCharactersInternal.NonWhiteSpace))),
|
||||||
Factory.Markup("'").With(SpanChunkGenerator.Null)),
|
Factory.Markup("'").With(SpanChunkGenerator.Null)),
|
||||||
Factory.Markup(" />")));
|
Factory.Markup(" />")));
|
||||||
var expectedErrors = new RazorError[]
|
var expectedErrors = new RazorDiagnostic[]
|
||||||
{
|
{
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
@"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.",
|
@"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.",
|
||||||
new SourceLocation(12, 0, 12),
|
new SourceLocation(12, 0, 12),
|
||||||
length: 1),
|
length: 1)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
@"""' />"" is not valid at the start of a code block. Only identifiers, keywords, comments, ""("" and ""{"" are valid.",
|
@"""' />"" is not valid at the start of a code block. Only identifiers, keywords, comments, ""("" and ""{"" are valid.",
|
||||||
new SourceLocation(14, 0, 14),
|
new SourceLocation(14, 0, 14),
|
||||||
length: 4),
|
length: 4)),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,10 @@ 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>"))),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_TextTagCannotContainAttributes,
|
LegacyResources.ParseError_TextTagCannotContainAttributes,
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 4));
|
length: 4)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -43,10 +43,10 @@ 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))),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_TextTagCannotContainAttributes,
|
LegacyResources.ParseError_TextTagCannotContainAttributes,
|
||||||
new SourceLocation(8, 0, 8),
|
new SourceLocation(8, 0, 8),
|
||||||
length: 4));
|
length: 4)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -54,10 +54,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
{
|
{
|
||||||
ParseBlockTest("foo bar <baz>",
|
ParseBlockTest("foo bar <baz>",
|
||||||
new MarkupBlock(),
|
new MarkupBlock(),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.ParseError_MarkupBlock_Must_Start_With_Tag,
|
LegacyResources.ParseError_MarkupBlock_Must_Start_With_Tag,
|
||||||
SourceLocation.Zero,
|
SourceLocation.Zero,
|
||||||
length: 3));
|
length: 3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -68,10 +68,10 @@ 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)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_UnexpectedEndTag("foo"),
|
LegacyResources.FormatParseError_UnexpectedEndTag("foo"),
|
||||||
new SourceLocation(2, 0, 2),
|
new SourceLocation(2, 0, 2),
|
||||||
length: 3));
|
length: 3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -85,10 +85,10 @@ 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))),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_MissingEndTag("p"),
|
LegacyResources.FormatParseError_MissingEndTag("p"),
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -99,10 +99,10 @@ 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")),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_MissingEndTag("foo"),
|
LegacyResources.FormatParseError_MissingEndTag("foo"),
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 3));
|
length: 3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -115,10 +115,10 @@ 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)))))),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_UnfinishedTag("foo"),
|
LegacyResources.FormatParseError_UnfinishedTag("foo"),
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 3));
|
length: 3)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,10 @@ 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)),
|
||||||
new RazorError(
|
RazorDiagnostic.Create(new RazorError(
|
||||||
LegacyResources.FormatParseError_MissingEndTag("p"),
|
LegacyResources.FormatParseError_MissingEndTag("p"),
|
||||||
new SourceLocation(1, 0, 1),
|
new SourceLocation(1, 0, 1),
|
||||||
length: 1));
|
length: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -16,14 +16,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
RunParseTreeRewriterTest(
|
RunParseTreeRewriterTest(
|
||||||
documentContent,
|
documentContent,
|
||||||
expectedOutput,
|
expectedOutput,
|
||||||
errors: Enumerable.Empty<RazorError>(),
|
errors: Enumerable.Empty<RazorDiagnostic>(),
|
||||||
tagNames: tagNames);
|
tagNames: tagNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RunParseTreeRewriterTest(
|
internal void RunParseTreeRewriterTest(
|
||||||
string documentContent,
|
string documentContent,
|
||||||
MarkupBlock expectedOutput,
|
MarkupBlock expectedOutput,
|
||||||
IEnumerable<RazorError> errors,
|
IEnumerable<RazorDiagnostic> errors,
|
||||||
params string[] tagNames)
|
params string[] tagNames)
|
||||||
{
|
{
|
||||||
var descriptors = BuildDescriptors(tagNames);
|
var descriptors = BuildDescriptors(tagNames);
|
||||||
|
|
@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
IEnumerable<TagHelperDescriptor> descriptors,
|
IEnumerable<TagHelperDescriptor> descriptors,
|
||||||
string documentContent,
|
string documentContent,
|
||||||
MarkupBlock expectedOutput,
|
MarkupBlock expectedOutput,
|
||||||
IEnumerable<RazorError> expectedErrors,
|
IEnumerable<RazorDiagnostic> expectedErrors,
|
||||||
string tagHelperPrefix = null,
|
string tagHelperPrefix = null,
|
||||||
RazorParserFeatureFlags featureFlags = null)
|
RazorParserFeatureFlags featureFlags = null)
|
||||||
{
|
{
|
||||||
|
|
@ -68,7 +68,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
.OrderBy(error => error.Span.AbsoluteIndex)
|
.OrderBy(error => error.Span.AbsoluteIndex)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
EvaluateRazorErrors(actualErrors, expectedErrors.Select(error => RazorDiagnostic.Create(error)).ToList());
|
EvaluateRazorErrors(actualErrors, expectedErrors.ToList());
|
||||||
EvaluateParseTree(actualTree, expectedOutput);
|
EvaluateParseTree(actualTree, expectedOutput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -134,20 +134,20 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
|
|
||||||
internal virtual void ParseBlockTest(string document)
|
internal virtual void ParseBlockTest(string document)
|
||||||
{
|
{
|
||||||
ParseBlockTest(document, null, false, new RazorError[0]);
|
ParseBlockTest(document, null, false, new RazorDiagnostic[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal virtual void ParseBlockTest(string document, bool designTime)
|
internal virtual void ParseBlockTest(string document, bool designTime)
|
||||||
{
|
{
|
||||||
ParseBlockTest(document, null, designTime, new RazorError[0]);
|
ParseBlockTest(document, null, designTime, new RazorDiagnostic[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal virtual void ParseBlockTest(string document, params RazorError[] expectedErrors)
|
internal virtual void ParseBlockTest(string document, params RazorDiagnostic[] expectedErrors)
|
||||||
{
|
{
|
||||||
ParseBlockTest(document, false, expectedErrors);
|
ParseBlockTest(document, false, expectedErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal virtual void ParseBlockTest(string document, bool designTime, params RazorError[] expectedErrors)
|
internal virtual void ParseBlockTest(string document, bool designTime, params RazorDiagnostic[] expectedErrors)
|
||||||
{
|
{
|
||||||
ParseBlockTest(document, null, designTime, expectedErrors);
|
ParseBlockTest(document, null, designTime, expectedErrors);
|
||||||
}
|
}
|
||||||
|
|
@ -167,22 +167,22 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
ParseBlockTest(document, expectedRoot, designTime, null);
|
ParseBlockTest(document, expectedRoot, designTime, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal virtual void ParseBlockTest(string document, Block expectedRoot, params RazorError[] expectedErrors)
|
internal virtual void ParseBlockTest(string document, Block expectedRoot, params RazorDiagnostic[] expectedErrors)
|
||||||
{
|
{
|
||||||
ParseBlockTest(document, expectedRoot, false, expectedErrors);
|
ParseBlockTest(document, expectedRoot, false, expectedErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal virtual void ParseBlockTest(string document, IEnumerable<DirectiveDescriptor> directives, Block expectedRoot, params RazorError[] expectedErrors)
|
internal virtual void ParseBlockTest(string document, IEnumerable<DirectiveDescriptor> directives, Block expectedRoot, params RazorDiagnostic[] expectedErrors)
|
||||||
{
|
{
|
||||||
ParseBlockTest(document, directives, expectedRoot, false, expectedErrors);
|
ParseBlockTest(document, directives, expectedRoot, false, expectedErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal virtual void ParseBlockTest(string document, Block expected, bool designTime, params RazorError[] expectedErrors)
|
internal virtual void ParseBlockTest(string document, Block expected, bool designTime, params RazorDiagnostic[] expectedErrors)
|
||||||
{
|
{
|
||||||
ParseBlockTest(document, null, expected, designTime, expectedErrors);
|
ParseBlockTest(document, null, expected, designTime, expectedErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal virtual void ParseBlockTest(string document, IEnumerable<DirectiveDescriptor> directives, Block expected, bool designTime, params RazorError[] expectedErrors)
|
internal virtual void ParseBlockTest(string document, IEnumerable<DirectiveDescriptor> directives, Block expected, bool designTime, params RazorDiagnostic[] expectedErrors)
|
||||||
{
|
{
|
||||||
var result = ParseBlock(document, directives, designTime);
|
var result = ParseBlock(document, directives, designTime);
|
||||||
|
|
||||||
|
|
@ -199,7 +199,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
|
|
||||||
if (!ReferenceEquals(expected, IgnoreOutput))
|
if (!ReferenceEquals(expected, IgnoreOutput))
|
||||||
{
|
{
|
||||||
EvaluateResults(result, expected, expectedErrors?.Select(error => RazorDiagnostic.Create(error)).ToList());
|
EvaluateResults(result, expected, expectedErrors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -213,22 +213,22 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
SingleSpanBlockTest(document, spanContent, blockKind, spanType, acceptedCharacters, expectedErrors: null);
|
SingleSpanBlockTest(document, spanContent, blockKind, spanType, acceptedCharacters, expectedErrors: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal virtual void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorError[] expectedError)
|
internal virtual void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorDiagnostic[] expectedError)
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(document, document, blockKind, spanType, expectedError);
|
SingleSpanBlockTest(document, document, blockKind, spanType, expectedError);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal virtual void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorError[] expectedErrors)
|
internal virtual void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, params RazorDiagnostic[] expectedErrors)
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(document, spanContent, blockKind, spanType, AcceptedCharactersInternal.Any, expectedErrors ?? new RazorError[0]);
|
SingleSpanBlockTest(document, spanContent, blockKind, spanType, AcceptedCharactersInternal.Any, expectedErrors ?? new RazorDiagnostic[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal virtual void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorError[] expectedError)
|
internal virtual void SingleSpanBlockTest(string document, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] expectedError)
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(document, document, blockKind, spanType, acceptedCharacters, expectedError);
|
SingleSpanBlockTest(document, document, blockKind, spanType, acceptedCharacters, expectedError);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal virtual void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorError[] expectedErrors)
|
internal virtual void SingleSpanBlockTest(string document, string spanContent, BlockKindInternal blockKind, SpanKindInternal spanType, AcceptedCharactersInternal acceptedCharacters, params RazorDiagnostic[] expectedErrors)
|
||||||
{
|
{
|
||||||
var result = ParseBlock(document, designTime: false);
|
var result = ParseBlock(document, designTime: false);
|
||||||
|
|
||||||
|
|
@ -249,7 +249,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
|
|
||||||
if (!ReferenceEquals(expected, IgnoreOutput))
|
if (!ReferenceEquals(expected, IgnoreOutput))
|
||||||
{
|
{
|
||||||
EvaluateResults(result, expected, expectedErrors?.Select(error => RazorDiagnostic.Create(error)).ToList());
|
EvaluateResults(result, expected, expectedErrors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -263,12 +263,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
ParseDocumentTest(document, expectedRoot, false, null);
|
ParseDocumentTest(document, expectedRoot, false, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal virtual void ParseDocumentTest(string document, Block expectedRoot, params RazorError[] expectedErrors)
|
internal virtual void ParseDocumentTest(string document, Block expectedRoot, params RazorDiagnostic[] expectedErrors)
|
||||||
{
|
{
|
||||||
ParseDocumentTest(document, expectedRoot, false, expectedErrors);
|
ParseDocumentTest(document, expectedRoot, false, expectedErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal virtual void ParseDocumentTest(string document, IEnumerable<DirectiveDescriptor> directives, Block expected, params RazorError[] expectedErrors)
|
internal virtual void ParseDocumentTest(string document, IEnumerable<DirectiveDescriptor> directives, Block expected, params RazorDiagnostic[] expectedErrors)
|
||||||
{
|
{
|
||||||
ParseDocumentTest(document, directives, expected, false, expectedErrors);
|
ParseDocumentTest(document, directives, expected, false, expectedErrors);
|
||||||
}
|
}
|
||||||
|
|
@ -283,12 +283,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
ParseDocumentTest(document, expectedRoot, designTime, null);
|
ParseDocumentTest(document, expectedRoot, designTime, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal virtual void ParseDocumentTest(string document, Block expected, bool designTime, params RazorError[] expectedErrors)
|
internal virtual void ParseDocumentTest(string document, Block expected, bool designTime, params RazorDiagnostic[] expectedErrors)
|
||||||
{
|
{
|
||||||
ParseDocumentTest(document, null, expected, designTime, expectedErrors);
|
ParseDocumentTest(document, null, expected, designTime, expectedErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal virtual void ParseDocumentTest(string document, IEnumerable<DirectiveDescriptor> directives, Block expected, bool designTime, params RazorError[] expectedErrors)
|
internal virtual void ParseDocumentTest(string document, IEnumerable<DirectiveDescriptor> directives, Block expected, bool designTime, params RazorDiagnostic[] expectedErrors)
|
||||||
{
|
{
|
||||||
var result = ParseDocument(document, directives, designTime);
|
var result = ParseDocument(document, directives, designTime);
|
||||||
|
|
||||||
|
|
@ -305,7 +305,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
|
|
||||||
if (!ReferenceEquals(expected, IgnoreOutput))
|
if (!ReferenceEquals(expected, IgnoreOutput))
|
||||||
{
|
{
|
||||||
EvaluateResults(result, expected, expectedErrors?.Select(error => RazorDiagnostic.Create(error)).ToList());
|
EvaluateResults(result, expected, expectedErrors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -339,9 +339,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
string directiveText,
|
string directiveText,
|
||||||
string typePattern = null,
|
string typePattern = null,
|
||||||
string assemblyName = null,
|
string assemblyName = null,
|
||||||
params RazorError[] legacyErrors)
|
params RazorDiagnostic[] errors)
|
||||||
{
|
{
|
||||||
var diagnostics = legacyErrors.Select(error => RazorDiagnostic.Create(error)).ToList();
|
var diagnostics = errors.ToList();
|
||||||
return _self
|
return _self
|
||||||
.With(new AddTagHelperChunkGenerator(lookupText, directiveText, typePattern, assemblyName, diagnostics))
|
.With(new AddTagHelperChunkGenerator(lookupText, directiveText, typePattern, assemblyName, diagnostics))
|
||||||
.Accepts(AcceptedCharactersInternal.AnyExceptNewline);
|
.Accepts(AcceptedCharactersInternal.AnyExceptNewline);
|
||||||
|
|
@ -352,17 +352,17 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
string directiveText,
|
string directiveText,
|
||||||
string typePattern = null,
|
string typePattern = null,
|
||||||
string assemblyName = null,
|
string assemblyName = null,
|
||||||
params RazorError[] legacyErrors)
|
params RazorDiagnostic[] errors)
|
||||||
{
|
{
|
||||||
var diagnostics = legacyErrors.Select(error => RazorDiagnostic.Create(error)).ToList();
|
var diagnostics = errors.ToList();
|
||||||
return _self
|
return _self
|
||||||
.With(new RemoveTagHelperChunkGenerator(lookupText, directiveText, typePattern, assemblyName, diagnostics))
|
.With(new RemoveTagHelperChunkGenerator(lookupText, directiveText, typePattern, assemblyName, diagnostics))
|
||||||
.Accepts(AcceptedCharactersInternal.AnyExceptNewline);
|
.Accepts(AcceptedCharactersInternal.AnyExceptNewline);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpanConstructor AsTagHelperPrefixDirective(string prefix, string directiveText, params RazorError[] legacyErrors)
|
public SpanConstructor AsTagHelperPrefixDirective(string prefix, string directiveText, params RazorDiagnostic[] errors)
|
||||||
{
|
{
|
||||||
var diagnostics = legacyErrors.Select(error => RazorDiagnostic.Create(error)).ToList();
|
var diagnostics = errors.ToList();
|
||||||
return _self
|
return _self
|
||||||
.With(new TagHelperPrefixDirectiveChunkGenerator(prefix, directiveText, diagnostics))
|
.With(new TagHelperPrefixDirectiveChunkGenerator(prefix, directiveText, diagnostics))
|
||||||
.Accepts(AcceptedCharactersInternal.AnyExceptNewline);
|
.Accepts(AcceptedCharactersInternal.AnyExceptNewline);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue