Skip to content

Commit 72c939e

Browse files
committed
MinimalActions -> DelegateEndpoints in analyzer
1 parent 86f7439 commit 72c939e

File tree

5 files changed

+19
-23
lines changed

5 files changed

+19
-23
lines changed

src/Framework/Analyzer/src/MinimalActions/MinimalActionAnalyzer.cs renamed to src/Framework/Analyzer/src/DelegateEndpoints/DelegateEndpointAnalyzer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
using Microsoft.CodeAnalysis.Diagnostics;
99
using Microsoft.CodeAnalysis.Operations;
1010

11-
namespace Microsoft.AspNetCore.Analyzers.MinimalActions;
11+
namespace Microsoft.AspNetCore.Analyzers.DelegateEndpoints;
1212

1313
[DiagnosticAnalyzer(LanguageNames.CSharp)]
14-
public partial class MinimalActionAnalyzer : DiagnosticAnalyzer
14+
public partial class DelegateEndpointAnalyzer : DiagnosticAnalyzer
1515
{
1616
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create(new[]
1717
{
18-
DiagnosticDescriptors.DoNotUseModelBindingAttributesOnMinimalActionParameters,
18+
DiagnosticDescriptors.DoNotUseModelBindingAttributesOnDelegateEndpointParameters,
1919
});
2020

2121
public override void Initialize(AnalysisContext context)
@@ -35,7 +35,7 @@ public override void Initialize(AnalysisContext context)
3535
{
3636
var invocation = (IInvocationOperation)operationAnalysisContext.Operation;
3737
var targetMethod = invocation.TargetMethod;
38-
if (IsMapActionInvocation(wellKnownTypes, invocation, targetMethod))
38+
if (IsDelegateHandlerInvocation(wellKnownTypes, invocation, targetMethod))
3939
{
4040
return;
4141
}
@@ -60,13 +60,13 @@ public override void Initialize(AnalysisContext context)
6060
});
6161
}
6262

63-
private static bool IsMapActionInvocation(
63+
private static bool IsDelegateHandlerInvocation(
6464
WellKnownTypes wellKnownTypes,
6565
IInvocationOperation invocation,
6666
IMethodSymbol targetMethod)
6767
{
6868
return !targetMethod.Name.StartsWith("Map", StringComparison.Ordinal) ||
69-
!SymbolEqualityComparer.Default.Equals(wellKnownTypes.MinimalActionEndpointRouteBuilderExtensions, targetMethod.ContainingType) ||
69+
!SymbolEqualityComparer.Default.Equals(wellKnownTypes.DelegateEndpointRouteBuilderExtensions, targetMethod.ContainingType) ||
7070
invocation.Arguments.Length != 3;
7171
}
7272
}

src/Framework/Analyzer/src/MinimalActions/DiagnosticDescriptors.cs renamed to src/Framework/Analyzer/src/DelegateEndpoints/DiagnosticDescriptors.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33

44
using Microsoft.CodeAnalysis;
55

6-
namespace Microsoft.AspNetCore.Analyzers.MinimalActions
6+
namespace Microsoft.AspNetCore.Analyzers.DelegateEndpoints
77
{
88
[System.Diagnostics.CodeAnalysis.SuppressMessage("MicrosoftCodeAnalysisReleaseTracking", "RS2008:Enable analyzer release tracking")]
99
internal static class DiagnosticDescriptors
1010
{
11-
internal static readonly DiagnosticDescriptor DoNotUseModelBindingAttributesOnMinimalActionParameters = new(
11+
internal static readonly DiagnosticDescriptor DoNotUseModelBindingAttributesOnDelegateEndpointParameters = new(
1212
"ASP0003",
13-
"Do not use model binding attributes with Map actions",
14-
"{0} should not be specified for a {1} delegate parameter",
13+
"Do not use model binding attributes with Map handlers",
14+
"{0} should not be specified for a {1} Delegate parameter",
1515
"Usage",
1616
DiagnosticSeverity.Warning,
1717
isEnabledByDefault: true,

src/Framework/Analyzer/src/MinimalActions/DisallowMvcBindArgumentsOnParameters.cs renamed to src/Framework/Analyzer/src/DelegateEndpoints/DisallowMvcBindArgumentsOnParameters.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
using Microsoft.CodeAnalysis.Diagnostics;
77
using Microsoft.CodeAnalysis.Operations;
88

9-
namespace Microsoft.AspNetCore.Analyzers.MinimalActions;
9+
namespace Microsoft.AspNetCore.Analyzers.DelegateEndpoints;
1010

11-
public partial class MinimalActionAnalyzer : DiagnosticAnalyzer
11+
public partial class DelegateEndpointAnalyzer : DiagnosticAnalyzer
1212
{
1313
private static void DisallowMvcBindArgumentsOnParameters(
1414
in OperationAnalysisContext context,
@@ -33,7 +33,7 @@ private static void DisallowMvcBindArgumentsOnParameters(
3333
var methodName = invocation.TargetMethod.Name;
3434

3535
context.ReportDiagnostic(Diagnostic.Create(
36-
DiagnosticDescriptors.DoNotUseModelBindingAttributesOnMinimalActionParameters,
36+
DiagnosticDescriptors.DoNotUseModelBindingAttributesOnDelegateEndpointParameters,
3737
location,
3838
modelBindingAttribute.AttributeClass.Name,
3939
methodName));

src/Framework/Analyzer/src/MinimalActions/WellKnownTypes.cs renamed to src/Framework/Analyzer/src/DelegateEndpoints/WellKnownTypes.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
using System.Diagnostics.CodeAnalysis;
55
using Microsoft.CodeAnalysis;
66

7-
namespace Microsoft.AspNetCore.Analyzers.MinimalActions;
7+
namespace Microsoft.AspNetCore.Analyzers.DelegateEndpoints;
88

99
internal sealed class WellKnownTypes
1010
{
1111
public static bool TryCreate(Compilation compilation, [NotNullWhen(true)] out WellKnownTypes? wellKnownTypes)
1212
{
1313
wellKnownTypes = default;
14-
const string MinimalActionEndpointRouteBuilderExtensions = "Microsoft.AspNetCore.Builder.MinimalActionEndpointRouteBuilderExtensions";
15-
if (compilation.GetTypeByMetadataName(MinimalActionEndpointRouteBuilderExtensions) is not { } minimalActionEndpointRouteBuilderExtensions)
14+
const string DelegateEndpointRouteBuilderExtensions = "Microsoft.AspNetCore.Builder.DelegateEndpointRouteBuilderExtensions";
15+
if (compilation.GetTypeByMetadataName(DelegateEndpointRouteBuilderExtensions) is not { } delegateEndpointRouteBuilderExtensions)
1616
{
1717
return false;
1818
}
@@ -33,15 +33,15 @@ public static bool TryCreate(Compilation compilation, [NotNullWhen(true)] out We
3333

3434
wellKnownTypes = new WellKnownTypes
3535
{
36-
MinimalActionEndpointRouteBuilderExtensions = minimalActionEndpointRouteBuilderExtensions,
36+
DelegateEndpointRouteBuilderExtensions = delegateEndpointRouteBuilderExtensions,
3737
IBinderTypeProviderMetadata = ibinderTypeProviderMetadata,
3838
BindAttribute = bindAttribute,
3939
};
4040

4141
return true;
4242
}
4343

44-
public ITypeSymbol MinimalActionEndpointRouteBuilderExtensions { get; private init; }
44+
public ITypeSymbol DelegateEndpointRouteBuilderExtensions { get; private init; }
4545
public INamedTypeSymbol IBinderTypeProviderMetadata { get; private init; }
4646
public INamedTypeSymbol BindAttribute { get; private init; }
4747
}

src/Http/Routing/test/FunctionalTests/MapDelegateTest.cs renamed to src/Http/Routing/test/FunctionalTests/DelegateEndpointTest.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@
33

44
#nullable enable
55

6-
using System;
76
using System.Net.Http.Json;
8-
using System.Threading.Tasks;
97
using Microsoft.AspNetCore.Builder;
108
using Microsoft.AspNetCore.Hosting;
119
using Microsoft.AspNetCore.Http;
12-
using Microsoft.AspNetCore.Mvc;
1310
using Microsoft.AspNetCore.TestHost;
1411
using Microsoft.Extensions.DependencyInjection;
1512
using Microsoft.Extensions.Hosting;
16-
using Xunit;
1713

1814
namespace Microsoft.AspNetCore.Routing.FunctionalTests
1915
{
20-
public class MapDelegateTest
16+
public class DelegateEndpointTest
2117
{
2218
[Fact]
2319
public async Task MapPost_FromBodyWorksWithJsonPayload()

0 commit comments

Comments
 (0)