Changing Analzyer to Analyzer
This commit is contained in:
parent
1aebfa681a
commit
b13f2614de
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Analyzers
|
||||||
if (serviceItem.UseMethod.Name == "BuildServiceProvider")
|
if (serviceItem.UseMethod.Name == "BuildServiceProvider")
|
||||||
{
|
{
|
||||||
context.ReportDiagnostic(Diagnostic.Create(
|
context.ReportDiagnostic(Diagnostic.Create(
|
||||||
StartupAnalzyer.Diagnostics.BuildServiceProviderShouldNotCalledInConfigureServicesMethod,
|
StartupAnalyzer.Diagnostics.BuildServiceProviderShouldNotCalledInConfigureServicesMethod,
|
||||||
serviceItem.Operation.Syntax.GetLocation(),
|
serviceItem.Operation.Syntax.GetLocation(),
|
||||||
serviceItem.UseMethod.Name,
|
serviceItem.UseMethod.Name,
|
||||||
serviceAnalysis.ConfigureServicesMethod.Name));
|
serviceAnalysis.ConfigureServicesMethod.Name));
|
||||||
|
|
@ -10,10 +10,10 @@ namespace Microsoft.AspNetCore.Analyzers
|
||||||
internal class StartupAnalysisBuilder
|
internal class StartupAnalysisBuilder
|
||||||
{
|
{
|
||||||
private readonly Dictionary<INamedTypeSymbol, List<object>> _analysesByType;
|
private readonly Dictionary<INamedTypeSymbol, List<object>> _analysesByType;
|
||||||
private readonly StartupAnalzyer _analyzer;
|
private readonly StartupAnalyzer _analyzer;
|
||||||
private readonly object _lock;
|
private readonly object _lock;
|
||||||
|
|
||||||
public StartupAnalysisBuilder(StartupAnalzyer analyzer, StartupSymbols startupSymbols)
|
public StartupAnalysisBuilder(StartupAnalyzer analyzer, StartupSymbols startupSymbols)
|
||||||
{
|
{
|
||||||
_analyzer = analyzer;
|
_analyzer = analyzer;
|
||||||
StartupSymbols = startupSymbols;
|
StartupSymbols = startupSymbols;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ using Microsoft.CodeAnalysis.Diagnostics;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Analyzers
|
namespace Microsoft.AspNetCore.Analyzers
|
||||||
{
|
{
|
||||||
public partial class StartupAnalzyer : DiagnosticAnalyzer
|
public partial class StartupAnalyzer : DiagnosticAnalyzer
|
||||||
{
|
{
|
||||||
internal static class Diagnostics
|
internal static class Diagnostics
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ using Microsoft.CodeAnalysis.Diagnostics;
|
||||||
namespace Microsoft.AspNetCore.Analyzers
|
namespace Microsoft.AspNetCore.Analyzers
|
||||||
{
|
{
|
||||||
// Events for testability. Allows us to unit test the data we gather from analysis.
|
// Events for testability. Allows us to unit test the data we gather from analysis.
|
||||||
public partial class StartupAnalzyer : DiagnosticAnalyzer
|
public partial class StartupAnalyzer : DiagnosticAnalyzer
|
||||||
{
|
{
|
||||||
internal event EventHandler<IMethodSymbol>? ConfigureServicesMethodFound;
|
internal event EventHandler<IMethodSymbol>? ConfigureServicesMethodFound;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ using Microsoft.CodeAnalysis.Diagnostics;
|
||||||
namespace Microsoft.AspNetCore.Analyzers
|
namespace Microsoft.AspNetCore.Analyzers
|
||||||
{
|
{
|
||||||
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
||||||
public partial class StartupAnalzyer : DiagnosticAnalyzer
|
public partial class StartupAnalyzer : DiagnosticAnalyzer
|
||||||
{
|
{
|
||||||
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => Diagnostics.SupportedDiagnostics;
|
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => Diagnostics.SupportedDiagnostics;
|
||||||
|
|
||||||
|
|
@ -42,7 +42,7 @@ namespace Microsoft.AspNetCore.Analyzers
|
||||||
if (!OptionsFacts.IsEndpointRoutingExplicitlyDisabled(optionsAnalysis))
|
if (!OptionsFacts.IsEndpointRoutingExplicitlyDisabled(optionsAnalysis))
|
||||||
{
|
{
|
||||||
context.ReportDiagnostic(Diagnostic.Create(
|
context.ReportDiagnostic(Diagnostic.Create(
|
||||||
StartupAnalzyer.Diagnostics.UnsupportedUseMvcWithEndpointRouting,
|
StartupAnalyzer.Diagnostics.UnsupportedUseMvcWithEndpointRouting,
|
||||||
middlewareItem.Operation.Syntax.GetLocation(),
|
middlewareItem.Operation.Syntax.GetLocation(),
|
||||||
middlewareItem.UseMethod.Name,
|
middlewareItem.UseMethod.Name,
|
||||||
optionsAnalysis.ConfigureServicesMethod.Name));
|
optionsAnalysis.ConfigureServicesMethod.Name));
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Analyzers
|
||||||
{
|
{
|
||||||
public StartupAnalyzerTest()
|
public StartupAnalyzerTest()
|
||||||
{
|
{
|
||||||
StartupAnalyzer = new StartupAnalzyer();
|
StartupAnalyzer = new StartupAnalyzer();
|
||||||
|
|
||||||
Runner = new AnalyzersDiagnosticAnalyzerRunner(StartupAnalyzer);
|
Runner = new AnalyzersDiagnosticAnalyzerRunner(StartupAnalyzer);
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Analyzers
|
||||||
StartupAnalyzer.ConfigureMethodFound += (sender, method) => ConfigureMethods.Add(method);
|
StartupAnalyzer.ConfigureMethodFound += (sender, method) => ConfigureMethods.Add(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
private StartupAnalzyer StartupAnalyzer { get; }
|
private StartupAnalyzer StartupAnalyzer { get; }
|
||||||
|
|
||||||
private AnalyzersDiagnosticAnalyzerRunner Runner { get; }
|
private AnalyzersDiagnosticAnalyzerRunner Runner { get; }
|
||||||
|
|
||||||
|
|
@ -140,7 +140,7 @@ namespace Microsoft.AspNetCore.Analyzers
|
||||||
diagnostics,
|
diagnostics,
|
||||||
diagnostic =>
|
diagnostic =>
|
||||||
{
|
{
|
||||||
Assert.Same(StartupAnalzyer.Diagnostics.UnsupportedUseMvcWithEndpointRouting, diagnostic.Descriptor);
|
Assert.Same(StartupAnalyzer.Diagnostics.UnsupportedUseMvcWithEndpointRouting, diagnostic.Descriptor);
|
||||||
AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location);
|
AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -172,7 +172,7 @@ namespace Microsoft.AspNetCore.Analyzers
|
||||||
diagnostics,
|
diagnostics,
|
||||||
diagnostic =>
|
diagnostic =>
|
||||||
{
|
{
|
||||||
Assert.Same(StartupAnalzyer.Diagnostics.UnsupportedUseMvcWithEndpointRouting, diagnostic.Descriptor);
|
Assert.Same(StartupAnalyzer.Diagnostics.UnsupportedUseMvcWithEndpointRouting, diagnostic.Descriptor);
|
||||||
AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location);
|
AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -194,17 +194,17 @@ namespace Microsoft.AspNetCore.Analyzers
|
||||||
diagnostics,
|
diagnostics,
|
||||||
diagnostic =>
|
diagnostic =>
|
||||||
{
|
{
|
||||||
Assert.Same(StartupAnalzyer.Diagnostics.UnsupportedUseMvcWithEndpointRouting, diagnostic.Descriptor);
|
Assert.Same(StartupAnalyzer.Diagnostics.UnsupportedUseMvcWithEndpointRouting, diagnostic.Descriptor);
|
||||||
AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MM1"], diagnostic.Location);
|
AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MM1"], diagnostic.Location);
|
||||||
},
|
},
|
||||||
diagnostic =>
|
diagnostic =>
|
||||||
{
|
{
|
||||||
Assert.Same(StartupAnalzyer.Diagnostics.UnsupportedUseMvcWithEndpointRouting, diagnostic.Descriptor);
|
Assert.Same(StartupAnalyzer.Diagnostics.UnsupportedUseMvcWithEndpointRouting, diagnostic.Descriptor);
|
||||||
AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MM2"], diagnostic.Location);
|
AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MM2"], diagnostic.Location);
|
||||||
},
|
},
|
||||||
diagnostic =>
|
diagnostic =>
|
||||||
{
|
{
|
||||||
Assert.Same(StartupAnalzyer.Diagnostics.UnsupportedUseMvcWithEndpointRouting, diagnostic.Descriptor);
|
Assert.Same(StartupAnalyzer.Diagnostics.UnsupportedUseMvcWithEndpointRouting, diagnostic.Descriptor);
|
||||||
AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MM3"], diagnostic.Location);
|
AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MM3"], diagnostic.Location);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -224,7 +224,7 @@ namespace Microsoft.AspNetCore.Analyzers
|
||||||
Assert.Collection(diagnostics,
|
Assert.Collection(diagnostics,
|
||||||
diagnostic =>
|
diagnostic =>
|
||||||
{
|
{
|
||||||
Assert.Same(StartupAnalzyer.Diagnostics.BuildServiceProviderShouldNotCalledInConfigureServicesMethod, diagnostic.Descriptor);
|
Assert.Same(StartupAnalyzer.Diagnostics.BuildServiceProviderShouldNotCalledInConfigureServicesMethod, diagnostic.Descriptor);
|
||||||
AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MM1"], diagnostic.Location);
|
AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MM1"], diagnostic.Location);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue