diff --git a/src/Microsoft.AspNetCore.Razor.Language/AllowedChildTagDescriptor.cs b/src/Microsoft.AspNetCore.Razor.Language/AllowedChildTagDescriptor.cs index 14ea34c493..84a83b3e8c 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/AllowedChildTagDescriptor.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/AllowedChildTagDescriptor.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; namespace Microsoft.AspNetCore.Razor.Language diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpCodeParser.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpCodeParser.cs index 8a720db36b..2f9c1f9e83 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpCodeParser.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/CSharpCodeParser.cs @@ -296,10 +296,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy StringComparison.Ordinal)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatParseError_HelperDirectiveNotAvailable( - SyntaxConstants.CSharp.HelperKeyword), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_HelperDirectiveNotAvailable( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length))); } Context.Builder.CurrentBlock.Type = BlockKindInternal.Expression; @@ -344,24 +342,21 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (At(CSharpSymbolType.WhiteSpace) || At(CSharpSymbolType.NewLine)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS, - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length))); } else if (EndOfFile) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock, - length: 1 /* end of file */); + RazorDiagnosticFactory.CreateParsing_UnexpectedEndOfFileAtStartOfCodeBlock( + new SourceSpan(CurrentStart, contentLength: 1 /* end of file */))); } else { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS( - CurrentSymbol.Content), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), + CurrentSymbol.Content)); } } finally @@ -634,9 +629,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { AcceptUntil(CSharpSymbolType.LessThan); Context.ErrorSink.OnError( - block.Start, - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(block.Name, ")", "("), - length: 1 /* ( */); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(block.Start, contentLength: 1 /* ( */), block.Name, ")", "(")); } // If necessary, put an empty-content marker symbol here @@ -664,9 +658,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (Context.Builder.ActiveBlocks.Any(block => block.Type == BlockKindInternal.Template)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.ParseError_InlineMarkup_Blocks_Cannot_Be_Nested, - length: 1 /* @ */); + RazorDiagnosticFactory.CreateParsing_InlineMarkupBlocksCannotBeNested( + new SourceSpan(CurrentStart, contentLength: 1 /* @ */))); } Output(SpanKindInternal.Code); using (Context.Builder.StartBlock(BlockKindInternal.Template)) @@ -767,9 +760,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy protected virtual void ReservedDirective(bool topLevel) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatParseError_ReservedWord(CurrentSymbol.Content), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_ReservedWord( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), CurrentSymbol.Content)); + AcceptAndMoveNext(); Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None; Span.ChunkGenerator = SpanChunkGenerator.Null; @@ -850,9 +843,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!topLevel) { Context.ErrorSink.OnError( - block.Start, - LegacyResources.ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock, - block.Name.Length); + RazorDiagnosticFactory.CreateParsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock( + new SourceSpan(block.Start, block.Name.Length))); StandardStatement(); } else @@ -1170,11 +1162,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!At(CSharpSymbolType.LeftBrace)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatParseError_SingleLine_ControlFlowStatements_Not_Allowed( + RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), Language.GetSample(CSharpSymbolType.LeftBrace), - CurrentSymbol.Content), - CurrentSymbol.Content.Length); + CurrentSymbol.Content)); } // Parse the statement and then we're done @@ -1333,9 +1324,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (type == CSharpSymbolType.Transition && !isSingleLineMarkup) { Context.ErrorSink.OnError( - loc, - LegacyResources.ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start, - length: 1 /* @ */); + RazorDiagnosticFactory.CreateParsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart( + new SourceSpan(loc, contentLength: 1 /* @ */))); } // Markup block @@ -1417,9 +1407,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (At(CSharpSymbolType.LeftBrace)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.ParseError_Unexpected_Nested_CodeBlock, - length: 1 /* { */); + RazorDiagnosticFactory.CreateParsing_UnexpectedNestedCodeBlock( + new SourceSpan(CurrentStart, contentLength: 1 /* { */))); } // @( or @foo - Nested expression, parse a child block @@ -1513,9 +1502,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (EndOfFile) { Context.ErrorSink.OnError( - block.Start, - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(block.Name, '}', '{'), - length: 1 /* { OR } */); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(block.Start, contentLength: 1 /* { OR } */), block.Name, "}", "{")); } else if (acceptTerminatingBrace) { @@ -1624,9 +1612,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var currentDirective = CurrentSymbol.Content; Context.ErrorSink.OnError( - CurrentStart, - Resources.FormatDirectiveMustAppearAtStartOfLine(currentDirective), - length: currentDirective.Length); + RazorDiagnosticFactory.CreateParsing_DirectiveMustAppearAtStartOfLine( + new SourceSpan(CurrentStart, currentDirective.Length), currentDirective)); break; } } @@ -1662,9 +1649,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy !EndOfFile) { Context.ErrorSink.OnError( - CurrentStart, - Resources.FormatDirectiveTokensMustBeSeparatedByWhitespace(descriptor.Directive), - length: CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_DirectiveTokensMustBeSeparatedByWhitespace( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), descriptor.Directive)); return; } @@ -1700,9 +1686,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else if (EndOfFile) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatUnexpectedEOFAfterDirective(descriptor.Directive, tokenDescriptor.Kind.ToString().ToLowerInvariant()), - length: 1); + RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( + new SourceSpan(CurrentStart, contentLength: 1), + descriptor.Directive, + tokenDescriptor.Kind.ToString().ToLowerInvariant())); return; } @@ -1712,9 +1699,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!NamespaceOrTypeName()) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatDirectiveExpectsTypeName(descriptor.Directive), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsTypeName( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), descriptor.Directive)); return; } @@ -1724,9 +1710,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (!QualifiedIdentifier(out var identifierLength)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatDirectiveExpectsNamespace(descriptor.Directive), - identifierLength); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsNamespace( + new SourceSpan(CurrentStart, identifierLength), descriptor.Directive)); return; } @@ -1740,9 +1725,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatDirectiveExpectsIdentifier(descriptor.Directive), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsIdentifier( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), descriptor.Directive)); return; } break; @@ -1755,9 +1739,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatDirectiveExpectsQuotedStringLiteral(descriptor.Directive), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsQuotedStringLiteral( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), descriptor.Directive)); return; } break; @@ -1789,9 +1772,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy else if (!EndOfFile) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatUnexpectedDirectiveLiteral(descriptor.Directive, LegacyResources.ErrorComponent_Newline), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_UnexpectedDirectiveLiteral( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), + descriptor.Directive, + LegacyResources.ErrorComponent_Newline)); } Span.ChunkGenerator = SpanChunkGenerator.Null; @@ -1854,18 +1838,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { if (Context.SeenDirectives.Contains(descriptor.Directive)) { - UsageError(Resources.FormatDuplicateDirective(descriptor.Directive)); + // There will always be at least 1 child because of the `@` transition. + var directiveStart = Context.Builder.CurrentBlock.Children.First().Start; + var errorLength = /* @ */ 1 + descriptor.Directive.Length; + Context.ErrorSink.OnError( + RazorDiagnosticFactory.CreateParsing_DuplicateDirective( + new SourceSpan(directiveStart, errorLength), descriptor.Directive)); + return; } } - - void UsageError(string message) - { - // There wil always be at least 1 child because of the `@` transition. - var directiveStart = Context.Builder.CurrentBlock.Children.First().Start; - var errorLength = /* @ */ 1 + descriptor.Directive.Length; - Context.ErrorSink.OnError(directiveStart, message, errorLength); - } } private void ParseDirectiveBlock(DirectiveDescriptor descriptor, Action parseChildren) @@ -1873,16 +1855,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (EndOfFile) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatUnexpectedEOFAfterDirective(descriptor.Directive, "{"), - length: 1 /* { */); + RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( + new SourceSpan(CurrentStart, contentLength: 1 /* { */), descriptor.Directive, "{")); } else if (!At(CSharpSymbolType.LeftBrace)) { Context.ErrorSink.OnError( - CurrentStart, - LegacyResources.FormatUnexpectedDirectiveLiteral(descriptor.Directive, "{"), - CurrentSymbol.Content.Length); + RazorDiagnosticFactory.CreateParsing_UnexpectedDirectiveLiteral( + new SourceSpan(CurrentStart, CurrentSymbol.Content.Length), descriptor.Directive, "{")); } else { @@ -1900,9 +1880,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { editHandler.AutoCompleteString = "}"; Context.ErrorSink.OnError( - startingBraceLocation, - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(descriptor.Directive, "}", "{"), - length: 1 /* } */); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(startingBraceLocation, contentLength: 1 /* } */), descriptor.Directive, "}", "{")); } else { @@ -1923,8 +1902,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var directiveStart = Context.Builder.CurrentBlock.Children.First().Start; var errorLength = /* @ */ 1 + SyntaxConstants.CSharp.TagHelperPrefixKeyword.Length; duplicateDiagnostic = RazorDiagnosticFactory.CreateParsing_DuplicateDirective( - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - new SourceSpan(directiveStart, errorLength)); + new SourceSpan(directiveStart, errorLength), + SyntaxConstants.CSharp.TagHelperPrefixKeyword); } TagHelperDirective( @@ -1957,11 +1936,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (char.IsWhiteSpace(character) || InvalidNonWhitespaceNameCharacters.Contains(character)) { diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - Resources.FormatInvalidTagHelperPrefixValue(SyntaxConstants.CSharp.TagHelperPrefixKeyword, character, prefix), - directiveLocation, - prefix.Length))); + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperPrefixValue( + new SourceSpan(directiveLocation, prefix.Length), + SyntaxConstants.CSharp.TagHelperPrefixKeyword, + character, + prefix)); return; } @@ -2036,11 +2015,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy text.EndsWith("'")) { errors.Add( - RazorDiagnostic.Create( - new RazorError( - Resources.FormatInvalidTagHelperLookupText(text), - directiveLocation, - Math.Max(text.Length, 1)))); + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(directiveLocation, Math.Max(text.Length, 1)), text)); return directive; } @@ -2099,59 +2075,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Debug.Assert(string.Equals(CurrentSymbol.Content, directive, StringComparison.Ordinal)); } - protected void BaseTypeDirective(string noTypeNameError, Func createChunkGenerator) - { - var keywordStartLocation = Span.Start; - - // Set the block type - Context.Builder.CurrentBlock.Type = BlockKindInternal.Directive; - - var keywordLength = Span.End.AbsoluteIndex - Span.Start.AbsoluteIndex; - - // Accept whitespace - var remainingWhitespace = AcceptSingleWhiteSpaceCharacter(); - - if (Span.Symbols.Count > 1) - { - Span.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None; - } - - Output(SpanKindInternal.MetaCode); - - if (remainingWhitespace != null) - { - Accept(remainingWhitespace); - } - - AcceptWhile(IsSpacingToken(includeNewLines: false, includeComments: true)); - - if (EndOfFile || At(CSharpSymbolType.WhiteSpace) || At(CSharpSymbolType.NewLine)) - { - Context.ErrorSink.OnError( - keywordStartLocation, - noTypeNameError, - keywordLength); - } - - // Parse to the end of the line - AcceptUntil(CSharpSymbolType.NewLine); - if (!Context.DesignTimeMode) - { - // We want the newline to be treated as code, but it causes issues at design-time. - Optional(CSharpSymbolType.NewLine); - } - - // Pull out the type name - var baseType = string.Concat(Span.Symbols.Select(s => s.Content)); - - // Set up chunk generation - Span.ChunkGenerator = createChunkGenerator(baseType.Trim()); - - // Output the span and finish the block - CompleteBlock(); - Output(SpanKindInternal.Code, AcceptedCharactersInternal.AnyExceptNewline); - } - private void TagHelperDirective(string keyword, Func, ISpanChunkGenerator> chunkGeneratorFactory) { AssertDirective(keyword); @@ -2189,9 +2112,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (EndOfFile || At(CSharpSymbolType.NewLine)) { Context.ErrorSink.OnError( - keywordStartLocation, - LegacyResources.FormatParseError_DirectiveMustHaveValue(keyword), - keywordLength); + RazorDiagnosticFactory.CreateParsing_DirectiveMustHaveValue( + new SourceSpan(keywordStartLocation, keywordLength), keyword)); directiveValue = string.Empty; } @@ -2212,9 +2134,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (startsWithQuote != endsWithQuote) { Context.ErrorSink.OnError( - startLocation, - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(keyword), - rawValue.Length); + RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( + new SourceSpan(startLocation, rawValue.Length), keyword)); } directiveValue = rawValue; diff --git a/src/Microsoft.AspNetCore.Razor.Language/LegacyResources.resx b/src/Microsoft.AspNetCore.Razor.Language/LegacyResources.resx index af753ed15b..27a7c396a5 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/LegacyResources.resx +++ b/src/Microsoft.AspNetCore.Razor.Language/LegacyResources.resx @@ -224,9 +224,10 @@ The "@" character must be followed by a ":", "(", or a C# identifier. If you intended to switch to markup, use an HTML start tag, for example: -@if(isLoggedIn) { +@if(isLoggedIn) {{ <p>Hello, @user!</p> -} +}} + "{{" is an escape sequence for string.Format, when outputted to the user it will be displayed as "{" End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. @@ -272,9 +273,10 @@ Namespace imports and type aliases cannot be placed within code blocks. They must immediately follow an "@" character in markup. It is recommended that you put them at the top of the page, as in the following example: @using System.Drawing; -@{ +@{{ // OK here to use types from System.Drawing in the page. -} +}} + "{{" is an escape sequence for string.Format, when outputted to the user it will be displayed as "{" Outer tag is missing a name. The first character of a markup block must be an HTML tag with a valid name. @@ -321,10 +323,12 @@ Instead, wrap the contents of the block in "{{}}": End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" - Unexpected "{" after "@" character. Once inside the body of a code block (@if {}, @{}, etc.) you do not need to use "@{" to switch to code. + Unexpected "{{" after "@" character. Once inside the body of a code block (@if {{}}, @{{}}, etc.) you do not need to use "@{{" to switch to code. + "{{" is an escape sequence for string.Format, when outputted to the user it will be displayed as "{" - A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. + A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. + "{{" is an escape sequence for string.Format, when outputted to the user it will be displayed as "{" End of file or an unexpected character was reached before the "{0}" tag could be parsed. Elements inside markup blocks must be complete. They must either be self-closing ("<br />") or have matching end tags ("<p>Hello</p>"). If you intended to display a "<" character, use the "&lt;" HTML entity. diff --git a/src/Microsoft.AspNetCore.Razor.Language/Properties/LegacyResources.Designer.cs b/src/Microsoft.AspNetCore.Razor.Language/Properties/LegacyResources.Designer.cs index 73042a77d8..e7ec427c84 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Properties/LegacyResources.Designer.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Properties/LegacyResources.Designer.cs @@ -489,9 +489,9 @@ namespace Microsoft.AspNetCore.Razor.Language /// /// The "@" character must be followed by a ":", "(", or a C# identifier. If you intended to switch to markup, use an HTML start tag, for example: /// - /// @if(isLoggedIn) { + /// @if(isLoggedIn) {{ /// <p>Hello, @user!</p> - /// } + /// }} /// internal static string ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start { @@ -501,9 +501,9 @@ namespace Microsoft.AspNetCore.Razor.Language /// /// The "@" character must be followed by a ":", "(", or a C# identifier. If you intended to switch to markup, use an HTML start tag, for example: /// - /// @if(isLoggedIn) { + /// @if(isLoggedIn) {{ /// <p>Hello, @user!</p> - /// } + /// }} /// internal static string FormatParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start() => GetString("ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start"); @@ -688,9 +688,9 @@ namespace Microsoft.AspNetCore.Razor.Language /// Namespace imports and type aliases cannot be placed within code blocks. They must immediately follow an "@" character in markup. It is recommended that you put them at the top of the page, as in the following example: /// /// @using System.Drawing; - /// @{ + /// @{{ /// // OK here to use types from System.Drawing in the page. - /// } + /// }} /// internal static string ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock { @@ -701,9 +701,9 @@ namespace Microsoft.AspNetCore.Razor.Language /// Namespace imports and type aliases cannot be placed within code blocks. They must immediately follow an "@" character in markup. It is recommended that you put them at the top of the page, as in the following example: /// /// @using System.Drawing; - /// @{ + /// @{{ /// // OK here to use types from System.Drawing in the page. - /// } + /// }} /// internal static string FormatParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock() => GetString("ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock"); @@ -881,7 +881,7 @@ namespace Microsoft.AspNetCore.Razor.Language => GetString("ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock1"); /// - /// Unexpected "{" after "@" character. Once inside the body of a code block (@if {}, @{}, etc.) you do not need to use "@{" to switch to code. + /// Unexpected "{{" after "@" character. Once inside the body of a code block (@if {{}}, @{{}}, etc.) you do not need to use "@{{" to switch to code. /// internal static string ParseError_Unexpected_Nested_CodeBlock { @@ -889,13 +889,13 @@ namespace Microsoft.AspNetCore.Razor.Language } /// - /// Unexpected "{" after "@" character. Once inside the body of a code block (@if {}, @{}, etc.) you do not need to use "@{" to switch to code. + /// Unexpected "{{" after "@" character. Once inside the body of a code block (@if {{}}, @{{}}, etc.) you do not need to use "@{{" to switch to code. /// internal static string FormatParseError_Unexpected_Nested_CodeBlock() => GetString("ParseError_Unexpected_Nested_CodeBlock"); /// - /// A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. + /// A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. /// internal static string ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS { @@ -903,7 +903,7 @@ namespace Microsoft.AspNetCore.Razor.Language } /// - /// A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. + /// A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{{" are valid at the start of a code block and they must occur immediately following "@" with no space in between. /// internal static string FormatParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS() => GetString("ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS"); diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnosticFactory.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnosticFactory.cs index b6b1887b43..21b977af1b 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnosticFactory.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorDiagnosticFactory.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language { @@ -49,6 +50,206 @@ namespace Microsoft.AspNetCore.Razor.Language return RazorDiagnostic.Create(Parsing_BlockCommentNotTerminated, location); } + internal static readonly RazorDiagnosticDescriptor Parsing_HelperDirectiveNotAvailable = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1002", + () => LegacyResources.ParseError_HelperDirectiveNotAvailable, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_HelperDirectiveNotAvailable(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_HelperDirectiveNotAvailable, location, SyntaxConstants.CSharp.HelperKeyword); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedWhiteSpaceAtStartOfCodeBlock = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1003", + () => LegacyResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_UnexpectedWhiteSpaceAtStartOfCodeBlock, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedEndOfFileAtStartOfCodeBlock = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1004", + () => LegacyResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedEndOfFileAtStartOfCodeBlock(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_UnexpectedEndOfFileAtStartOfCodeBlock, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedCharacterAtStartOfCodeBlock = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1005", + () => LegacyResources.ParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedCharacterAtStartOfCodeBlock(SourceSpan location, string content) + { + return RazorDiagnostic.Create(Parsing_UnexpectedCharacterAtStartOfCodeBlock, location, content); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_ExpectedEndOfBlockBeforeEOF = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1006", + () => LegacyResources.ParseError_Expected_EndOfBlock_Before_EOF, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_ExpectedEndOfBlockBeforeEOF(SourceSpan location, string blockName, string closeBlock, string openBlock) + { + return RazorDiagnostic.Create(Parsing_ExpectedEndOfBlockBeforeEOF, location, blockName, closeBlock, openBlock); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_ReservedWord = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1007", + () => LegacyResources.ParseError_ReservedWord, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_ReservedWord(SourceSpan location, string content) + { + return RazorDiagnostic.Create(Parsing_ReservedWord, location, content); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_SingleLineControlFlowStatementsNotAllowed = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1008", + () => LegacyResources.ParseError_SingleLine_ControlFlowStatements_Not_Allowed, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_SingleLineControlFlowStatementsNotAllowed(SourceSpan location, string expected, string actual) + { + return RazorDiagnostic.Create(Parsing_SingleLineControlFlowStatementsNotAllowed, location, expected, actual); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1009", + () => LegacyResources.ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedNestedCodeBlock = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1010", + () => LegacyResources.ParseError_Unexpected_Nested_CodeBlock, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedNestedCodeBlock(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_UnexpectedNestedCodeBlock, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveTokensMustBeSeparatedByWhitespace = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1011", + () => Resources.DirectiveTokensMustBeSeparatedByWhitespace, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveTokensMustBeSeparatedByWhitespace(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveTokensMustBeSeparatedByWhitespace, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedEOFAfterDirective = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1012", + () => LegacyResources.UnexpectedEOFAfterDirective, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedEOFAfterDirective(SourceSpan location, string directiveName, string expectedToken) + { + return RazorDiagnostic.Create(Parsing_UnexpectedEOFAfterDirective, location, directiveName, expectedToken); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveExpectsTypeName = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1013", + () => LegacyResources.DirectiveExpectsTypeName, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveExpectsTypeName(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveExpectsTypeName, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveExpectsNamespace = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1014", + () => LegacyResources.DirectiveExpectsNamespace, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveExpectsNamespace(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveExpectsNamespace, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveExpectsIdentifier = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1015", + () => LegacyResources.DirectiveExpectsIdentifier, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveExpectsIdentifier(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveExpectsIdentifier, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveExpectsQuotedStringLiteral = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1016", + () => LegacyResources.DirectiveExpectsQuotedStringLiteral, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveExpectsQuotedStringLiteral(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveExpectsQuotedStringLiteral, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedDirectiveLiteral = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1017", + () => LegacyResources.UnexpectedDirectiveLiteral, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedDirectiveLiteral(SourceSpan location, string directiveName, string expected) + { + return RazorDiagnostic.Create(Parsing_UnexpectedDirectiveLiteral, location, directiveName, expected); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveMustHaveValue = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1018", + () => LegacyResources.ParseError_DirectiveMustHaveValue, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveMustHaveValue(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveMustHaveValue, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_IncompleteQuotesAroundDirective = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1019", + () => LegacyResources.ParseError_IncompleteQuotesAroundDirective, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_IncompleteQuotesAroundDirective(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_IncompleteQuotesAroundDirective, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_InvalidTagHelperPrefixValue = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1020", + () => Resources.InvalidTagHelperPrefixValue, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_InvalidTagHelperPrefixValue(SourceSpan location, string directiveName, char character, string prefix) + { + return RazorDiagnostic.Create(Parsing_InvalidTagHelperPrefixValue, location, directiveName, character, prefix); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_InvalidTagHelperLookupText = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1020", + () => Resources.InvalidTagHelperLookupText, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_InvalidTagHelperLookupText(SourceSpan location, string lookupText) + { + return RazorDiagnostic.Create(Parsing_InvalidTagHelperLookupText, location, lookupText); + } + #endregion #region Semantic Errors @@ -70,7 +271,7 @@ namespace Microsoft.AspNetCore.Razor.Language $"{DiagnosticPrefix}2001", () => Resources.DuplicateDirective, RazorDiagnosticSeverity.Error); - public static RazorDiagnostic CreateParsing_DuplicateDirective(string directive, SourceSpan location) + public static RazorDiagnostic CreateParsing_DuplicateDirective(SourceSpan location, string directive) { return RazorDiagnostic.Create(Parsing_DuplicateDirective, location, directive); } @@ -85,9 +286,39 @@ namespace Microsoft.AspNetCore.Razor.Language return RazorDiagnostic.Create(Parsing_SectionsCannotBeNested, location, LegacyResources.SectionExample_CS); } - internal static readonly RazorDiagnosticDescriptor TagHelper_CodeBlocksNotSupportedInAttributes = + internal static readonly RazorDiagnosticDescriptor Parsing_InlineMarkupBlocksCannotBeNested = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}2003", + () => LegacyResources.ParseError_InlineMarkup_Blocks_Cannot_Be_Nested, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_InlineMarkupBlocksCannotBeNested(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_InlineMarkupBlocksCannotBeNested, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2004", + () => LegacyResources.ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock(SourceSpan location) + { + return RazorDiagnostic.Create(Parsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock, location); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveMustAppearAtStartOfLine = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2005", + () => Resources.DirectiveMustAppearAtStartOfLine, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveMustAppearAtStartOfLine(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveMustAppearAtStartOfLine, location, directiveName); + } + + internal static readonly RazorDiagnosticDescriptor TagHelper_CodeBlocksNotSupportedInAttributes = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2006", () => LegacyResources.TagHelpers_CodeBlocks_NotSupported_InAttributes, RazorDiagnosticSeverity.Error); public static RazorDiagnostic CreateTagHelper_CodeBlocksNotSupportedInAttributes(SourceSpan location) @@ -98,7 +329,7 @@ namespace Microsoft.AspNetCore.Razor.Language internal static readonly RazorDiagnosticDescriptor TagHelper_InlineMarkupBlocksNotSupportedInAttributes = new RazorDiagnosticDescriptor( - $"{DiagnosticPrefix}2004", + $"{DiagnosticPrefix}2007", () => LegacyResources.TagHelpers_InlineMarkupBlocks_NotSupported_InAttributes, RazorDiagnosticSeverity.Error); public static RazorDiagnostic CreateTagHelper_InlineMarkupBlocksNotSupportedInAttributes(string expectedTypeName, SourceSpan location) diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt index 2f95c8c58a..1cfef392ae 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt @@ -1,12 +1,12 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ9999: The 'page' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,1): Error RZ9999: The 'page' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,7): Error RZ9999: The 'page' directive expects a string surrounded by double quotes. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,7): Error RZ9999: The 'model' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,1): Error RZ9999: The 'model' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,8): Error RZ9999: The 'model' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(10,8): Error RZ9999: The 'inject' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,9): Error RZ9999: The 'inject' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,26): Error RZ9999: The 'inject' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(14,11): Error RZ9999: The 'namespace' directive expects a namespace name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,1): Error RZ9999: The 'namespace' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,12): Error RZ9999: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ2001: The 'page' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,1): Error RZ2001: The 'page' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,7): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,7): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,1): Error RZ2001: The 'model' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,8): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(10,8): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,9): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,26): Error RZ1015: The 'inject' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(14,11): Error RZ1014: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,1): Error RZ2001: The 'namespace' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,12): Error RZ1014: The 'namespace' directive expects a namespace name. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt index 2f95c8c58a..1cfef392ae 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt @@ -1,12 +1,12 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ9999: The 'page' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,1): Error RZ9999: The 'page' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,7): Error RZ9999: The 'page' directive expects a string surrounded by double quotes. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,7): Error RZ9999: The 'model' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,1): Error RZ9999: The 'model' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,8): Error RZ9999: The 'model' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(10,8): Error RZ9999: The 'inject' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,9): Error RZ9999: The 'inject' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,26): Error RZ9999: The 'inject' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(14,11): Error RZ9999: The 'namespace' directive expects a namespace name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,1): Error RZ9999: The 'namespace' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,12): Error RZ9999: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ2001: The 'page' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,1): Error RZ2001: The 'page' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,7): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,7): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,1): Error RZ2001: The 'model' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,8): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(10,8): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,9): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,26): Error RZ1015: The 'inject' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(14,11): Error RZ1014: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,1): Error RZ2001: The 'namespace' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,12): Error RZ1014: The 'namespace' directive expects a namespace name. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt index d076071130..90446dc58b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,12): Error RZ9999: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,12): Error RZ1014: The 'namespace' directive expects a namespace name. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt index d076071130..90446dc58b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,12): Error RZ9999: The 'namespace' directive expects a namespace name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,12): Error RZ1014: The 'namespace' directive expects a namespace name. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.diagnostics.txt index 664a950710..637d1e902b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml(1,7): Error RZ9999: The 'page' directive expects a string surrounded by double quotes. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml(1,7): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.diagnostics.txt index 664a950710..637d1e902b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml(1,7): Error RZ9999: The 'page' directive expects a string surrounded by double quotes. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml(1,7): Error RZ1016: The 'page' directive expects a string surrounded by double quotes. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt index b051568470..2fe8233c66 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml(2,1): Error RZ9999: The 'model' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml(2,1): Error RZ2001: The 'model' directive may only occur once per document. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt index 72a8fa589b..3542c13c86 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt @@ -1,6 +1,6 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,7): Error RZ9999: The 'model' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ9999: The 'model' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,8): Error RZ9999: The 'model' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(6,8): Error RZ9999: The 'inject' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,9): Error RZ9999: The 'inject' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,26): Error RZ9999: The 'inject' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,7): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ2001: The 'model' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,8): Error RZ1013: The 'model' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(6,8): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,9): Error RZ1013: The 'inject' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,26): Error RZ1015: The 'inject' directive expects an identifier. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt index cfbf688e18..c3add1daa9 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,2): Error RZ9999: "namespace" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,2): Error RZ1007: "namespace" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt index b051568470..2fe8233c66 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml(2,1): Error RZ9999: The 'model' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml(2,1): Error RZ2001: The 'model' directive may only occur once per document. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorTagHelperBinderPhaseTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorTagHelperBinderPhaseTest.cs index e4236e7743..9dc31b856f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorTagHelperBinderPhaseTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultRazorTagHelperBinderPhaseTest.cs @@ -29,11 +29,8 @@ namespace Microsoft.AspNetCore.Razor.Language { RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( new SourceSpan(new SourceLocation(14 + Environment.NewLine.Length, 1, 14), contentLength: 1)), - RazorDiagnostic.Create( - new RazorError( - Resources.FormatInvalidTagHelperLookupText("\""), - new SourceLocation(14 + Environment.NewLine.Length, 1, 14), - length: 1)) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(14 + Environment.NewLine.Length, 1, 14), contentLength: 1), "\"") }; var content = @@ -71,11 +68,8 @@ namespace Microsoft.AspNetCore.Razor.Language { RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( new SourceSpan(new SourceLocation(17 + Environment.NewLine.Length, 1, 17), contentLength: 1)), - RazorDiagnostic.Create( - new RazorError( - Resources.FormatInvalidTagHelperLookupText("\""), - new SourceLocation(17 + Environment.NewLine.Length, 1, 17), - length: 1)) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(17 + Environment.NewLine.Length, 1, 17), contentLength: 1), "\"") }; var content = @@ -113,11 +107,8 @@ namespace Microsoft.AspNetCore.Razor.Language { RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( new SourceSpan(new SourceLocation(17 + Environment.NewLine.Length, 1, 17), contentLength: 1)), - RazorDiagnostic.Create( - new RazorError( - Resources.FormatInvalidTagHelperPrefixValue("tagHelperPrefix", "\"", "\""), - new SourceLocation(17 + Environment.NewLine.Length, 1, 17), - length: 1)) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperPrefixValue( + new SourceSpan(new SourceLocation(17 + Environment.NewLine.Length, 1, 17), contentLength: 1), "tagHelperPrefix", '\"', "\""), }; var content = diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/BasicIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/BasicIntegrationTest.cs index cac3abd762..63234e0826 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/BasicIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/BasicIntegrationTest.cs @@ -80,10 +80,9 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests var document = RazorCodeDocument.Create(TestRazorSourceDocument.Create("@!!!", fileName: "test.cshtml")); - var expected = RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("!"), - new SourceLocation("test.cshtml", 1, 0, 1), - length: 1)); + var expected = RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation("test.cshtml", 1, 0, 1), contentLength: 1), + "!"); // Act engine.Process(document); @@ -102,10 +101,8 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests var document = RazorCodeDocument.Create(TestRazorSourceDocument.Create("@{", fileName: "test.cshtml")); - var expected = RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_Code, "}", "{"), - new SourceLocation("test.cshtml", 1, 0, 1), - length: 1)); + var expected = RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation("test.cshtml", 1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"); // Act engine.Process(document); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs index ff07646f2e..9f83bbae65 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpAutoCompleteTest.cs @@ -16,11 +16,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(FunctionsDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(FunctionsDirective.Directive.Directive, "}", "{"), - new SourceLocation(10, 0, 10), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1), FunctionsDirective.Directive.Directive, "}", "{")); // Act & Assert ParseBlockTest( @@ -38,11 +35,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("section", "}", "{"), - new SourceLocation(16, 0, 16), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 1), "section", "}", "{")); // Act & Assert ParseBlockTest( @@ -71,11 +65,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsStatement() .With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" }) ), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF( - LegacyResources.BlockName_Code, "}", "{"), - new SourceLocation(1, 0, 1), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{")); } [Fact] @@ -84,11 +75,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(FunctionsDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("functions", "}", "{"), - new SourceLocation(10, 0, 10), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1), "functions", "}", "{")); // Act & Assert ParseBlockTest( @@ -107,11 +95,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("section", "}", "{"), - new SourceLocation(16, 0, 16), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 1), "section", "}", "{")); // Act & Assert ParseBlockTest( @@ -152,11 +137,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Span(SpanKindInternal.Code, new CSharpSymbol(string.Empty, CSharpSymbolType.Unknown)) .With(new StatementChunkGenerator()) ), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF( - LegacyResources.BlockName_Code, "}", "{"), - new SourceLocation(1, 0, 1), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{")); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs index 7a3ea59679..97ceb54221 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpBlockTest.cs @@ -499,10 +499,8 @@ while(true);", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedChara document, BlockKindInternal.Statement, SpanKindInternal.Code, - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'), - SourceLocation.Zero, - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "foreach", "}", "{")); } [Fact] @@ -516,10 +514,8 @@ while(true);", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedChara SpanKindInternal.Code, RazorDiagnosticFactory.CreateParsing_BlockCommentNotTerminated( new SourceSpan(new SourceLocation(24, 0, 24), contentLength: 1)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'), - SourceLocation.Zero, - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "foreach", "}", "{")); } [Fact] @@ -531,10 +527,8 @@ while(true);", BlockKindInternal.Statement, SpanKindInternal.Code, acceptedChara document, BlockKindInternal.Statement, SpanKindInternal.Code, - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'), - SourceLocation.Zero, - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "foreach", "}", "{")); } [Fact] @@ -1155,10 +1149,8 @@ catch(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code); @"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)), - 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)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), }; // Act & Assert @@ -1194,14 +1186,11 @@ catch(bar) { baz(); }", BlockKindInternal.Statement, SpanKindInternal.Code); Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)); var expectedErrors = new RazorDiagnostic[] { - 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)), - 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)), + RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(13, 0, 13), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 5), + "' />}"), }; // Act & Assert diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs index 2b9c3dec9a..ddbf4f94e8 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpDirectivesTest.cs @@ -60,10 +60,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy }); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - Resources.FormatDuplicateDirective("custom"), - 42 + Environment.NewLine.Length, 1, 0, 7))); + RazorDiagnosticFactory.CreateParsing_DuplicateDirective( + new SourceSpan(new SourceLocation(42 + Environment.NewLine.Length, 1, 0), 7), "custom")); // Act & Assert ParseDocumentTest( @@ -202,10 +200,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken().AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - Resources.FormatDirectiveTokensMustBeSeparatedByWhitespace("custom"), - 17, 0, 17, 9))); + RazorDiagnosticFactory.CreateParsing_DirectiveTokensMustBeSeparatedByWhitespace( + new SourceSpan(new SourceLocation(17, 0, 17), 9), "custom")); // Act & Assert ParseCodeBlockTest( @@ -228,10 +224,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddNamespaceToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsNamespace("custom"), - 8, 0, 8, 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsNamespace( + new SourceSpan(new SourceLocation(8, 0, 8), 7), "custom")); // Act & Assert ParseCodeBlockTest( @@ -253,10 +247,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddNamespaceToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsNamespace("custom"), - 8, 0, 8, 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsNamespace( + new SourceSpan(new SourceLocation(8, 0, 8), 7), "custom")); // Act & Assert ParseCodeBlockTest( @@ -277,10 +269,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddNamespaceToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsNamespace("custom"), - 8, 0, 8, 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsNamespace( + new SourceSpan(new SourceLocation(8, 0, 8), 7), "custom")); // Act & Assert ParseCodeBlockTest( @@ -302,10 +292,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddNamespaceToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsNamespace("custom"), - 8, 0, 8, 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsNamespace( + new SourceSpan(new SourceLocation(8, 0, 8), 7), "custom")); // Act & Assert ParseCodeBlockTest( @@ -386,7 +374,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy "*, Foo", "*", "Foo", - RazorDiagnostic.Create(new RazorError(Resources.FormatDirectiveMustAppearAtStartOfLine("addTagHelper"), new SourceLocation(4, 0, 4), 12)))), + RazorDiagnosticFactory.CreateParsing_DirectiveMustAppearAtStartOfLine( + new SourceSpan(new SourceLocation(4, 0, 4), 12), "addTagHelper"))), Factory.Code(Environment.NewLine).AsStatement(), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None))); } @@ -401,11 +390,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddTypeToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - Resources.FormatDirectiveMustAppearAtStartOfLine("custom"), - new SourceLocation(4, 0, 4), - 6))); + RazorDiagnosticFactory.CreateParsing_DirectiveMustAppearAtStartOfLine( + new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 6), "custom")); // Act & Assert ParseCodeBlockTest( @@ -541,11 +527,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsQuotedStringLiteral("custom"), - new SourceLocation(8, 0, 8), - length: 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsQuotedStringLiteral( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 7), "custom")); // Act & Assert ParseCodeBlockTest( @@ -567,11 +550,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsQuotedStringLiteral("custom"), - new SourceLocation(8, 0, 8), - length: 1))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsQuotedStringLiteral( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 1), "custom")); // Act & Assert ParseCodeBlockTest( @@ -593,11 +573,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsQuotedStringLiteral("custom"), - new SourceLocation(8, 0, 8), - length: 9))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsQuotedStringLiteral( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 9), "custom")); // Act & Assert ParseCodeBlockTest( @@ -619,11 +596,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsQuotedStringLiteral("custom"), - new SourceLocation(8, 0, 8), - length: 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsQuotedStringLiteral( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 7), "custom")); // Act & Assert ParseCodeBlockTest( @@ -761,11 +735,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddMemberToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsIdentifier("custom"), - new SourceLocation(8, 0, 8), - length: 1))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsIdentifier( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 1), "custom")); // Act & Assert ParseCodeBlockTest( @@ -887,11 +858,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedDirectiveLiteral("custom", "line break"), - new SourceLocation(16, 0, 16), - length: 7))); + RazorDiagnosticFactory.CreateParsing_UnexpectedDirectiveLiteral( + new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 7), "custom", "line break")); // Act & Assert ParseCodeBlockTest( @@ -916,11 +884,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedDirectiveLiteral("custom", "{"), - new SourceLocation(16, 0, 16), - length: 5))); + RazorDiagnosticFactory.CreateParsing_UnexpectedDirectiveLiteral( + new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 5), "custom", "{")); // Act & Assert ParseCodeBlockTest( @@ -945,11 +910,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedEOFAfterDirective("custom", "{"), - new SourceLocation(15, 0, 15), - length: 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( + new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 1), "custom", "{")); // Act & Assert ParseCodeBlockTest( @@ -972,11 +934,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy b => b.AddStringToken()); var chunkGenerator = new DirectiveChunkGenerator(descriptor); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("custom", "}", "{"), - new SourceLocation(16, 0, 16), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 1), "custom", "}", "{")); // Act & Assert ParseCodeBlockTest( @@ -998,8 +957,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { // Arrange var expectedDiagnostic = RazorDiagnosticFactory.CreateParsing_DuplicateDirective( - "tagHelperPrefix", - new SourceSpan(null, 22 + Environment.NewLine.Length, 1, 0, 16)); + new SourceSpan(null, 22 + Environment.NewLine.Length, 1, 0, 16), "tagHelperPrefix"); // Act var document = ParseDocument( @@ -1068,9 +1026,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy public void TagHelperPrefixDirective_RequiresValue() { // Arrange - var expectedError = RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_DirectiveMustHaveValue(SyntaxConstants.CSharp.TagHelperPrefixKeyword), - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 15)); + var expectedError = RazorDiagnosticFactory.CreateParsing_DirectiveMustHaveValue( + new SourceSpan(filePath: null, absoluteIndex: 1, lineIndex: 0, characterIndex: 1, length: 15), SyntaxConstants.CSharp.TagHelperPrefixKeyword); // Act & Assert ParseBlockTest("@tagHelperPrefix ", @@ -1095,12 +1052,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 1)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.TagHelperPrefixKeyword), - 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)) + RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( + new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 4), SyntaxConstants.CSharp.TagHelperPrefixKeyword), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperPrefixValue( + new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 4), SyntaxConstants.CSharp.TagHelperPrefixKeyword, '"', "\"Foo"), }; // Act & Assert @@ -1125,12 +1080,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( new SourceSpan(filePath: null, absoluteIndex: 23, lineIndex: 0, characterIndex: 23, length: 1)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.TagHelperPrefixKeyword), - 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)) + RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( + new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 7), SyntaxConstants.CSharp.TagHelperPrefixKeyword), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperPrefixValue( + new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 7), SyntaxConstants.CSharp.TagHelperPrefixKeyword, ' ', "Foo \""), }; // Act & Assert @@ -1152,10 +1105,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - RazorDiagnostic.Create(new RazorError( - Resources.FormatInvalidTagHelperLookupText(string.Empty), - new SourceLocation(18, 0, 18), - length: 1)) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(18, 0, 18), contentLength: 1), string.Empty) }; ParseBlockTest("@removeTagHelper \"\"", @@ -1179,10 +1130,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - RazorDiagnostic.Create(new RazorError( - Resources.FormatInvalidTagHelperLookupText("Foo"), - new SourceLocation(17, 0, 17), - length: 3)) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(17, 0, 17), contentLength: 3), "Foo") }; ParseBlockTest("@removeTagHelper Foo", @@ -1206,10 +1155,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - RazorDiagnostic.Create(new RazorError( - Resources.FormatInvalidTagHelperLookupText("'*, Foo'"), - new SourceLocation(17, 0, 17), - length: 8)) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(17, 0, 17), contentLength: 8), "'*, Foo'") }; ParseBlockTest("@removeTagHelper '*, Foo'", @@ -1231,10 +1178,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - RazorDiagnostic.Create(new RazorError( - Resources.FormatInvalidTagHelperLookupText("Foo"), - new SourceLocation(18, 0, 18), - length: 3)) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(18, 0, 18), contentLength: 3), "Foo") }; ParseBlockTest("@removeTagHelper \"Foo\"", @@ -1278,13 +1223,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var expectedErrors = new[] { - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_DirectiveMustHaveValue(SyntaxConstants.CSharp.RemoveTagHelperKeyword), - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 15)), - RazorDiagnostic.Create(new RazorError( - Resources.FormatInvalidTagHelperLookupText(string.Empty), - new SourceLocation(17, 0, 17), - length: 1)), + RazorDiagnosticFactory.CreateParsing_DirectiveMustHaveValue( + new SourceSpan(filePath: null, absoluteIndex: 1, lineIndex: 0, characterIndex: 1, length: 15), SyntaxConstants.CSharp.RemoveTagHelperKeyword), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(17, 0, 17), contentLength: 1), string.Empty), }; // Act & Assert @@ -1308,13 +1250,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 1)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.RemoveTagHelperKeyword), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 4)), - RazorDiagnostic.Create(new RazorError( - Resources.FormatInvalidTagHelperLookupText("\"Foo"), - new SourceLocation(17, 0, 17), - length: 4)), + RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( + new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 4), SyntaxConstants.CSharp.RemoveTagHelperKeyword), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(17, 0, 17), contentLength: 4), "\"Foo"), }; // Act & Assert @@ -1339,13 +1278,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( new SourceSpan(new SourceLocation(absoluteIndex: 20, lineIndex: 0, characterIndex: 20), contentLength: 1)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.RemoveTagHelperKeyword), - absoluteIndex: 17, lineIndex: 0, columnIndex: 17, length: 4)), - RazorDiagnostic.Create(new RazorError( - Resources.FormatInvalidTagHelperLookupText("Foo\""), - new SourceLocation(17, 0, 17), - length: 4)), + RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( + new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 4), SyntaxConstants.CSharp.RemoveTagHelperKeyword), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(17, 0, 17), contentLength: 4), "Foo\""), }; // Act & Assert @@ -1368,10 +1304,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - RazorDiagnostic.Create(new RazorError( - Resources.FormatInvalidTagHelperLookupText(string.Empty), - new SourceLocation(15, 0, 15), - length: 1)) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 1), string.Empty), }; ParseBlockTest("@addTagHelper \"\"", @@ -1395,10 +1329,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - RazorDiagnostic.Create(new RazorError( - Resources.FormatInvalidTagHelperLookupText("Foo"), - new SourceLocation(14, 0, 14), - length: 3)) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 3), "Foo"), }; ParseBlockTest("@addTagHelper Foo", @@ -1420,10 +1352,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - RazorDiagnostic.Create(new RazorError( - Resources.FormatInvalidTagHelperLookupText("Foo"), - new SourceLocation(15, 0, 15), - length: 3)) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 3), "Foo") }; ParseBlockTest("@addTagHelper \"Foo\"", @@ -1447,10 +1377,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var expectedErrors = new[] { - RazorDiagnostic.Create(new RazorError( - Resources.FormatInvalidTagHelperLookupText("'*, Foo'"), - new SourceLocation(14, 0, 14), - length: 8)) + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 8), "'*, Foo'") }; ParseBlockTest("@addTagHelper '*, Foo'", @@ -1494,13 +1422,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var expectedErrors = new[] { - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_DirectiveMustHaveValue(SyntaxConstants.CSharp.AddTagHelperKeyword), - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 12)), - RazorDiagnostic.Create(new RazorError( - Resources.FormatInvalidTagHelperLookupText(string.Empty), - new SourceLocation(14, 0, 14), - length: 1)), + RazorDiagnosticFactory.CreateParsing_DirectiveMustHaveValue( + new SourceSpan(filePath: null, absoluteIndex: 1, lineIndex: 0, characterIndex: 1, length: 12), SyntaxConstants.CSharp.AddTagHelperKeyword), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 1), string.Empty), }; // Act & Assert @@ -1526,13 +1451,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( new SourceSpan(filePath: null, absoluteIndex: 14, lineIndex: 0, characterIndex: 14, length: 1)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.AddTagHelperKeyword), - absoluteIndex: 14, lineIndex: 0, columnIndex: 14, length: 4)), - RazorDiagnostic.Create(new RazorError( - Resources.FormatInvalidTagHelperLookupText("\"Foo"), - new SourceLocation(14, 0, 14), - length: 4)), + RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( + new SourceSpan(filePath: null, absoluteIndex: 14, lineIndex: 0, characterIndex: 14, length: 4), SyntaxConstants.CSharp.AddTagHelperKeyword), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 4), "\"Foo"), }; // Act & Assert @@ -1557,13 +1479,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( new SourceSpan(filePath: null, absoluteIndex: 17, lineIndex: 0, characterIndex: 17, length: 1)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_IncompleteQuotesAroundDirective(SyntaxConstants.CSharp.AddTagHelperKeyword), - absoluteIndex: 14, lineIndex: 0, columnIndex: 14, length: 4)), - RazorDiagnostic.Create(new RazorError( - Resources.FormatInvalidTagHelperLookupText("Foo\""), - new SourceLocation(14, 0, 14), - length: 4)), + RazorDiagnosticFactory.CreateParsing_IncompleteQuotesAroundDirective( + new SourceSpan(filePath: null, absoluteIndex: 14, lineIndex: 0, characterIndex: 14, length: 4), SyntaxConstants.CSharp.AddTagHelperKeyword), + RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 4), "Foo\""), }; // Act & Assert @@ -1859,24 +1778,20 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var directiveLocation = new SourceLocation(1, 2, 3); - var invalidTagHelperPrefixValueError = - "Invalid tag helper directive '{0}' value. '{1}' is not allowed in prefix '{2}'."; + RazorDiagnostic InvalidPrefixError(int length, char character, string prefix) + { + return RazorDiagnosticFactory.CreateParsing_InvalidTagHelperPrefixValue( + new SourceSpan(directiveLocation, length), SyntaxConstants.CSharp.TagHelperPrefixKeyword, character, prefix); + } - return new TheoryData> + return new TheoryData> { { "th ", directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - ' ', - "th "), - directiveLocation, - length: 3) + InvalidPrefixError(3, ' ', "th "), } }, { @@ -1884,14 +1799,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - '\t', - "th\t"), - directiveLocation, - length: 3) + InvalidPrefixError(3, '\t', "th\t"), } }, { @@ -1899,14 +1807,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - Environment.NewLine[0], - "th" + Environment.NewLine), - directiveLocation, - length: 2 + Environment.NewLine.Length) + InvalidPrefixError(2 + Environment.NewLine.Length, Environment.NewLine[0], "th" + Environment.NewLine), } }, { @@ -1914,14 +1815,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - ' ', - " th "), - directiveLocation, - length: 4) + InvalidPrefixError(4, ' ', " th "), } }, { @@ -1929,14 +1823,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - '@', - "@"), - directiveLocation, - length: 1) + InvalidPrefixError(1, '@', "@"), } }, { @@ -1944,14 +1831,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - '@', - "t@h"), - directiveLocation, - length: 3) + InvalidPrefixError(3, '@', "t@h"), } }, { @@ -1959,14 +1839,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - '!', - "!"), - directiveLocation, - length: 1) + InvalidPrefixError(1, '!', "!"), } }, { @@ -1974,14 +1847,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy directiveLocation, new[] { - new RazorError( - string.Format( - invalidTagHelperPrefixValueError, - SyntaxConstants.CSharp.TagHelperPrefixKeyword, - '!', - "!th"), - directiveLocation, - length: 3) + InvalidPrefixError(3, '!', "!th"), } }, }; @@ -1996,7 +1862,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy object expectedErrors) { // Arrange - var expectedDiagnostics = ((IEnumerable)expectedErrors).Select(RazorDiagnostic.Create); + var expectedDiagnostics = (IEnumerable)expectedErrors; var source = TestRazorSourceDocument.Create(); var options = RazorParserOptions.CreateDefault(); var context = new ParserContext(source, options); @@ -2066,22 +1932,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var parser = new CSharpCodeParser(context); - var expectedErrorMessage = string.Format( - "Invalid tag helper directive look up text '{0}'. The correct look up text " + - "format is: \"name, assemblyName\".", - directiveText); - var directive = new CSharpCodeParser.ParsedDirective() { DirectiveText = directiveText }; var diagnostics = new List(); - var expectedError = RazorDiagnostic.Create( - new RazorError( - expectedErrorMessage, - new SourceLocation(1, 2, 3), - errorLength)); + var expectedError = RazorDiagnosticFactory.CreateParsing_InvalidTagHelperLookupText( + new SourceSpan(new SourceLocation(1, 2, 3), errorLength), directiveText); // Act var result = parser.ParseAddOrRemoveDirective(directive, new SourceLocation(1, 2, 3), diagnostics); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs index d6fb897c82..1629f5f15a 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpErrorTest.cs @@ -19,10 +19,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsImplicitExpression(KeywordSet) .Accepts(AcceptedCharactersInternal.NonWhiteSpace) ), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS('"'), - new SourceLocation(1, 0, 1), - length: 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), + "\"")); } [Fact] @@ -34,10 +33,31 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code("helper") .AsImplicitExpression(KeywordSet) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_HelperDirectiveNotAvailable(SyntaxConstants.CSharp.HelperKeyword), - new SourceLocation(1, 0, 1), - length: 6))); + RazorDiagnosticFactory.CreateParsing_HelperDirectiveNotAvailable( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 6))); + } + + [Fact] + public void ParseBlockWithNestedCodeBlockProducesError() + { + ParseBlockTest("@if { @{} }", + new StatementBlock( + Factory.CodeTransition(), + Factory.Code("if { ") + .AsStatement() + .Accepts(AcceptedCharactersInternal.Any), + new StatementBlock( + Factory.CodeTransition(), + Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None), + Factory.EmptyCSharp() + .AsStatement() + .AutoCompleteWith(autoCompleteString: null), + Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), + Factory.Code(" }") + .AsStatement() + .Accepts(AcceptedCharactersInternal.Any)), + RazorDiagnosticFactory.CreateParsing_UnexpectedNestedCodeBlock( + new SourceSpan(new SourceLocation(7, 0, 7), contentLength: 1))); } [Fact] @@ -60,10 +80,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsStatement() .With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" }) ), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_Code, "}", "{"), - SourceLocation.Zero, - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), LegacyResources.BlockName_Code, "}", "{")); } [Fact] @@ -88,10 +106,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyCSharp() .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS, - new SourceLocation(1, 0, 1), - Environment.NewLine.Length))); + RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(1, 0, 1), Environment.NewLine.Length))); } [Fact] @@ -113,10 +129,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code(" {}" + Environment.NewLine).AsStatement(), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) ), - RazorDiagnostic.Create(new RazorError( - LegacyResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS, - new SourceLocation(6 + Environment.NewLine.Length, 1, 5), - length: 3))); + RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(6 + Environment.NewLine.Length, 1, 5), contentLength: 3))); } [Fact] @@ -136,13 +150,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), Factory.EmptyCSharp().AsStatement() ), - RazorDiagnostic.Create(new RazorError( - LegacyResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock, - 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))); + RazorDiagnosticFactory.CreateParsing_UnexpectedEndOfFileAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(6 + Environment.NewLine.Length, 1, 5), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), LegacyResources.BlockName_Code, "}", "{")); } [Fact] @@ -154,10 +165,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyCSharp() .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("!"), - new SourceLocation(1, 0, 1), - length: 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), + "!")); } [Fact] @@ -169,10 +179,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), Factory.Code($"foo bar{Environment.NewLine}baz").AsExpression() ), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_ExplicitExpression, ')', '('), - SourceLocation.Zero, - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), LegacyResources.BlockName_ExplicitExpression, ")", "(")); } [Fact] @@ -186,10 +194,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), Factory.Code($"foo bar{Environment.NewLine}").AsExpression() ), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_ExplicitExpression, ')', '('), - SourceLocation.Zero, - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), LegacyResources.BlockName_ExplicitExpression, ")", "(")); } [Fact] @@ -289,11 +295,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code(" var foo = bar; if(foo != null) { bar(); } ") .AsStatement() .AutoCompleteWith("}")), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF( - LegacyResources.BlockName_Code, '}', '{'), - SourceLocation.Zero, - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), LegacyResources.BlockName_Code, "}", "{")); } [Fact] @@ -302,10 +305,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(FunctionsDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("functions", '}', '{'), - new SourceLocation(10, 0, 10), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1), "functions", "}", "{")); // Act & Assert ParseBlockTest( @@ -331,10 +332,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("if(foo) { baz(); } else { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("else", '}', '{'), - new SourceLocation(19, 0, 19), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(19, 0, 19), contentLength: 1), "else", "}", "{")); } [Fact] @@ -344,10 +343,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("if(foo) { baz(); } else if { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("else if", '}', '{'), - new SourceLocation(19, 0, 19), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(19, 0, 19), contentLength: 1), "else if", "}", "{")); } [Fact] @@ -357,10 +354,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("do { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("do", '}', '{'), - SourceLocation.Zero, - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "do", "}", "{")); } [Fact] @@ -370,10 +365,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("try { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("try", '}', '{'), - SourceLocation.Zero, - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "try", "}", "{")); } [Fact] @@ -383,10 +376,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("try { baz(); } catch(Foo) { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("catch", '}', '{'), - new SourceLocation(15, 0, 15), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 1), "catch", "}", "{")); } [Fact] @@ -396,10 +387,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("try { baz(); } finally { var foo = bar; if(foo != null) { bar(); } ").AsStatement() ), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("finally", '}', '{'), - new SourceLocation(15, 0, 15), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(15, 0, 15), contentLength: 1), "finally", "}", "{")); } [Fact] @@ -463,9 +452,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy BlockFactory.MarkupTagBlock("

", AcceptedCharactersInternal.None)), Factory.EmptyCSharp().AsStatement() ), - 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))); + RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: 1), "{", "<"), + RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( + new SourceSpan(new SourceLocation(32, 0, 32), contentLength: 1), "{", "<"), + RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( + new SourceSpan(new SourceLocation(48, 0, 48), contentLength: 1), "{", "<")); } [Fact] @@ -475,10 +467,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new StatementBlock( Factory.Code("if(foo)) { var bar = foo; }").AsStatement() ), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_SingleLine_ControlFlowStatements_Not_Allowed("{", ")"), - new SourceLocation(7, 0, 7), - length: 1))); + RazorDiagnosticFactory.CreateParsing_SingleLineControlFlowStatementsNotAllowed( + new SourceSpan(new SourceLocation(7, 0, 7), contentLength: 1), "{", ")")); } [Fact] @@ -496,10 +486,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)), Factory.Code("}").AsStatement() ), - RazorDiagnostic.Create(new RazorError( - LegacyResources.ParseError_AtInCode_Must_Be_Followed_By_Colon_Paren_Or_Identifier_Start, - new SourceLocation(10, 0, 10), - length: 1))); + RazorDiagnosticFactory.CreateParsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart( + new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1))); } [Fact] @@ -597,10 +585,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy SingleSpanBlockTest("if(foo) { var foo = \"blah blah blah blah blah", BlockKindInternal.Statement, SpanKindInternal.Code, RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( new SourceSpan(new SourceLocation(20, 0, 20), contentLength: 1)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("if", '}', '{'), - SourceLocation.Zero, - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "if", "}", "{")); } [Fact] @@ -614,10 +600,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy BlockKindInternal.Statement, SpanKindInternal.Code, RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( new SourceSpan(new SourceLocation(20, 0, 20), contentLength: 1)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("if", '}', '{'), - SourceLocation.Zero, - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), "if", "}", "{")); } [Fact] @@ -685,10 +669,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy keyword + " (foo) { var foo = bar; if(foo != null) { bar(); } ", BlockKindInternal.Statement, SpanKindInternal.Code, - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(keyword, '}', '{'), - SourceLocation.Zero, - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(SourceLocation.Zero, contentLength: 1), keyword, "}", "{")); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs index 484ab6b610..201935bb5e 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() ), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF( - LegacyResources.BlockName_ExplicitExpression, ")", "("), - new SourceLocation(1, 0, 1), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), + LegacyResources.BlockName_ExplicitExpression, + ")", + "(")); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs index c74c0d4283..44e5252e9e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpImplicitExpressionTest.cs @@ -135,10 +135,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyCSharp() .AsImplicitExpression(KeywordSet) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("/"), - new SourceLocation(1, 0, 1), - length: 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), + "/")); } [Fact] @@ -150,10 +149,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyCSharp() .AsImplicitExpression(KeywordSet) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock, - new SourceLocation(1, 0, 1), - length: 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedEndOfFileAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 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 b6495d1eaf..9bbb28d55d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpRazorCommentsTest.cs @@ -157,10 +157,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy LegacyResources.FormatParseError_MissingEndTag("text"), new SourceLocation(7 + Environment.NewLine.Length, 1, 5), length: 4)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(LegacyResources.BlockName_Code, "}", "{"), - new SourceLocation(1, 0, 1), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{")); } [Fact] @@ -186,11 +184,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy LegacyResources.ParseError_RazorComment_Not_Terminated, new SourceLocation(2, 0, 2), length: 2)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF( - LegacyResources.BlockName_Code, "}", "{"), - new SourceLocation(1, 0, 1), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{")); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs index c8bb2e4253..21a2dacf19 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpReservedWordsTest.cs @@ -16,10 +16,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new DirectiveBlock( Factory.MetaCode(word).Accepts(AcceptedCharactersInternal.None) ), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_ReservedWord(word), - SourceLocation.Zero, - word.Length))); + RazorDiagnosticFactory.CreateParsing_ReservedWord( + new SourceSpan(SourceLocation.Zero, word.Length), word)); } [Theory] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs index 8cda823970..3ae95b1994 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSectionTest.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; @@ -16,11 +15,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsIdentifier(SectionDirective.Directive.Directive), - new SourceLocation(8, 0, 8), - length: Environment.NewLine.Length))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsIdentifier( + new SourceSpan(new SourceLocation(8, 0, 8), contentLength: Environment.NewLine.Length), SectionDirective.Directive.Directive)); // Act & Assert ParseDocumentTest( @@ -42,11 +38,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedEOFAfterDirective(SectionDirective.Directive.Directive, "{"), - new SourceLocation(25 + Environment.NewLine.Length, 0, 25 + Environment.NewLine.Length), - length: 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( + new SourceSpan(new SourceLocation(25 + Environment.NewLine.Length, 1, 4), contentLength: 1), + SectionDirective.Directive.Directive, + "{")); // Act & Assert ParseDocumentTest( @@ -69,11 +64,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsIdentifier(SectionDirective.Directive.Directive), - new SourceLocation(17, 0, 17), - length: Environment.NewLine.Length))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsIdentifier( + new SourceSpan(new SourceLocation(17, 0, 17), contentLength: Environment.NewLine.Length), SectionDirective.Directive.Directive)); // Act & Assert ParseDocumentTest( @@ -113,11 +105,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsIdentifier(SectionDirective.Directive.Directive), - new SourceLocation(9, 0, 9), - length: 1))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsIdentifier( + new SourceSpan(new SourceLocation(9, 0, 9), contentLength: 1), SectionDirective.Directive.Directive)); // Act & Assert ParseDocumentTest( @@ -144,11 +133,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedDirectiveLiteral(SectionDirective.Directive.Directive, "{"), - new SourceLocation(12, 0, 12), - length: 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedDirectiveLiteral( + new SourceSpan(new SourceLocation(12, 0, 12), contentLength: 1), + SectionDirective.Directive.Directive, + "{")); // Act & Assert ParseDocumentTest( @@ -176,11 +164,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var erroredChunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); erroredChunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - Resources.FormatDirectiveMustAppearAtStartOfLine("section"), - new SourceLocation(16, 0, 16), - 7))); + RazorDiagnosticFactory.CreateParsing_DirectiveMustAppearAtStartOfLine( + new SourceSpan(new SourceLocation(16, 0, 16), contentLength: 7), "section")); erroredChunkGenerator.Diagnostics.Add( RazorDiagnosticFactory.CreateParsing_SectionsCannotBeNested( new SourceSpan(new SourceLocation(15, 0, 15), 8))); @@ -227,11 +212,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(SectionDirective.Directive.Directive, "}", "{"), - new SourceLocation(13, 0, 13), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(13, 0, 13), contentLength: 1), SectionDirective.Directive.Directive, "}", "{")); // Act & Assert ParseDocumentTest( @@ -260,11 +242,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("section", "}", "{"), - new SourceLocation(13, 0, 13), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(13, 0, 13), contentLength: 1), "section", "}", "{")); // Act & Assert ParseDocumentTest( @@ -289,11 +268,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("section", "}", "{"), - new SourceLocation(13, 0, 13), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(13, 0, 13), contentLength: 1), "section", "}", "{")); // Act & Assert ParseDocumentTest( @@ -325,11 +301,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var newLine = Environment.NewLine; var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("section", "}", "{"), - new SourceLocation(13 + newLine.Length, 1, 0), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(13 + newLine.Length, 1, 0), contentLength: 1), "section", "}", "{")); var spaces = " "; // Act & Assert @@ -369,11 +342,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedEOFAfterDirective(SectionDirective.Directive.Directive, "{"), - new SourceLocation(18 + Environment.NewLine.Length, 0, 18 + Environment.NewLine.Length), - length: 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( + new SourceSpan(new SourceLocation(18 + Environment.NewLine.Length, 1, 0), contentLength: 1), + SectionDirective.Directive.Directive, + "{")); // Act & Assert ParseDocumentTest( diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs index 2bf1223be9..ca472f33f5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpSpecialBlockTest.cs @@ -15,10 +15,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(InheritsDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatUnexpectedEOFAfterDirective(InheritsDirective.Directive.Directive, "type"), - new SourceLocation(9, 0, 9), 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedEOFAfterDirective( + new SourceSpan(new SourceLocation(9, 0, 9), 1), InheritsDirective.Directive.Directive, "type")); // Act & Assert ParseDocumentTest( @@ -56,10 +54,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(InheritsDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatDirectiveExpectsTypeName(InheritsDirective.Directive.Directive), - 25, 0, 25, Environment.NewLine.Length))); + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsTypeName( + new SourceSpan(new SourceLocation(25, 0, 25), Environment.NewLine.Length), + InheritsDirective.Directive.Directive)); // Act & Assert ParseDocumentTest( @@ -87,10 +84,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AutoCompleteWith(autoCompleteString: null), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) ), - RazorDiagnostic.Create(new RazorError( - LegacyResources.ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock, - new SourceLocation(2, 0, 2), - length: 5))); + RazorDiagnosticFactory.CreateParsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 5))); } [Fact] @@ -104,10 +99,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AutoCompleteWith(autoCompleteString: null), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) ), - RazorDiagnostic.Create(new RazorError( - LegacyResources.ParseError_NamespaceImportAndTypeAlias_Cannot_Exist_Within_CodeBlock, - new SourceLocation(2, 0, 2), - length: 5))); + RazorDiagnosticFactory.CreateParsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 5))); } [Fact] @@ -191,11 +184,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Arrange var chunkGenerator = new DirectiveChunkGenerator(FunctionsDirective.Directive); chunkGenerator.Diagnostics.Add( - RazorDiagnostic.Create( - new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("functions", "}", "{"), - new SourceLocation(10, 0, 10), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(10, 0, 10), contentLength: 1), "functions", "}", "{")); // Act & Assert ParseBlockTest( @@ -227,10 +217,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.EmptyCSharp() .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("/"), - new SourceLocation(1, 0, 1), - length: 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 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 e08bc0f5fb..92c19a1808 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpStatementTest.cs @@ -249,9 +249,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var unbalancedParenErrorString = "An opening \"(\" is missing the corresponding closing \")\"."; - var unbalancedBracketCatchErrorString = "The catch 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."; // document, expectedStatement, expectedErrors return new TheoryData @@ -281,7 +278,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory .Code("try { someMethod(); } catch(Exception) when (true) {") .AsStatement()), - new[] { RazorDiagnostic.Create(new RazorError(unbalancedBracketCatchErrorString, 23, 0, 23, 1)) } + new[] + { + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(23, 0, 23), contentLength: 1), "catch", "}", "{") + } }, }; } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs index 90da08a135..0631ff1c7f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpTemplateTest.cs @@ -314,10 +314,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy private static RazorDiagnostic GetNestedTemplateError(int characterIndex) { - return RazorDiagnostic.Create(new RazorError( - LegacyResources.ParseError_InlineMarkup_Blocks_Cannot_Be_Nested, - new SourceLocation(characterIndex, 0, characterIndex), - length: 1)); + return RazorDiagnosticFactory.CreateParsing_InlineMarkupBlocksCannotBeNested( + new SourceSpan(new SourceLocation(characterIndex, 0, characterIndex), contentLength: 1)); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs index b1587e1d89..1d96a65590 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpToMarkupSwitchTest.cs @@ -111,10 +111,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code(" " + Environment.NewLine).AsStatement(), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None) ), true, - 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))); + RazorDiagnosticFactory.CreateParsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart( + new SourceSpan(new SourceLocation(5 + Environment.NewLine.Length, 1, 4), contentLength: 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 723312ff96..903e68f313 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpVerbatimBlockTest.cs @@ -44,10 +44,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy designTime: true, expectedErrors: new[] { - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("}"), - new SourceLocation(2, 0, 2), - length: 1)) + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 1), + "}") }); } @@ -69,10 +68,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy designTime: true, expectedErrors: new[] { - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("."), - new SourceLocation(2, 0, 2), - length: 1)) + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(2, 0, 2), contentLength: 1), + ".") }); } @@ -94,10 +92,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Code(Environment.NewLine).AsStatement(), Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)), /* designTimeParser */ true, - RazorDiagnostic.Create(new RazorError( - LegacyResources.ParseError_Unexpected_WhiteSpace_At_Start_Of_CodeBlock_CS, - new SourceLocation(6 + Environment.NewLine.Length, 1, 5), - Environment.NewLine.Length))); + RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(6 + Environment.NewLine.Length, 1, 5), Environment.NewLine.Length))); } [Fact] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs index 4d8b25494b..275364706a 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlBlockTest.cs @@ -47,11 +47,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock( new MarkupTagBlock( Factory.Markup("<"))))), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF( - LegacyResources.BlockName_Code, "}", "{"), - new SourceLocation(1, 0, 1), - length: 1))); + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{")); } [Fact] @@ -86,10 +83,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy LegacyResources.FormatParseError_UnexpectedEndTag("html"), new SourceLocation(5 + Environment.NewLine.Length * 2, 2, 2), length: 4)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("code", "}", "{"), - new SourceLocation(1, 0, 1), - length: 1)) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), }); } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlDocumentTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlDocumentTest.cs index 52bc87d991..0f06fe578a 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlDocumentTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlDocumentTest.cs @@ -64,10 +64,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), Factory.EmptyHtml()), - RazorDiagnostic.Create(new RazorError( - LegacyResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock, - new SourceLocation(1, 0, 1), - length: 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedEndOfFileAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1))); } [Fact] @@ -159,10 +157,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) .Accepts(AcceptedCharactersInternal.NonWhiteSpace)), Factory.EmptyHtml()), - RazorDiagnostic.Create(new RazorError( - LegacyResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock, - new SourceLocation(5, 0, 5), - length: 1))); + RazorDiagnosticFactory.CreateParsing_UnexpectedEndOfFileAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(5, 0, 5), contentLength: 1))); } [Fact] @@ -788,14 +784,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy Factory.Markup(" />"))); var expectedErrors = new RazorDiagnostic[] { - 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)), - 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)), + RazorDiagnosticFactory.CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(12, 0, 12), contentLength: 1)), + RazorDiagnosticFactory.CreateParsing_UnexpectedCharacterAtStartOfCodeBlock( + new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 4), + "' />"), }; // Act & Assert diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs index f0de083acf..1996c68455 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperBlockRewriterTest.cs @@ -695,9 +695,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy string.Format(CultureInfo.InvariantCulture, errorFormatUnclosed, "p"), new SourceLocation(1, 0, 1), length: 1)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("do", "}", "{"), - absoluteIndex: 11, lineIndex: 0, columnIndex: 11, length: 1)) + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(11, 0, 11), contentLength: 1), "do", "}", "{"), } }, { @@ -718,9 +717,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy string.Format(CultureInfo.InvariantCulture, errorFormatUnclosed, "p"), new SourceLocation(1, 0, 1), length: 1)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("do", "}", "{"), - absoluteIndex: 11, lineIndex: 0, columnIndex: 11, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(11, 0, 11), contentLength: 1), "do", "}", "{"), RazorDiagnosticFactory.CreateParsing_UnterminatedStringLiteral( new SourceSpan(filePath: null, absoluteIndex: 15, lineIndex: 0, characterIndex: 15, length: 1)) } @@ -742,9 +740,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy RazorDiagnostic.Create(new RazorError( string.Format(CultureInfo.InvariantCulture, errorFormatNoCSharp, "p"), absoluteIndex: 3, lineIndex: 0 , columnIndex: 3, length: 30)), - RazorDiagnostic.Create(new RazorError( - LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("do", "}", "{"), - absoluteIndex: 4, lineIndex: 0, columnIndex: 4, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(4, 0, 4), contentLength: 1), "do", "}", "{"), RazorDiagnostic.Create(new RazorError( LegacyResources.FormatParseError_UnexpectedEndTag("p"), absoluteIndex: 31, lineIndex: 0, columnIndex: 31, length: 1)) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperParseTreeRewriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperParseTreeRewriterTest.cs index 41cfa2655e..2a77d0c83e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperParseTreeRewriterTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/TagHelperParseTreeRewriterTest.cs @@ -2346,10 +2346,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var errorFormatNormalUnclosed = "The \"{0}\" element was not closed. All elements must be either self-closing or have a " + "matching end tag."; - var errorMatchingBrace = - "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."; Func, MarkupBlock> buildStatementBlock = (insideBuilder) => { @@ -2394,9 +2390,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}")))), new [] { - RazorDiagnostic.Create(new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalUnclosed, "!text"), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5)) @@ -2541,10 +2536,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var errorFormatNormalNotStarted = "Encountered end tag \"{0}\" with no matching start tag. Are your start/end tags properly " + "balanced?"; - var errorMatchingBrace = - "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."; Func, MarkupBlock> buildStatementBlock = (insideBuilder) => { @@ -2574,9 +2565,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}")))), new [] { - RazorDiagnostic.Create(new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalUnclosed, "!text", CultureInfo.InvariantCulture), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5)), @@ -2669,9 +2659,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}")))), new [] { - RazorDiagnostic.Create(new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalUnclosed, "text", CultureInfo.InvariantCulture), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 4)) @@ -2723,10 +2712,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var errorMatchingBrace = - "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."; var errorEOFMatchingBrace = "End of file or an unexpected character was reached before the \"{0}\" tag could be parsed. " + "Elements inside markup blocks must be complete. They must either be self-closing " + @@ -2752,9 +2737,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy () => new MarkupBlock(blockFactory.EscapedMarkupTagBlock("<", "text}"))), new [] { - RazorDiagnostic.Create(new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!text}"), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 6)) @@ -2770,9 +2754,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock(factory.Markup("}"))))), new [] { - RazorDiagnostic.Create(new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!text"), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5)) @@ -2798,9 +2781,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("}", 15, 0, 15))))))), new [] { - RazorDiagnostic.Create(new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!text"), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5)) @@ -2826,9 +2808,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("btn}", 16, 0, 16))))))), new [] { - RazorDiagnostic.Create(new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!text"), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5)) @@ -2857,9 +2838,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock(factory.Markup("}"))))), new [] { - RazorDiagnostic.Create(new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!text"), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5)) @@ -2889,9 +2869,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock(factory.Markup("}"))))), new [] { - RazorDiagnostic.Create(new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!text"), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 5)) @@ -2917,10 +2896,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { var factory = new SpanFactory(); var blockFactory = new BlockFactory(factory); - var errorMatchingBrace = - "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."; var errorEOFMatchingBrace = "End of file or an unexpected character was reached before the \"{0}\" tag could be parsed. " + "Elements inside markup blocks must be complete. They must either be self-closing " + @@ -2946,9 +2921,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy () => new MarkupBlock(blockFactory.EscapedMarkupTagBlock("<", "}"))), new [] { - RazorDiagnostic.Create(new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!}"), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)) @@ -2960,9 +2934,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy () => new MarkupBlock(blockFactory.EscapedMarkupTagBlock("<", "p}"))), new [] { - RazorDiagnostic.Create(new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!p}"), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 3)) @@ -2975,9 +2948,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy blockFactory.EscapedMarkupTagBlock("<", "p /", new MarkupBlock(factory.Markup("}"))))), new [] { - RazorDiagnostic.Create(new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!p"), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)) @@ -3003,9 +2975,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("}", 12, 0, 12))))))), new [] { - RazorDiagnostic.Create(new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!p"), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)) @@ -3031,9 +3002,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("btn}", 13, 0, 13))))))), new [] { - RazorDiagnostic.Create(new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!p"), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)) @@ -3066,9 +3036,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy value: new LocationTagged("}", 18, 0, 18))))))), new [] { - RazorDiagnostic.Create(new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!p"), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)) @@ -3097,9 +3066,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy new MarkupBlock(factory.Markup("}"))))), new [] { - RazorDiagnostic.Create(new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!p"), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)) @@ -3130,9 +3098,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}"))))), new [] { - RazorDiagnostic.Create(new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), RazorDiagnostic.Create(new RazorError( string.Format(errorEOFMatchingBrace, "!p"), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)) @@ -3274,10 +3241,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var errorFormatNormalNotStarted = "Encountered end tag \"{0}\" with no matching start tag. Are your start/end tags properly " + "balanced?"; - var errorMatchingBrace = - "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."; Func, MarkupBlock> buildStatementBlock = (insideBuilder) => { @@ -3307,9 +3270,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}")))), new [] { - RazorDiagnostic.Create(new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalUnclosed, "!p", CultureInfo.InvariantCulture), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)), @@ -3399,9 +3361,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}"))))), new [] { - RazorDiagnostic.Create(new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalUnclosed, "p", CultureInfo.InvariantCulture), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 1)), @@ -3537,10 +3498,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var errorFormatNormalUnclosed = "The \"{0}\" element was not closed. All elements must be either self-closing or have a " + "matching end tag."; - var errorMatchingBrace = - "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."; Func, MarkupBlock> buildStatementBlock = (insideBuilder) => { @@ -3585,9 +3542,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy factory.Markup("}")))), new [] { - RazorDiagnostic.Create(new RazorError( - errorMatchingBrace, - absoluteIndex: 1, lineIndex: 0, columnIndex: 1, length: 1)), + RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( + new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), LegacyResources.BlockName_Code, "}", "{"), RazorDiagnostic.Create(new RazorError( string.Format(errorFormatNormalUnclosed, "!p"), absoluteIndex: 3, lineIndex: 0, columnIndex: 3, length: 2)) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.diagnostics.txt index 9fb02062cb..c3072c6248 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml(1,2): Error RZ9999: 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml(1,2): Error RZ1006: 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. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.diagnostics.txt index 9fb02062cb..c3072c6248 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml(1,2): Error RZ9999: 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF.cshtml(1,2): Error RZ1006: 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. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.diagnostics.txt index c0a89d2ef4..84ac278f6d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml(2,6): Error RZ9999: 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml(2,6): Error RZ1003: 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. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.diagnostics.txt index c0a89d2ef4..84ac278f6d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml(2,6): Error RZ9999: 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml(2,6): Error RZ1003: 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. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.diagnostics.txt index 862260264e..5524460d0c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml(3,2): Error RZ9999: "!" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml(3,2): Error RZ1005: "!" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.diagnostics.txt index 862260264e..5524460d0c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml(3,2): Error RZ9999: "!" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml(3,2): Error RZ1005: "!" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.diagnostics.txt index 2050eeea35..4e0bfb131d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml(3,2): Error RZ9999: The explicit expression 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml(3,2): Error RZ1006: The explicit expression 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. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.diagnostics.txt index 2050eeea35..4e0bfb131d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml(3,2): Error RZ9999: The explicit expression 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml(3,2): Error RZ1006: The explicit expression 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. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.diagnostics.txt index ee9b4f9d6f..b0a8bd2630 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.diagnostics.txt @@ -1,2 +1,2 @@ TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,11): Error RZ9999: Encountered end tag "div" with no matching start tag. Are your start/end tags properly balanced? -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,7): Error RZ9999: The explicit expression 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,7): Error RZ1006: The explicit expression 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. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.diagnostics.txt index ee9b4f9d6f..b0a8bd2630 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_Runtime.diagnostics.txt @@ -1,2 +1,2 @@ TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,11): Error RZ9999: Encountered end tag "div" with no matching start tag. Are your start/end tags properly balanced? -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,7): Error RZ9999: The explicit expression 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml(1,7): Error RZ1006: The explicit expression 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. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.diagnostics.txt index 1fd198f0e7..e2a8c29095 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml(3,2): Error RZ9999: End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml(3,2): Error RZ1004: End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.diagnostics.txt index 1fd198f0e7..e2a8c29095 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml(3,2): Error RZ9999: End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml(3,2): Error RZ1004: End-of-file was found after the "@" character. "@" must be followed by a valid code block. If you want to output an "@", escape it using the sequence: "@@" diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt index e418c499d1..b01ced2ed2 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_DesignTime.diagnostics.txt @@ -1,27 +1,27 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,2): Error RZ9999: Directive 'addTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,14): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,2): Error RZ9999: Directive 'addTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,15): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,2): Error RZ1018: Directive 'addTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,14): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,2): Error RZ1018: Directive 'addTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,15): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ9999: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,2): Error RZ9999: Directive 'removeTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,17): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,2): Error RZ9999: Directive 'removeTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,18): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ1020: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,2): Error RZ1018: Directive 'removeTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,17): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,2): Error RZ1018: Directive 'removeTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,18): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ9999: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,2): Error RZ9999: Directive 'tagHelperPrefix' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,2): Error RZ9999: Directive 'tagHelperPrefix' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ1020: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,2): Error RZ1018: Directive 'tagHelperPrefix' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,2): Error RZ1018: Directive 'tagHelperPrefix' must have a value. TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,1): Error RZ2001: The 'tagHelperPrefix' directive may only occur once per document. TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,1): Error RZ2001: The 'tagHelperPrefix' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ9999: Invalid tag helper directive 'tagHelperPrefix' value. '"' is not allowed in prefix '"'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,10): Error RZ9999: The 'inherits' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,1): Error RZ9999: The 'inherits' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,11): Error RZ9999: The 'inherits' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(19,1): Error RZ9999: Unexpected literal following the 'functions' directive. Expected '{'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,1): Error RZ9999: Unexpected literal following the 'functions' directive. Expected '{'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,9): Error RZ9999: The 'section' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(22,10): Error RZ9999: The 'section' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(24,10): Error RZ9999: The 'section' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(25,12): Error RZ9999: The functions 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ1020: Invalid tag helper directive 'tagHelperPrefix' value. '"' is not allowed in prefix '"'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,10): Error RZ1013: The 'inherits' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,1): Error RZ2001: The 'inherits' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,11): Error RZ1013: The 'inherits' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(19,1): Error RZ1017: Unexpected literal following the 'functions' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,1): Error RZ1017: Unexpected literal following the 'functions' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,9): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(22,10): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(24,10): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(25,12): Error RZ1006: The functions 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. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt index e418c499d1..b01ced2ed2 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives_Runtime.diagnostics.txt @@ -1,27 +1,27 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,2): Error RZ9999: Directive 'addTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,14): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,2): Error RZ9999: Directive 'addTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,15): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,2): Error RZ1018: Directive 'addTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,14): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,2): Error RZ1018: Directive 'addTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,15): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ9999: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,2): Error RZ9999: Directive 'removeTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,17): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,2): Error RZ9999: Directive 'removeTagHelper' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,18): Error RZ9999: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(5,15): Error RZ1020: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,2): Error RZ1018: Directive 'removeTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,17): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,2): Error RZ1018: Directive 'removeTagHelper' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,18): Error RZ1020: Invalid tag helper directive look up text ''. The correct look up text format is: "name, assemblyName". TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ9999: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,2): Error RZ9999: Directive 'tagHelperPrefix' must have a value. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,2): Error RZ9999: Directive 'tagHelperPrefix' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(9,18): Error RZ1020: Invalid tag helper directive look up text '"'. The correct look up text format is: "name, assemblyName". +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(11,2): Error RZ1018: Directive 'tagHelperPrefix' must have a value. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,2): Error RZ1018: Directive 'tagHelperPrefix' must have a value. TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(12,1): Error RZ2001: The 'tagHelperPrefix' directive may only occur once per document. TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ1000: Unterminated string literal. Strings that start with a quotation mark (") must be terminated before the end of the line. However, strings that start with @ and a quotation mark (@") can span multiple lines. TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,1): Error RZ2001: The 'tagHelperPrefix' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ9999: Invalid tag helper directive 'tagHelperPrefix' value. '"' is not allowed in prefix '"'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,10): Error RZ9999: The 'inherits' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,1): Error RZ9999: The 'inherits' directive may only occur once per document. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,11): Error RZ9999: The 'inherits' directive expects a type name. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(19,1): Error RZ9999: Unexpected literal following the 'functions' directive. Expected '{'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,1): Error RZ9999: Unexpected literal following the 'functions' directive. Expected '{'. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,9): Error RZ9999: The 'section' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(22,10): Error RZ9999: The 'section' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(24,10): Error RZ9999: The 'section' directive expects an identifier. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(25,12): Error RZ9999: The functions 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(13,18): Error RZ1020: Invalid tag helper directive 'tagHelperPrefix' value. '"' is not allowed in prefix '"'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(15,10): Error RZ1013: The 'inherits' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,1): Error RZ2001: The 'inherits' directive may only occur once per document. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(16,11): Error RZ1013: The 'inherits' directive expects a type name. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(19,1): Error RZ1017: Unexpected literal following the 'functions' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,1): Error RZ1017: Unexpected literal following the 'functions' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(21,9): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(22,10): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(24,10): Error RZ1015: The 'section' directive expects an identifier. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(25,12): Error RZ1006: The functions 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. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_DesignTime.diagnostics.txt index 78599522c6..66af9b7600 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks.cshtml(1,14): Error RZ9999: Unexpected literal following the 'section' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks.cshtml(1,14): Error RZ1017: Unexpected literal following the 'section' directive. Expected '{'. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.diagnostics.txt index 78599522c6..66af9b7600 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks.cshtml(1,14): Error RZ9999: Unexpected literal following the 'section' directive. Expected '{'. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks.cshtml(1,14): Error RZ1017: Unexpected literal following the 'section' directive. Expected '{'. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.diagnostics.txt index 3d3db9befd..6f37373476 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.diagnostics.txt @@ -1,3 +1,3 @@ TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(4,3): Error RZ9999: Encountered end tag "body" with no matching start tag. Are your start/end tags properly balanced? TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(5,3): Error RZ9999: Encountered end tag "html" with no matching start tag. Are your start/end tags properly balanced? -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(3,2): Error RZ9999: The if 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(3,2): Error RZ1006: The if 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. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.diagnostics.txt index 3d3db9befd..6f37373476 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_Runtime.diagnostics.txt @@ -1,3 +1,3 @@ TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(4,3): Error RZ9999: Encountered end tag "body" with no matching start tag. Are your start/end tags properly balanced? TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(5,3): Error RZ9999: Encountered end tag "html" with no matching start tag. Are your start/end tags properly balanced? -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(3,2): Error RZ9999: The if 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf.cshtml(3,2): Error RZ1006: The if 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. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.diagnostics.txt index 3c7606cc34..1a25d90e26 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.diagnostics.txt @@ -1,2 +1,2 @@ TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(2,1): Error RZ1001: End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(1,2): Error RZ9999: 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(1,2): Error RZ1006: 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. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.diagnostics.txt index 3c7606cc34..1a25d90e26 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_Runtime.diagnostics.txt @@ -1,2 +1,2 @@ TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(2,1): Error RZ1001: End of file was reached before the end of the block comment. All comments started with "/*" sequence must be terminated with a matching "*/" sequence. -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(1,2): Error RZ9999: 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. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError.cshtml(1,2): Error RZ1006: 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. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_DesignTime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_DesignTime.diagnostics.txt index e966770db2..cc0379e358 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_DesignTime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_DesignTime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes.cshtml(7,12): Error RZ9999: "class" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes.cshtml(7,12): Error RZ1007: "class" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.diagnostics.txt index e966770db2..cc0379e358 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.diagnostics.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes_Runtime.diagnostics.txt @@ -1 +1 @@ -TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes.cshtml(7,12): Error RZ9999: "class" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. +TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TransitionsInTagHelperAttributes.cshtml(7,12): Error RZ1007: "class" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used.