Use DefaultRazorDiagnostic in DefaultDirectiveSyntaxTreePass
This commit is contained in:
parent
4164821e4c
commit
6bbd063e26
|
|
@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
|||
{
|
||||
private const string DiagnosticPrefix = "RZ";
|
||||
|
||||
public static readonly RazorDiagnosticDescriptor ViewComponent_CannotFindMethod =
|
||||
internal static readonly RazorDiagnosticDescriptor ViewComponent_CannotFindMethod =
|
||||
new RazorDiagnosticDescriptor(
|
||||
$"{DiagnosticPrefix}3900",
|
||||
() => ViewComponentResources.ViewComponent_CannotFindMethod,
|
||||
|
|
@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
|||
return diagnostic;
|
||||
}
|
||||
|
||||
public static readonly RazorDiagnosticDescriptor ViewComponent_AmbiguousMethods =
|
||||
internal static readonly RazorDiagnosticDescriptor ViewComponent_AmbiguousMethods =
|
||||
new RazorDiagnosticDescriptor(
|
||||
$"{DiagnosticPrefix}3901",
|
||||
() => ViewComponentResources.ViewComponent_AmbiguousMethods,
|
||||
|
|
@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
|||
return diagnostic;
|
||||
}
|
||||
|
||||
public static readonly RazorDiagnosticDescriptor ViewComponent_AsyncMethod_ShouldReturnTask =
|
||||
internal static readonly RazorDiagnosticDescriptor ViewComponent_AsyncMethod_ShouldReturnTask =
|
||||
new RazorDiagnosticDescriptor(
|
||||
$"{DiagnosticPrefix}3902",
|
||||
() => ViewComponentResources.ViewComponent_AsyncMethod_ShouldReturnTask,
|
||||
|
|
@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
|||
return diagnostic;
|
||||
}
|
||||
|
||||
public static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_ShouldReturnValue =
|
||||
internal static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_ShouldReturnValue =
|
||||
new RazorDiagnosticDescriptor(
|
||||
$"{DiagnosticPrefix}3903",
|
||||
() => ViewComponentResources.ViewComponent_SyncMethod_ShouldReturnValue,
|
||||
|
|
@ -82,7 +82,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
|||
return diagnostic;
|
||||
}
|
||||
|
||||
public static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_CannotReturnTask =
|
||||
internal static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_CannotReturnTask =
|
||||
new RazorDiagnosticDescriptor(
|
||||
$"{DiagnosticPrefix}3904",
|
||||
() => ViewComponentResources.ViewComponent_SyncMethod_CannotReturnTask,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
|
|||
{
|
||||
private const string DiagnosticPrefix = "RZ";
|
||||
|
||||
public static readonly RazorDiagnosticDescriptor ViewComponent_CannotFindMethod =
|
||||
internal static readonly RazorDiagnosticDescriptor ViewComponent_CannotFindMethod =
|
||||
new RazorDiagnosticDescriptor(
|
||||
$"{DiagnosticPrefix}3900",
|
||||
() => ViewComponentResources.ViewComponent_CannotFindMethod,
|
||||
|
|
@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
|
|||
return diagnostic;
|
||||
}
|
||||
|
||||
public static readonly RazorDiagnosticDescriptor ViewComponent_AmbiguousMethods =
|
||||
internal static readonly RazorDiagnosticDescriptor ViewComponent_AmbiguousMethods =
|
||||
new RazorDiagnosticDescriptor(
|
||||
$"{DiagnosticPrefix}3901",
|
||||
() => ViewComponentResources.ViewComponent_AmbiguousMethods,
|
||||
|
|
@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
|
|||
return diagnostic;
|
||||
}
|
||||
|
||||
public static readonly RazorDiagnosticDescriptor ViewComponent_AsyncMethod_ShouldReturnTask =
|
||||
internal static readonly RazorDiagnosticDescriptor ViewComponent_AsyncMethod_ShouldReturnTask =
|
||||
new RazorDiagnosticDescriptor(
|
||||
$"{DiagnosticPrefix}3902",
|
||||
() => ViewComponentResources.ViewComponent_AsyncMethod_ShouldReturnTask,
|
||||
|
|
@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
|
|||
return diagnostic;
|
||||
}
|
||||
|
||||
public static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_ShouldReturnValue =
|
||||
internal static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_ShouldReturnValue =
|
||||
new RazorDiagnosticDescriptor(
|
||||
$"{DiagnosticPrefix}3903",
|
||||
() => ViewComponentResources.ViewComponent_SyncMethod_ShouldReturnValue,
|
||||
|
|
@ -82,7 +82,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
|
|||
return diagnostic;
|
||||
}
|
||||
|
||||
public static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_CannotReturnTask =
|
||||
internal static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_CannotReturnTask =
|
||||
new RazorDiagnosticDescriptor(
|
||||
$"{DiagnosticPrefix}3904",
|
||||
() => ViewComponentResources.ViewComponent_SyncMethod_CannotReturnTask,
|
||||
|
|
@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
|
|||
return diagnostic;
|
||||
}
|
||||
|
||||
public static readonly RazorDiagnosticDescriptor PageDirective_CannotBeImported =
|
||||
internal static readonly RazorDiagnosticDescriptor PageDirective_CannotBeImported =
|
||||
new RazorDiagnosticDescriptor(
|
||||
$"{DiagnosticPrefix}3905",
|
||||
() => Resources.PageDirectiveCannotBeImported,
|
||||
|
|
|
|||
|
|
@ -45,11 +45,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
{
|
||||
var directiveStart = block.Children.First(child => !child.IsBlock && ((Span)child).Kind == SpanKindInternal.Transition).Start;
|
||||
var errorLength = /* @ */ 1 + SectionDirective.Directive.Directive.Length;
|
||||
var error = RazorDiagnostic.Create(
|
||||
new RazorError(
|
||||
LegacyResources.FormatParseError_Sections_Cannot_Be_Nested(LegacyResources.SectionExample_CS),
|
||||
directiveStart,
|
||||
errorLength));
|
||||
var error = RazorDiagnosticFactory.CreateParsing_SectionsCannotBeNested(new SourceSpan(directiveStart, errorLength));
|
||||
chunkGenerator.Diagnostics.Add(error);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
|
||||
// General Errors ID Offset = 0
|
||||
|
||||
public static readonly RazorDiagnosticDescriptor Directive_BlockDirectiveCannotBeImported =
|
||||
internal static readonly RazorDiagnosticDescriptor Directive_BlockDirectiveCannotBeImported =
|
||||
new RazorDiagnosticDescriptor(
|
||||
$"{DiagnosticPrefix}0000",
|
||||
() => Resources.BlockDirectiveCannotBeImported,
|
||||
|
|
@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
|
||||
// Semantic Errors ID Offset = 2000
|
||||
|
||||
public static readonly RazorDiagnosticDescriptor CodeTarget_UnsupportedExtension =
|
||||
internal static readonly RazorDiagnosticDescriptor CodeTarget_UnsupportedExtension =
|
||||
new RazorDiagnosticDescriptor(
|
||||
$"{DiagnosticPrefix}2000",
|
||||
() => Resources.Diagnostic_CodeTarget_UnsupportedExtension,
|
||||
|
|
@ -55,6 +55,16 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
return RazorDiagnostic.Create(Parsing_DuplicateDirective, location, directive);
|
||||
}
|
||||
|
||||
internal static readonly RazorDiagnosticDescriptor Parsing_SectionsCannotBeNested =
|
||||
new RazorDiagnosticDescriptor(
|
||||
$"{DiagnosticPrefix}2002",
|
||||
() => LegacyResources.ParseError_Sections_Cannot_Be_Nested,
|
||||
RazorDiagnosticSeverity.Error);
|
||||
public static RazorDiagnostic CreateParsing_SectionsCannotBeNested(SourceSpan location)
|
||||
{
|
||||
return RazorDiagnostic.Create(Parsing_SectionsCannotBeNested, location, LegacyResources.SectionExample_CS);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TagHelper Errors
|
||||
|
|
@ -116,7 +126,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
() => Resources.TagHelper_InvalidBoundAttributeName,
|
||||
RazorDiagnosticSeverity.Error);
|
||||
public static RazorDiagnostic CreateTagHelper_InvalidBoundAttributeName(
|
||||
string tagHelperDisplayName,
|
||||
string tagHelperDisplayName,
|
||||
string propertyDisplayName,
|
||||
string invalidName,
|
||||
char invalidCharacter)
|
||||
|
|
|
|||
|
|
@ -182,11 +182,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
new SourceLocation(16, 0, 16),
|
||||
7)));
|
||||
erroredChunkGenerator.Diagnostics.Add(
|
||||
RazorDiagnostic.Create(
|
||||
new RazorError(
|
||||
LegacyResources.FormatParseError_Sections_Cannot_Be_Nested(LegacyResources.SectionExample_CS),
|
||||
new SourceLocation(15, 0, 15),
|
||||
8)));
|
||||
RazorDiagnosticFactory.CreateParsing_SectionsCannotBeNested(
|
||||
new SourceSpan(new SourceLocation(15, 0, 15), 8)));
|
||||
|
||||
// Act & Assert
|
||||
ParseDocumentTest(
|
||||
|
|
|
|||
Loading…
Reference in New Issue