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