diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs index 9f0e9f1fba..ff07646f2e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs @@ -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))); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs index 5972dabb25..352182184e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs @@ -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.Empty, 12, 0, 12), new LocationTagged("@", 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 (""
"") or have matching end tags (""

Hello

""). 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, diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs index 29cdff255b..0bbb88a40b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs @@ -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))); } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs index d9be2f5e7b..b7ff9cc498 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs @@ -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("

", 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))); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs index 83e0b9f2c1..484ab6b610 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs @@ -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] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs index ce82632a59..c74c0d4283 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs @@ -14,26 +14,26 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { get { - var noErrors = new RazorError[0]; - Func missingEndParenError = (index) => - new RazorError[1] + var noErrors = new RazorDiagnostic[0]; + Func 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 missingEndBracketError = (index) => - new RazorError[1] + Func 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 + return new TheoryData { { "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] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs index c4ec18b465..b6495d1eaf 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs @@ -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] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs index ce0382e7c6..c8bb2e4253 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs @@ -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] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs index 69e78889f9..2bf1223be9 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs @@ -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] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs index 490d252688..e08bc0f5fb 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs @@ -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 + return new TheoryData { { "@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] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs index 775f2a3c4f..90da08a135 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs @@ -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)); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs index fa51eb681f..b1587e1d89 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs @@ -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] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs index dde4e6e58c..723312ff96 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs @@ -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] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeParserTestBase.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeParserTestBase.cs index f67b159189..f0af2d1530 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeParserTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CodeParserTestBase.cs @@ -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, diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs index f0cf332e1f..4d8b25494b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs @@ -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("").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("").Accepts(AcceptedCharactersInternal.None)), new MarkupTagBlock( Factory.Markup("").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("
"))); - 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 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlErrorTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlErrorTest.cs index 0856a18c43..6d6ef4db9a 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlErrorTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlErrorTest.cs @@ -28,10 +28,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.MarkupTransition("").Accepts(AcceptedCharactersInternal.Any)), new MarkupTagBlock( Factory.MarkupTransition(""))), - 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("")), new MarkupTagBlock( Factory.MarkupTransition("").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 ", 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("
").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("").Accepts(AcceptedCharactersInternal.None)), new MarkupTagBlock( 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] @@ -99,10 +99,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagBlock( Factory.Markup("").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(" bar=", 4, 0, 4), new LocationTagged(string.Empty, 12, 0, 12)), Factory.Markup(" bar=").With(SpanChunkGenerator.Null), Factory.Markup("baz").With(new LiteralAttributeChunkGenerator(new LocationTagged(string.Empty, 9, 0, 9), new LocationTagged("baz", 9, 0, 9)))))), - new RazorError( + RazorDiagnostic.Create(new RazorError( LegacyResources.FormatParseError_UnfinishedTag("foo"), new SourceLocation(1, 0, 1), - length: 3)); + length: 3))); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTagsTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTagsTest.cs index c1b3b1a688..4f8e565035 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTagsTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlTagsTest.cs @@ -39,10 +39,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy BlockFactory.MarkupTagBlock("

", 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] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs index cc6b408e3d..67ef8fac0c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs @@ -156,7 +156,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData WithoutEndTagElementData @@ -230,7 +230,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData TagStructureCompatibilityData @@ -334,7 +334,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData MalformedTagHelperAttributeBlockData @@ -362,7 +362,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Code("do {" + extraCode).AsStatement()))); }; - return new TheoryData + return new TheoryData { { "

+ return new TheoryData { { ""))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(CultureInfo.InvariantCulture, errorFormatUnclosed, "strong"), new SourceLocation(3, 0, 3), - length: 6) + length: 6)) } }, { @@ -925,10 +925,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.MarkupTagBlock("

"))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(CultureInfo.InvariantCulture, errorFormatUnclosed, "p"), new SourceLocation(14, 0, 14), - length: 1) + length: 1)) } } }; @@ -942,7 +942,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "strong", "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); } public static TheoryData CodeTagHelperAttributesData @@ -1219,7 +1219,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy descriptors, documentContent, (MarkupBlock)expectedOutput, - expectedErrors: Enumerable.Empty()); + expectedErrors: Enumerable.Empty()); } public static IEnumerable IncompleteHelperBlockData @@ -1258,14 +1258,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }, new MarkupTagHelperBlock("strong")), blockFactory.MarkupTagBlock("")), - new RazorError[] + new RazorDiagnostic[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(CultureInfo.InvariantCulture, malformedErrorFormat, "strong"), - absoluteIndex: 53, lineIndex: 0, columnIndex: 53, length: 6), - new RazorError( + absoluteIndex: 53, lineIndex: 0, columnIndex: 53, length: 6)), + RazorDiagnostic.Create(new RazorError( string.Format(CultureInfo.InvariantCulture, malformedErrorFormat, "strong"), - absoluteIndex: 66, lineIndex: 0, columnIndex: 66, length: 6) + absoluteIndex: 66, lineIndex: 0, columnIndex: 66, length: 6)) } }; yield return new object[] @@ -1278,11 +1278,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagHelperBlock("strong", factory.Markup("World")), blockFactory.MarkupTagBlock(""))), - new RazorError[] + new RazorDiagnostic[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(CultureInfo.InvariantCulture, malformedErrorFormat, "p"), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 1) + absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 1)) } }; yield return new object[] @@ -1295,14 +1295,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagHelperBlock("strong", factory.Markup("World"), blockFactory.MarkupTagBlock("")))), - new RazorError[] + new RazorDiagnostic[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(CultureInfo.InvariantCulture, malformedErrorFormat, "p"), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 1), - new RazorError( + absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(CultureInfo.InvariantCulture, malformedErrorFormat, "strong"), - absoluteIndex: 15, lineIndex: 0, columnIndex: 15, length: 6) + absoluteIndex: 15, lineIndex: 0, columnIndex: 15, length: 6)) } }; yield return new object[] @@ -1321,12 +1321,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new TagHelperAttributeNode("style", factory.Markup("color:red;")) }, factory.Markup("World")))), - new RazorError[] + new RazorDiagnostic[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(CultureInfo.InvariantCulture, malformedErrorFormat, "p"), new SourceLocation(1, 0, 1), - length: 1) + length: 1)) } }; } @@ -1339,7 +1339,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "strong", "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); } @@ -1917,7 +1917,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy [MemberData(nameof(EmptyAttributeTagHelperData))] public void Rewrite_UnderstandsEmptyAttributeTagHelpers(string documentContent, object expectedOutput) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, new RazorError[0], "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, new RazorDiagnostic[0], "p"); } public static TheoryData EmptyTagHelperBoundAttributeData @@ -1931,7 +1931,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var boolTypeName = typeof(bool).FullName; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "", @@ -1945,9 +1945,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5) + absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5)) } }, { @@ -1963,7 +1963,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.CodeMarkup(" true").With(new ExpressionChunkGenerator()), AttributeStructure.SingleQuotes) })), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -1980,9 +1980,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5) + absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5)) } }, { @@ -1998,12 +1998,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5), - new RazorError( + absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5)), + RazorDiagnostic.Create(new RazorError( string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 16, lineIndex: 0, columnIndex: 16, length: 5) + absoluteIndex: 16, lineIndex: 0, columnIndex: 16, length: 5)) } }, { @@ -2024,12 +2024,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5), - new RazorError( + absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5)), + RazorDiagnostic.Create(new RazorError( string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 5) + absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 5)) } }, { @@ -2051,9 +2051,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 19, lineIndex: 0, columnIndex: 19, length: 5) + absoluteIndex: 19, lineIndex: 0, columnIndex: 19, length: 5)) } }, { @@ -2072,9 +2072,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5), + absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5)), } }, { @@ -2093,9 +2093,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5), + absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5)), } }, { @@ -2122,9 +2122,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(emptyAttributeError, "bound", "myth", boolTypeName), - absoluteIndex: 31, lineIndex: 0, columnIndex: 31, length: 5), + absoluteIndex: 31, lineIndex: 0, columnIndex: 31, length: 5)), } }, { @@ -2139,9 +2139,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(emptyAttributeError, "BouND", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5), + absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5)), } }, { @@ -2157,12 +2157,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(emptyAttributeError, "BOUND", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5), - new RazorError( + absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5)), + RazorDiagnostic.Create(new RazorError( string.Format(emptyAttributeError, "bOUnd", "myth", boolTypeName), - absoluteIndex: 18, lineIndex: 0, columnIndex: 18, length: 5) + absoluteIndex: 18, lineIndex: 0, columnIndex: 18, length: 5)) } }, { @@ -2180,9 +2180,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(emptyAttributeError, "BOUND", "myth", boolTypeName), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5) + absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 5)) } }, { @@ -2207,7 +2207,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy AttributeStructure.SingleQuotes) } })), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -2233,7 +2233,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy AttributeStructure.SingleQuotes) } })), - new RazorError[0] + new RazorDiagnostic[0] }, }; } @@ -2265,7 +2265,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors); } public static IEnumerable ScriptBlockData @@ -2861,7 +2861,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput) { // Act & Assert - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, Enumerable.Empty(), "input"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, Enumerable.Empty(), "input"); } public static TheoryData MinimizedAttributeData_Document @@ -2869,7 +2869,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy get { var factory = new SpanFactory(); - var noErrors = new RazorError[0]; + var noErrors = new RazorDiagnostic[0]; var errorFormat = "Attribute '{0}' on tag helper element '{1}' requires a value. Tag helper bound " + "attributes of type '{2}' cannot be empty or contain only whitespace."; var emptyKeyFormat = "The tag helper attribute '{0}' in element '{1}' is missing a key. The " + @@ -2900,7 +2900,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("1", index + 16, 0, index + 16))))); // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "", @@ -2926,8 +2926,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-string", "p", stringType), 3, 0, 3, 12) + RazorDiagnostic.Create(new RazorError( + string.Format(errorFormat, "bound-string", "p", stringType), 3, 0, 3, 12)) } }, { @@ -2942,8 +2942,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-string", "input", stringType), 7, 0, 7, 21) + RazorDiagnostic.Create(new RazorError( + string.Format(errorFormat, "bound-required-string", "input", stringType), 7, 0, 7, 21)) } }, { @@ -2958,8 +2958,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-int", "input", intType), 7, 0, 7, 18) + RazorDiagnostic.Create(new RazorError( + string.Format(errorFormat, "bound-required-int", "input", intType), 7, 0, 7, 18)) } }, { @@ -2972,7 +2972,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { new TagHelperAttributeNode("bound-int", null, AttributeStructure.Minimized), })), - new[] { new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 3, 0, 3, 9) } + new[] { RazorDiagnostic.Create(new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 3, 0, 3, 9)) } }, { "", @@ -2986,12 +2986,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormat, "int-dictionary", "input", typeof(IDictionary).Namespace + ".IDictionary"), absoluteIndex: 7, lineIndex: 0, columnIndex: 7, - length: 14), + length: 14)), } }, { @@ -3006,12 +3006,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormat, "string-dictionary", "input", typeof(IDictionary).Namespace + ".IDictionary"), absoluteIndex: 7, lineIndex: 0, columnIndex: 7, - length: 17), + length: 17)), } }, { @@ -3026,18 +3026,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormat, "int-prefix-", "input", typeof(int).FullName), absoluteIndex: 7, lineIndex: 0, columnIndex: 7, - length: 11), - new RazorError( + length: 11)), + RazorDiagnostic.Create(new RazorError( string.Format(emptyKeyFormat, "int-prefix-", "input"), absoluteIndex: 7, lineIndex: 0, columnIndex: 7, - length: 11), + length: 11)), } }, { @@ -3052,18 +3052,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormat, "string-prefix-", "input", typeof(string).FullName), absoluteIndex: 7, lineIndex: 0, columnIndex: 7, - length: 14), - new RazorError( + length: 14)), + RazorDiagnostic.Create(new RazorError( string.Format(emptyKeyFormat, "string-prefix-", "input"), absoluteIndex: 7, lineIndex: 0, columnIndex: 7, - length: 14), + length: 14)), } }, { @@ -3078,12 +3078,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormat, "int-prefix-value", "input", typeof(int).FullName), absoluteIndex: 7, lineIndex: 0, columnIndex: 7, - length: 16), + length: 16)), } }, { @@ -3098,12 +3098,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormat, "string-prefix-value", "input", typeof(string).FullName), absoluteIndex: 7, lineIndex: 0, columnIndex: 7, - length: 19), + length: 19)), } }, { @@ -3118,12 +3118,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormat, "int-prefix-value", "input", typeof(int).FullName), absoluteIndex: 7, lineIndex: 0, columnIndex: 7, - length: 16), + length: 16)), } }, { @@ -3136,7 +3136,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { new TagHelperAttributeNode("string-prefix-value", new MarkupBlock(), AttributeStructure.SingleQuotes), })), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -3151,7 +3151,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.CodeMarkup("3").With(new ExpressionChunkGenerator()), AttributeStructure.SingleQuotes), })), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -3168,7 +3168,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup(" string")), AttributeStructure.SingleQuotes), })), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -3183,12 +3183,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormat, "bound-required-string", "input", stringType), absoluteIndex: 24, lineIndex: 0, columnIndex: 24, - length: 21) + length: 21)) } }, { @@ -3204,8 +3204,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 3, 0, 3, 9), - new RazorError(string.Format(errorFormat, "bound-string", "p", stringType), 13, 0, 13, 12), + RazorDiagnostic.Create(new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 3, 0, 3, 9)), + RazorDiagnostic.Create(new RazorError(string.Format(errorFormat, "bound-string", "p", stringType), 13, 0, 13, 12)), } }, { @@ -3222,14 +3222,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-int", "input", intType), 7, 0, 7, 18), - new RazorError( + RazorDiagnostic.Create(new RazorError( + string.Format(errorFormat, "bound-required-int", "input", intType), 7, 0, 7, 18)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormat, "bound-required-string", "input", stringType), absoluteIndex: 43, lineIndex: 0, columnIndex: 43, - length: 21) + length: 21)) } }, { @@ -3246,9 +3246,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 3, 0, 3, 9), - new RazorError(string.Format(errorFormat, "bound-string", "p", stringType), 13, 0, 13, 12), - new RazorError(string.Format(errorFormat, "bound-string", "p", stringType), 26, 0, 26, 12), + RazorDiagnostic.Create(new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 3, 0, 3, 9)), + RazorDiagnostic.Create(new RazorError(string.Format(errorFormat, "bound-string", "p", stringType), 13, 0, 13, 12)), + RazorDiagnostic.Create(new RazorError(string.Format(errorFormat, "bound-string", "p", stringType), 26, 0, 26, 12)), } }, { @@ -3277,12 +3277,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormat, "bound-string", "p", stringType), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, - length: 12) + length: 12)) } }, { @@ -3311,12 +3311,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormat, "bound-string", "p", stringType), absoluteIndex: 15, lineIndex: 0, columnIndex: 15, - length: 12) + length: 12)) } }, { @@ -3332,12 +3332,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormat, "bound-required-string", "input", stringType), absoluteIndex: 7, lineIndex: 0, columnIndex: 7, - length: 21) + length: 21)) } }, { @@ -3353,12 +3353,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormat, "bound-required-string", "input", stringType), absoluteIndex: 19, lineIndex: 0, columnIndex: 19, - length: 21) + length: 21)) } }, { @@ -3374,8 +3374,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-int", "input", intType), 7, 0, 7, 18) + RazorDiagnostic.Create(new RazorError( + string.Format(errorFormat, "bound-required-int", "input", intType), 7, 0, 7, 18)) } }, { @@ -3391,7 +3391,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 3, 0, 3, 9) + RazorDiagnostic.Create(new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 3, 0, 3, 9)) } }, { @@ -3407,7 +3407,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-required-int", "input", intType), 19, 0, 19, 18) + RazorDiagnostic.Create(new RazorError(string.Format(errorFormat, "bound-required-int", "input", intType), 19, 0, 19, 18)) } }, { @@ -3423,7 +3423,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 15, 0, 15, 9) + RazorDiagnostic.Create(new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 15, 0, 15, 9)) } }, { @@ -3439,8 +3439,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-int", "input", intType), 33, 0, 33, 18) + RazorDiagnostic.Create(new RazorError( + string.Format(errorFormat, "bound-required-int", "input", intType), 33, 0, 33, 18)) } }, { @@ -3456,7 +3456,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 29, 0, 29, 9) + RazorDiagnostic.Create(new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 29, 0, 29, 9)) } }, { @@ -3476,14 +3476,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( - string.Format(errorFormat, "bound-required-int", "input", intType), 10, 0, 10, 18), - new RazorError( + RazorDiagnostic.Create(new RazorError( + string.Format(errorFormat, "bound-required-int", "input", intType), 10, 0, 10, 18)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormat, "bound-required-string", "input", stringType), absoluteIndex: 57, lineIndex: 0, columnIndex: 57, - length: 21), + length: 21)), } }, { @@ -3503,9 +3503,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 6, 0, 6, 9), - new RazorError(string.Format(errorFormat, "bound-string", "p", stringType), 44, 0, 44, 12), - new RazorError(string.Format(errorFormat, "bound-string", "p", stringType), 84, 0, 84, 12), + RazorDiagnostic.Create(new RazorError(string.Format(errorFormat, "bound-int", "p", intType), 6, 0, 6, 9)), + RazorDiagnostic.Create(new RazorError(string.Format(errorFormat, "bound-string", "p", stringType), 44, 0, 44, 12)), + RazorDiagnostic.Create(new RazorError(string.Format(errorFormat, "bound-string", "p", stringType), 84, 0, 84, 12)), } }, }; @@ -3612,12 +3612,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy data[1] = buildStatementBlock(() => data[1] as MarkupBlock); - var errors = data[2] as RazorError[]; + var errors = data[2] as RazorDiagnostic[]; for (var i = 0; i < errors.Length; i++) { var error = errors[i]; - error.Location = SourceLocationTracker.Advance(error.Location, "@{"); + var currentErrorLocation = new SourceLocation(error.Span.AbsoluteIndex, error.Span.LineIndex, error.Span.CharacterIndex); + var newErrorLocation = SourceLocationTracker.Advance(currentErrorLocation, "@{"); + var newError = new RazorError(error.GetMessage(), newErrorLocation, error.Span.Length); + errors[i] = RazorDiagnostic.Create(newError); } } @@ -3630,7 +3633,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy get { var factory = new SpanFactory(); - var noErrors = new RazorError[0]; + var noErrors = new RazorDiagnostic[0]; var errorFormatUnclosed = "Found a malformed '{0}' tag helper. Tag helpers must have a start and " + "end tag or be self closing."; var errorFormatNoCloseAngle = "Missing close angle for tag helper '{0}'."; @@ -3640,7 +3643,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var intType = typeof(int).FullName; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { " errorFormatUnclosed = (location, tagName) => - new RazorError( + Func errorFormatUnclosed = (location, tagName) => + RazorDiagnostic.Create(new RazorError( $"Found a malformed '{tagName}' tag helper. Tag helpers must have a start and end tag or be " + "self closing.", new SourceLocation(location, 0, location), - tagName.Length); - Func errorFormatNoCloseAngle = (location, tagName) => - new RazorError( + tagName.Length)); + Func errorFormatNoCloseAngle = (location, tagName) => + RazorDiagnostic.Create(new RazorError( $"Missing close angle for tag helper '{tagName}'.", new SourceLocation(location, 0, location), - tagName.Length); + tagName.Length)); // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "

", @@ -173,7 +173,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors); } public static TheoryData NestedVoidSelfClosingRequiredParentData @@ -279,7 +279,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData NestedRequiredParentData @@ -354,7 +354,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } [Fact] @@ -381,7 +381,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy descriptors, documentContent, expectedOutput, - expectedErrors: Enumerable.Empty(), + expectedErrors: Enumerable.Empty(), tagHelperPrefix: "th:"); } @@ -409,7 +409,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy descriptors, documentContent, expectedOutput, - expectedErrors: Enumerable.Empty(), + expectedErrors: Enumerable.Empty(), tagHelperPrefix: "th:"); } @@ -433,12 +433,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Build(), }; var expectedErrors = new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( LegacyResources.FormatTagHelpersParseTreeRewriter_FoundMalformedTagHelper("th:strong"), absoluteIndex: 8, lineIndex: 0, columnIndex: 8, - length: 9), + length: 9)), }; // Act & Assert @@ -474,7 +474,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy descriptors, documentContent, expectedOutput, - expectedErrors: Enumerable.Empty(), + expectedErrors: Enumerable.Empty(), tagHelperPrefix: "th:"); } @@ -755,12 +755,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy $"{Environment.NewLine} {Environment.NewLine}

"; var newLineLength = Environment.NewLine.Length; var expectedErrors = new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( LegacyResources.FormatTagHelperParseTreeRewriter_InvalidNestedTag("strong", "p", "br"), absoluteIndex: 8 + newLineLength, lineIndex: 1, columnIndex: 5, - length: 6), + length: 6)), }; var expectedOutput = new MarkupBlock( new MarkupTagHelperBlock("p", @@ -790,12 +790,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var documentContent = ""; var expectedErrors = new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( LegacyResources.FormatTagHelperParseTreeRewriter_InvalidNestedTag("strong", "strong", "br"), absoluteIndex: 18, lineIndex: 0, columnIndex: 18, - length: 6) + length: 6)) }; var expectedOutput = new MarkupBlock( new MarkupTagHelperBlock("strong", @@ -853,7 +853,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, expectedOutput, expectedErrors: new RazorDiagnostic[0]); } [Fact] @@ -889,7 +889,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData AllowedChildrenData @@ -898,8 +898,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - Func nestedTagError = - (childName, parentName, allowed, location, length) => new RazorError( + Func nestedTagError = + (childName, parentName, allowed, location, length) => RazorDiagnostic.Create(new RazorError( LegacyResources.FormatTagHelperParseTreeRewriter_InvalidNestedTag( childName, parentName, @@ -907,16 +907,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy absoluteIndex: location, lineIndex: 0, columnIndex: location, - length: length); - Func nestedContentError = - (parentName, allowed, location, length) => new RazorError( + length: length)); + Func nestedContentError = + (parentName, allowed, location, length) => RazorDiagnostic.Create(new RazorError( LegacyResources.FormatTagHelperParseTreeRewriter_CannotHaveNonTagContent(parentName, allowed), absoluteIndex: location, lineIndex: 0, columnIndex: location, - length: length); + length: length)); - return new TheoryData, MarkupBlock, RazorError[]> + return new TheoryData, MarkupBlock, RazorDiagnostic[]> { { "


", @@ -924,7 +924,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock( new MarkupTagHelperBlock("p", new MarkupTagHelperBlock("br", TagMode.SelfClosing))), - new RazorError[0] + new RazorDiagnostic[0] }, { $"

{Environment.NewLine}
{Environment.NewLine}

", @@ -934,7 +934,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup(Environment.NewLine), new MarkupTagHelperBlock("br", TagMode.SelfClosing), factory.Markup(Environment.NewLine))), - new RazorError[0] + new RazorDiagnostic[0] }, { "


", @@ -1129,7 +1129,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors); } [Fact] @@ -1152,12 +1152,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy BlockFactory.MarkupTagBlock(""; var expectedOutput = new MarkupBlock(blockFactory.MarkupTagBlock("")); var descriptors = new TagHelperDescriptor[] @@ -1253,7 +1253,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var expectedError = new RazorError( + var expectedError = RazorDiagnostic.Create(new RazorError( LegacyResources.FormatTagHelperParseTreeRewriter_InconsistentTagStructure( "InputTagHelper1", "InputTagHelper2", @@ -1262,7 +1262,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy absoluteIndex: 0, lineIndex: 0, columnIndex: 0, - length: 7); + length: 7)); var documentContent = ""; var expectedOutput = new MarkupBlock(new MarkupTagHelperBlock("input", TagMode.StartTagOnly)); var descriptors = new TagHelperDescriptor[] @@ -1711,7 +1711,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData NestedRequiredAttributeData @@ -1964,7 +1964,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorError[0]); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, expectedErrors: new RazorDiagnostic[0]); } public static TheoryData MalformedRequiredAttributeData @@ -1978,12 +1978,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var errorFormatNoCloseAngle = "Missing close angle for tag helper '{0}'."; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { ""), blockFactory.MarkupTagBlock(""))), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(CultureInfo.InvariantCulture, errorFormatNoCloseAngle, "p"), new SourceLocation(1, 0, 1), - length: 1), - new RazorError( + length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(CultureInfo.InvariantCulture, errorFormatUnclosed, "p"), new SourceLocation(1, 0, 1), - length: 1), + length: 1)), } }, { @@ -2103,14 +2103,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy children: blockFactory.MarkupTagBlock("

"))), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(CultureInfo.InvariantCulture, errorFormatNoCloseAngle, "p"), new SourceLocation(1, 0, 1), - length: 1), - new RazorError( + length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(CultureInfo.InvariantCulture, errorFormatUnclosed, "p"), new SourceLocation(1, 0, 1), - length: 1), + length: 1)), } }, { @@ -2124,14 +2124,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(CultureInfo.InvariantCulture, errorFormatNoCloseAngle, "p"), new SourceLocation(1, 0, 1), - length: 1), - new RazorError( + length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(CultureInfo.InvariantCulture, errorFormatNoCloseAngle, "p"), new SourceLocation(17, 0, 17), - length: 1) + length: 1)) } }, { @@ -2146,14 +2146,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy })), new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(CultureInfo.InvariantCulture, errorFormatNoCloseAngle, "p"), new SourceLocation(1, 0, 1), - length: 1), - new RazorError( + length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(CultureInfo.InvariantCulture, errorFormatNoCloseAngle, "p"), new SourceLocation(34, 0, 34), - length: 1) + length: 1)) } }, }; @@ -2179,7 +2179,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // Act & Assert - EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors); + EvaluateData(descriptors, documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors); } public static TheoryData PrefixedTagHelperBoundData @@ -2333,7 +2333,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy (IEnumerable)availableDescriptors, documentContent, (MarkupBlock)expectedOutput, - expectedErrors: Enumerable.Empty(), + expectedErrors: Enumerable.Empty(), tagHelperPrefix: "th:"); } @@ -2365,7 +2365,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "@{}", @@ -2394,12 +2394,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}")))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( + absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalUnclosed, "!text"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5) + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5)) } }, { @@ -2423,7 +2423,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("\"").With(SpanChunkGenerator.Null)), factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{words with spaces}", @@ -2447,7 +2447,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), factory.Markup("words with spaces"), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{}", @@ -2484,7 +2484,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("btn", 34, 0, 34)))), factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{}", @@ -2520,7 +2520,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("'").With(SpanChunkGenerator.Null)), factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, }; } @@ -2560,7 +2560,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "@{}", @@ -2574,12 +2574,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}")))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( + absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalUnclosed, "!text", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5), + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5)), } }, { @@ -2589,9 +2589,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalNotStarted, "!text", CultureInfo.InvariantCulture), - absoluteIndex: 4, lineIndex: 0, columnIndex: 4, length: 5), + absoluteIndex: 4, lineIndex: 0, columnIndex: 4, length: 5)), } }, { @@ -2600,7 +2600,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy () => new MarkupBlock( blockFactory.EscapedMarkupTagBlock("<", "text>", AcceptedCharactersInternal.None), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{words and spaces}", @@ -2609,7 +2609,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("<", "text>", AcceptedCharactersInternal.None), factory.Markup("words and spaces"), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{}", @@ -2619,12 +2619,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.MarkupTagBlock("", AcceptedCharactersInternal.None))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalUnclosed, "!text", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5), - new RazorError( + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatMalformed, "text", CultureInfo.InvariantCulture), - absoluteIndex: 11, lineIndex: 0, columnIndex: 11, length: 4) + absoluteIndex: 11, lineIndex: 0, columnIndex: 11, length: 4)) } }, { @@ -2638,9 +2638,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("text>").Accepts(AcceptedCharactersInternal.None)))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalUnclosed, "text", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 4) + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 4)) } }, { @@ -2650,7 +2650,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("<", "text>", AcceptedCharactersInternal.None), new MarkupTagHelperBlock("text"), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{}", @@ -2669,12 +2669,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}")))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( + absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalUnclosed, "text", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 4) + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 4)) } }, { @@ -2694,12 +2694,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.EmptyHtml()), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalNotStarted, "text", CultureInfo.InvariantCulture), - absoluteIndex: 19, lineIndex: 0, columnIndex: 19, length: 4), - new RazorError( + absoluteIndex: 19, lineIndex: 0, columnIndex: 19, length: 4)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatMalformed, "text", CultureInfo.InvariantCulture), - absoluteIndex: 19, lineIndex: 0, columnIndex: 19, length: 4) + absoluteIndex: 19, lineIndex: 0, columnIndex: 19, length: 4)) } }, }; @@ -2714,7 +2714,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "p", "text"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "p", "text"); } public static TheoryData OptOut_WithPartialTextTagData @@ -2744,7 +2744,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "@{ new MarkupBlock(blockFactory.EscapedMarkupTagBlock("<", "text}"))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( + absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!text}"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 6) + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 6)) } }, { @@ -2770,12 +2770,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock(factory.Markup("}"))))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( + absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!text"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5) + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5)) } }, { @@ -2798,12 +2798,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("}", 15, 0, 15))))))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( + absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!text"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5) + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5)) } }, { @@ -2826,12 +2826,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("btn}", 16, 0, 16))))))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( + absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!text"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5) + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5)) } }, { @@ -2857,12 +2857,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock(factory.Markup("}"))))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( + absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!text"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5) + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5)) } }, { @@ -2889,12 +2889,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock(factory.Markup("}"))))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( + absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!text"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5) + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5)) } } }; @@ -2908,7 +2908,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "text"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "text"); } public static TheoryData OptOut_WithPartialData_CSharp @@ -2938,7 +2938,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "@{ new MarkupBlock(blockFactory.EscapedMarkupTagBlock("<", "}"))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( + absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!}"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)) } }, { @@ -2960,12 +2960,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy () => new MarkupBlock(blockFactory.EscapedMarkupTagBlock("<", "p}"))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( + absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!p}"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 3) + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 3)) } }, { @@ -2975,12 +2975,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("<", "p /", new MarkupBlock(factory.Markup("}"))))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( + absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)) } }, { @@ -3003,12 +3003,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("}", 12, 0, 12))))))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( + absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)) } }, { @@ -3031,12 +3031,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("btn}", 13, 0, 13))))))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( + absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)) } }, { @@ -3066,12 +3066,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("}", 18, 0, 18))))))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( + absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)) } }, { @@ -3097,12 +3097,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock(factory.Markup("}"))))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( + absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)) } }, { @@ -3130,12 +3130,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}"))))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( + absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)) } } }; @@ -3149,7 +3149,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "strong", "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); } public static TheoryData OptOut_WithPartialData_HTML @@ -3256,7 +3256,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy string documentContent, object expectedOutput) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, new RazorError[0], "strong", "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, new RazorDiagnostic[0], "strong", "p"); } public static TheoryData OptOut_WithBlockData_CSharp @@ -3293,7 +3293,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "@{}", @@ -3307,12 +3307,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}")))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( + absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalUnclosed, "!p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2), + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)), } }, { @@ -3322,9 +3322,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalNotStarted, "!p", CultureInfo.InvariantCulture), - absoluteIndex: 4, lineIndex: 0, columnIndex: 4, length: 2), + absoluteIndex: 4, lineIndex: 0, columnIndex: 4, length: 2)), } }, { @@ -3333,7 +3333,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy () => new MarkupBlock( blockFactory.EscapedMarkupTagBlock("<", "p>", AcceptedCharactersInternal.None), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{words and spaces}", @@ -3342,7 +3342,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("<", "p>", AcceptedCharactersInternal.None), factory.Markup("words and spaces"), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{

}", @@ -3352,12 +3352,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalUnclosed, "!p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2), - new RazorError( + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 8, lineIndex: 0, columnIndex: 8, length: 1) + absoluteIndex: 8, lineIndex: 0, columnIndex: 8, length: 1)) } }, { @@ -3368,12 +3368,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None)))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalUnclosed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1), - new RazorError( + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1) + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1)) } }, { @@ -3383,7 +3383,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagHelperBlock("p", blockFactory.EscapedMarkupTagBlock("<", "p>", AcceptedCharactersInternal.None), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None)))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{

}", @@ -3399,15 +3399,15 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}"))))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( + absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalUnclosed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1), - new RazorError( + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1) + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1)) } }, { @@ -3427,12 +3427,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.EmptyHtml()), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalNotStarted, "p", CultureInfo.InvariantCulture), - absoluteIndex: 13, lineIndex: 0, columnIndex: 13, length: 1), - new RazorError( + absoluteIndex: 13, lineIndex: 0, columnIndex: 13, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 13, lineIndex: 0, columnIndex: 13, length: 1) + absoluteIndex: 13, lineIndex: 0, columnIndex: 13, length: 1)) } }, { @@ -3452,18 +3452,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.EmptyHtml()), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalUnclosed, "strong", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 6), - new RazorError( + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 6)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatMalformed, "strong", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 6), - new RazorError( + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 6)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalNotStarted, "strong", CultureInfo.InvariantCulture), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 6), - new RazorError( + absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 6)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatMalformed, "strong", CultureInfo.InvariantCulture), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 6) + absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 6)) } }, { @@ -3481,7 +3481,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.EmptyCSharp().AsStatement(), factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), factory.EmptyHtml()), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{

}", @@ -3504,24 +3504,24 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.EmptyHtml()), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalUnclosed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1), - new RazorError( + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatMalformed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1), - new RazorError( + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatMalformed, "strong", CultureInfo.InvariantCulture), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 6), - new RazorError( + absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 6)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalUnclosed, "!p", CultureInfo.InvariantCulture), - absoluteIndex: 24, lineIndex: 0, columnIndex: 24, length: 2), - new RazorError( + absoluteIndex: 24, lineIndex: 0, columnIndex: 24, length: 2)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatMalformed, "strong", CultureInfo.InvariantCulture), - absoluteIndex: 29, lineIndex: 0, columnIndex: 29, length: 6), - new RazorError( + absoluteIndex: 29, lineIndex: 0, columnIndex: 29, length: 6)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalNotStarted, "!p", CultureInfo.InvariantCulture), - absoluteIndex: 38, lineIndex: 0, columnIndex: 38, length: 2), + absoluteIndex: 38, lineIndex: 0, columnIndex: 38, length: 2)), } }, }; @@ -3556,7 +3556,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "@{}", @@ -3585,12 +3585,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}")))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1), - new RazorError( + absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalUnclosed, "!p"), - absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2) + absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)) } }, { @@ -3614,7 +3614,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("\"").With(SpanChunkGenerator.Null)), factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{words with spaces}", @@ -3638,7 +3638,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), factory.Markup("words with spaces"), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{}", @@ -3675,7 +3675,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("btn", 31, 0, 31)))), factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, { "@{}", @@ -3711,7 +3711,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("'").With(SpanChunkGenerator.Null)), factory.Markup(">").Accepts(AcceptedCharactersInternal.None)), blockFactory.EscapedMarkupTagBlock("", AcceptedCharactersInternal.None))), - new RazorError[0] + new RazorDiagnostic[0] }, }; } @@ -3725,7 +3725,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "strong", "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); } public static TheoryData OptOut_WithBlockData_HTML @@ -3738,26 +3738,26 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "end tag or be self closing."; // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "", new MarkupBlock( blockFactory.EscapedMarkupTagBlock("<", "p>")), - new RazorError[0] + new RazorDiagnostic[0] }, { "", new MarkupBlock( blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "", new MarkupBlock( blockFactory.EscapedMarkupTagBlock("<", "p>"), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "words and spaces", @@ -3765,7 +3765,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("<", "p>"), factory.Markup("words and spaces"), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "

", @@ -3774,9 +3774,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.MarkupTagBlock("

")), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatUnclosed, "p", CultureInfo.InvariantCulture), - absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 1) + absoluteIndex: 6, lineIndex: 0, columnIndex: 6, length: 1)) } }, { @@ -3785,10 +3785,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagHelperBlock("p", blockFactory.EscapedMarkupTagBlock(""))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatUnclosed, "p", CultureInfo.InvariantCulture), new SourceLocation(1, 0, 1), - length: 1) + length: 1)) } }, { @@ -3797,7 +3797,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagHelperBlock("p", blockFactory.EscapedMarkupTagBlock("<", "p>"), blockFactory.EscapedMarkupTagBlock(""))), - new RazorError[0] + new RazorDiagnostic[0] }, { "

", @@ -3807,10 +3807,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock(""))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatUnclosed, "p", CultureInfo.InvariantCulture), new SourceLocation(1, 0, 1), - length: 1) + length: 1)) } }, { @@ -3821,10 +3821,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.MarkupTagBlock("

")), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatUnclosed, "p", CultureInfo.InvariantCulture), new SourceLocation(11, 0, 11), - length: 1) + length: 1)) } }, { @@ -3832,7 +3832,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock( new MarkupTagHelperBlock("strong", blockFactory.EscapedMarkupTagBlock(""))), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -3840,7 +3840,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupTagHelperBlock("strong"), blockFactory.EscapedMarkupTagBlock("<", "p>"), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "

", @@ -3852,10 +3852,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock(""))), new [] { - new RazorError( + RazorDiagnostic.Create(new RazorError( string.Format(errorFormatUnclosed, "p", CultureInfo.InvariantCulture), new SourceLocation(1, 0, 1), - length: 1) + length: 1)) } }, }; @@ -3870,7 +3870,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var blockFactory = new BlockFactory(factory); // documentContent, expectedOutput, expectedErrors - return new TheoryData + return new TheoryData { { "", @@ -3891,7 +3891,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("btn", 11, 0, 11))), factory.Markup("\"").With(SpanChunkGenerator.Null)), factory.Markup(">"))), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -3913,7 +3913,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("\"").With(SpanChunkGenerator.Null)), factory.Markup(">")), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "words and spaces", @@ -3936,7 +3936,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup(">")), factory.Markup("words and spaces"), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -3972,7 +3972,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("btn", 29, 0, 29)))), factory.Markup(">")), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, { "", @@ -4007,7 +4007,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("'").With(SpanChunkGenerator.Null)), factory.Markup(">")), blockFactory.EscapedMarkupTagBlock("")), - new RazorError[0] + new RazorDiagnostic[0] }, }; } @@ -4021,7 +4021,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedOutput, object expectedErrors) { - RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorError[])expectedErrors, "strong", "p"); + RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p"); } public static IEnumerable TextTagsBlockData @@ -4305,10 +4305,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyHtml()); var expectedErrors = new[] { - new RazorError( + RazorDiagnostic.Create(new RazorError( "Encountered end tag \"div\" with no matching start tag. Are your start/end tags properly balanced?", new SourceLocation(9, 0, 9), - 3), + 3)), }; RunParseTreeRewriterTest(documentContent, expectedOutput, expectedErrors); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperRewritingTestBase.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperRewritingTestBase.cs index 6be1b3a5cb..8271cee1a9 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperRewritingTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperRewritingTestBase.cs @@ -16,14 +16,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy RunParseTreeRewriterTest( documentContent, expectedOutput, - errors: Enumerable.Empty(), + errors: Enumerable.Empty(), tagNames: tagNames); } internal void RunParseTreeRewriterTest( string documentContent, MarkupBlock expectedOutput, - IEnumerable errors, + IEnumerable errors, params string[] tagNames) { var descriptors = BuildDescriptors(tagNames); @@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy IEnumerable descriptors, string documentContent, MarkupBlock expectedOutput, - IEnumerable expectedErrors, + IEnumerable 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); } } diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs index 3e25f1c0d7..319dd201c1 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/ParserTestBase.cs @@ -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 directives, Block expectedRoot, params RazorError[] expectedErrors) + internal virtual void ParseBlockTest(string document, IEnumerable 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 directives, Block expected, bool designTime, params RazorError[] expectedErrors) + internal virtual void ParseBlockTest(string document, IEnumerable 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 directives, Block expected, params RazorError[] expectedErrors) + internal virtual void ParseDocumentTest(string document, IEnumerable 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 directives, Block expected, bool designTime, params RazorError[] expectedErrors) + internal virtual void ParseDocumentTest(string document, IEnumerable 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); } } diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/TestSpanBuilder.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/TestSpanBuilder.cs index 5b933b1749..ed7b3aadde 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/TestSpanBuilder.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Legacy/TestSpanBuilder.cs @@ -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);