diff --git a/src/Http/Http.Extensions/gen/DiagnosticDescriptors.cs b/src/Http/Http.Extensions/gen/DiagnosticDescriptors.cs
index a0803687b854..bf0b16d04c6a 100644
--- a/src/Http/Http.Extensions/gen/DiagnosticDescriptors.cs
+++ b/src/Http/Http.Extensions/gen/DiagnosticDescriptors.cs
@@ -106,4 +106,12 @@ internal static class DiagnosticDescriptors
"Usage",
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
+
+ public static DiagnosticDescriptor KeyedAndNotKeyedServiceAttributesNotSupported { get; } = new(
+ "RDG013",
+ new LocalizableResourceString(nameof(Resources.KeyedAndNotKeyedServiceAttributesNotSupported_Title), Resources.ResourceManager, typeof(Resources)),
+ new LocalizableResourceString(nameof(Resources.KeyedAndNotKeyedServiceAttributesNotSupported_Message), Resources.ResourceManager, typeof(Resources)),
+ "Usage",
+ DiagnosticSeverity.Warning,
+ isEnabledByDefault: true);
}
diff --git a/src/Http/Http.Extensions/gen/Resources.resx b/src/Http/Http.Extensions/gen/Resources.resx
index d5af6ee6f901..45f4c7e252ed 100644
--- a/src/Http/Http.Extensions/gen/Resources.resx
+++ b/src/Http/Http.Extensions/gen/Resources.resx
@@ -189,4 +189,10 @@
Encountered inaccessible type '{0}' while processing endpoint. Compile-time endpoint generation will skip this endpoint.
+
+ Invalid source attributes
+
+
+ The [FromKeyedServices] attribute is not supported on parameters that are also annotated with IFromServiceMetadata.
+
diff --git a/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/Emitters/EndpointEmitter.cs b/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/Emitters/EndpointEmitter.cs
index 28022dd1c77b..065d825867b0 100644
--- a/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/Emitters/EndpointEmitter.cs
+++ b/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/Emitters/EndpointEmitter.cs
@@ -54,6 +54,9 @@ internal static string EmitParameterPreparation(this IEnumerable({endpointParameter.KeyedServiceKey});" :
+ $"httpContext.RequestServices.GetRequiredKeyedService<{endpointParameter.Type}>({endpointParameter.KeyedServiceKey})";
+ codeWriter.WriteLine($"var {endpointParameter.EmitHandlerArgument()} = {assigningCode};");
+ }
+
internal static void EmitAsParametersParameterPreparation(this EndpointParameter endpointParameter, CodeWriter codeWriter, EmitterContext emitterContext)
{
codeWriter.WriteLine(endpointParameter.EmitParameterDiagnosticComment());
diff --git a/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/EndpointParameter.cs b/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/EndpointParameter.cs
index 7551ec41caf5..5bc8b8471113 100644
--- a/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/EndpointParameter.cs
+++ b/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/EndpointParameter.cs
@@ -138,6 +138,17 @@ private void ProcessEndpointParameterSource(Endpoint endpoint, ISymbol symbol, I
else if (attributes.HasAttributeImplementingInterface(wellKnownTypes.Get(WellKnownType.Microsoft_AspNetCore_Http_Metadata_IFromServiceMetadata)))
{
Source = EndpointParameterSource.Service;
+ if (attributes.TryGetAttribute(wellKnownTypes.Get(WellKnownType.Microsoft_Extensions_DependencyInjection_FromKeyedServicesAttribute), out var keyedServicesAttribute))
+ {
+ var location = endpoint.Operation.Syntax.GetLocation();
+ endpoint.Diagnostics.Add(Diagnostic.Create(DiagnosticDescriptors.KeyedAndNotKeyedServiceAttributesNotSupported, location));
+ }
+ }
+ else if (attributes.TryGetAttribute(wellKnownTypes.Get(WellKnownType.Microsoft_Extensions_DependencyInjection_FromKeyedServicesAttribute), out var keyedServicesAttribute))
+ {
+ Source = EndpointParameterSource.KeyedService;
+ var constructorArgument = keyedServicesAttribute.ConstructorArguments.FirstOrDefault();
+ KeyedServiceKey = SymbolDisplay.FormatPrimitive(constructorArgument.Value!, true, true);
}
else if (attributes.HasAttribute(wellKnownTypes.Get(WellKnownType.Microsoft_AspNetCore_Http_AsParametersAttribute)))
{
@@ -260,6 +271,7 @@ private static bool ImplementsIEndpointParameterMetadataProvider(ITypeSymbol typ
public string? PropertyAsParameterInfoConstruction { get; set; }
public IEnumerable? EndpointParameters { get; set; }
public bool IsFormFile { get; set; }
+ public string? KeyedServiceKey { get; set; }
// Only used for SpecialType parameters that need
// to be resolved by a specific WellKnownType
@@ -613,7 +625,8 @@ obj is EndpointParameter other &&
other.SymbolName == SymbolName &&
other.Ordinal == Ordinal &&
other.IsOptional == IsOptional &&
- SymbolEqualityComparer.IncludeNullability.Equals(other.Type, Type);
+ SymbolEqualityComparer.IncludeNullability.Equals(other.Type, Type) &&
+ other.KeyedServiceKey == KeyedServiceKey;
public bool SignatureEquals(object obj) =>
obj is EndpointParameter other &&
@@ -621,7 +634,8 @@ obj is EndpointParameter other &&
// The name of the parameter matters when we are querying for a specific parameter using
// an indexer, like `context.Request.RouteValues["id"]` or `context.Request.Query["id"]`
// and when generating log messages for required bodies or services.
- other.SymbolName == SymbolName;
+ other.SymbolName == SymbolName &&
+ other.KeyedServiceKey == KeyedServiceKey;
public override int GetHashCode()
{
diff --git a/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/EndpointParameterSource.cs b/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/EndpointParameterSource.cs
index d8410775a278..459028f33c41 100644
--- a/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/EndpointParameterSource.cs
+++ b/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/EndpointParameterSource.cs
@@ -14,6 +14,7 @@ internal enum EndpointParameterSource
JsonBodyOrService,
FormBody,
Service,
+ KeyedService,
// SpecialType refers to HttpContext, HttpRequest, CancellationToken, Stream, etc...
// that are specially checked for in RequestDelegateFactory.CreateArgument()
SpecialType,
diff --git a/src/Http/Http.Extensions/src/RequestDelegateFactory.cs b/src/Http/Http.Extensions/src/RequestDelegateFactory.cs
index 72aa1937fce2..139190ef23ec 100644
--- a/src/Http/Http.Extensions/src/RequestDelegateFactory.cs
+++ b/src/Http/Http.Extensions/src/RequestDelegateFactory.cs
@@ -56,6 +56,8 @@ public static partial class RequestDelegateFactory
private static readonly MethodInfo ExecuteAwaitedReturnMethod = typeof(RequestDelegateFactory).GetMethod(nameof(ExecuteAwaitedReturn), BindingFlags.NonPublic | BindingFlags.Static)!;
private static readonly MethodInfo GetRequiredServiceMethod = typeof(ServiceProviderServiceExtensions).GetMethod(nameof(ServiceProviderServiceExtensions.GetRequiredService), BindingFlags.Public | BindingFlags.Static, new Type[] { typeof(IServiceProvider) })!;
private static readonly MethodInfo GetServiceMethod = typeof(ServiceProviderServiceExtensions).GetMethod(nameof(ServiceProviderServiceExtensions.GetService), BindingFlags.Public | BindingFlags.Static, new Type[] { typeof(IServiceProvider) })!;
+ private static readonly MethodInfo GetRequiredKeyedServiceMethod = typeof(ServiceProviderKeyedServiceExtensions).GetMethod(nameof(ServiceProviderKeyedServiceExtensions.GetRequiredKeyedService), BindingFlags.Public | BindingFlags.Static, new Type[] { typeof(IServiceProvider), typeof(object) })!;
+ private static readonly MethodInfo GetKeyedServiceMethod = typeof(ServiceProviderKeyedServiceExtensions).GetMethod(nameof(ServiceProviderKeyedServiceExtensions.GetKeyedService), BindingFlags.Public | BindingFlags.Static, new Type[] { typeof(IServiceProvider), typeof(object) })!;
private static readonly MethodInfo ResultWriteResponseAsyncMethod = typeof(RequestDelegateFactory).GetMethod(nameof(ExecuteResultWriteResponse), BindingFlags.NonPublic | BindingFlags.Static)!;
private static readonly MethodInfo StringResultWriteResponseAsyncMethod = typeof(RequestDelegateFactory).GetMethod(nameof(ExecuteWriteStringResponseAsync), BindingFlags.NonPublic | BindingFlags.Static)!;
private static readonly MethodInfo StringIsNullOrEmptyMethod = typeof(string).GetMethod(nameof(string.IsNullOrEmpty), BindingFlags.Static | BindingFlags.Public)!;
@@ -761,9 +763,19 @@ private static Expression CreateArgument(ParameterInfo parameter, RequestDelegat
}
else if (parameter.CustomAttributes.Any(a => typeof(IFromServiceMetadata).IsAssignableFrom(a.AttributeType)))
{
+ if (parameterCustomAttributes.OfType().FirstOrDefault() is not null)
+ {
+ throw new NotSupportedException(
+ $"The {nameof(FromKeyedServicesAttribute)} is not supported on parameters that are also annotated with {nameof(IFromServiceMetadata)}.");
+ }
factoryContext.TrackedParameters.Add(parameter.Name, RequestDelegateFactoryConstants.ServiceAttribute);
return BindParameterFromService(parameter, factoryContext);
}
+ else if (parameterCustomAttributes.OfType().FirstOrDefault() is { } keyedServicesAttribute)
+ {
+ var key = keyedServicesAttribute.Key;
+ return BindParameterFromKeyedService(parameter, key, factoryContext);
+ }
else if (parameterCustomAttributes.OfType().Any())
{
if (parameter is PropertyAsParameterInfo)
@@ -1563,6 +1575,21 @@ private static Expression BindParameterFromService(ParameterInfo parameter, Requ
return Expression.Call(GetRequiredServiceMethod.MakeGenericMethod(parameter.ParameterType), RequestServicesExpr);
}
+ private static Expression BindParameterFromKeyedService(ParameterInfo parameter, object key, RequestDelegateFactoryContext factoryContext)
+ {
+ var isOptional = IsOptionalParameter(parameter, factoryContext);
+
+ if (isOptional)
+ {
+ return Expression.Call(GetKeyedServiceMethod.MakeGenericMethod(parameter.ParameterType), RequestServicesExpr, Expression.Convert(
+ Expression.Constant(key),
+ typeof(object)));
+ }
+ return Expression.Call(GetRequiredKeyedServiceMethod.MakeGenericMethod(parameter.ParameterType), RequestServicesExpr, Expression.Convert(
+ Expression.Constant(key),
+ typeof(object)));
+ }
+
private static Expression BindParameterFromValue(ParameterInfo parameter, Expression valueExpression, RequestDelegateFactoryContext factoryContext, string source)
{
if (parameter.ParameterType == typeof(string) || parameter.ParameterType == typeof(string[])
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_BindAsync_NullableReturn.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_BindAsync_NullableReturn.generated.txt
index ccb938ec7ecf..b1c3eef49159 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_BindAsync_NullableReturn.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_BindAsync_NullableReturn.generated.txt
@@ -58,8 +58,8 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
- [InterceptsLocation(@"TestMapActions.cs", 26, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 27, 5)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -166,8 +166,8 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 28, 5)]
[InterceptsLocation(@"TestMapActions.cs", 29, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 30, 5)]
internal static RouteHandlerBuilder MapGet1(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_BindAsync_Snapshot.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_BindAsync_Snapshot.generated.txt
index 1291c023f289..943c1e977de4 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_BindAsync_Snapshot.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_BindAsync_Snapshot.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -167,7 +167,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 26, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 27, 5)]
internal static RouteHandlerBuilder MapGet1(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -262,7 +262,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 27, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 28, 5)]
internal static RouteHandlerBuilder MapGet2(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -359,7 +359,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 28, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 29, 5)]
internal static RouteHandlerBuilder MapGet3(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -454,7 +454,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 29, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 30, 5)]
internal static RouteHandlerBuilder MapGet4(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -563,7 +563,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 30, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 31, 5)]
internal static RouteHandlerBuilder MapGet5(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -658,7 +658,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 31, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 32, 5)]
internal static RouteHandlerBuilder MapGet6(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -755,7 +755,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 32, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 33, 5)]
internal static RouteHandlerBuilder MapGet7(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -850,7 +850,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 33, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 34, 5)]
internal static RouteHandlerBuilder MapGet8(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -958,7 +958,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 34, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 35, 5)]
internal static RouteHandlerBuilder MapGet9(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -1052,7 +1052,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 35, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 36, 5)]
internal static RouteHandlerBuilder MapGet10(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -1148,7 +1148,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 36, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 37, 5)]
internal static RouteHandlerBuilder MapGet11(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -1242,7 +1242,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 37, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 38, 5)]
internal static RouteHandlerBuilder MapGet12(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -1351,7 +1351,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 38, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 39, 5)]
internal static RouteHandlerBuilder MapGet13(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -1446,7 +1446,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 39, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 40, 5)]
internal static RouteHandlerBuilder MapGet14(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -1554,7 +1554,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 40, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 41, 5)]
internal static RouteHandlerBuilder MapGet15(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -1648,7 +1648,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 41, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 42, 5)]
internal static RouteHandlerBuilder MapGet16(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -1757,7 +1757,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 42, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 43, 5)]
internal static RouteHandlerBuilder MapGet17(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -1852,7 +1852,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 43, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 44, 5)]
internal static RouteHandlerBuilder MapGet18(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -1960,7 +1960,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 44, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 45, 5)]
internal static RouteHandlerBuilder MapGet19(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitBodyParam_ComplexReturn_Snapshot.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitBodyParam_ComplexReturn_Snapshot.generated.txt
index a3777694db63..23b91e77db28 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitBodyParam_ComplexReturn_Snapshot.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitBodyParam_ComplexReturn_Snapshot.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] PostVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Post };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapPost0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -162,7 +162,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 26, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 27, 5)]
internal static RouteHandlerBuilder MapPost1(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitHeader_ComplexTypeArrayParam.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitHeader_ComplexTypeArrayParam.generated.txt
index af8a3debe034..8e2fff14a8c5 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitHeader_ComplexTypeArrayParam.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitHeader_ComplexTypeArrayParam.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitHeader_NullableStringArrayParam.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitHeader_NullableStringArrayParam.generated.txt
index 23106300da17..de264d352b6c 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitHeader_NullableStringArrayParam.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitHeader_NullableStringArrayParam.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitHeader_StringArrayParam.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitHeader_StringArrayParam.generated.txt
index fc559ae7e094..585b37885505 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitHeader_StringArrayParam.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitHeader_StringArrayParam.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitQuery_ComplexTypeArrayParam.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitQuery_ComplexTypeArrayParam.generated.txt
index 4dfe6564a97f..4cea661b4f8a 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitQuery_ComplexTypeArrayParam.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitQuery_ComplexTypeArrayParam.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitQuery_NullableStringArrayParam.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitQuery_NullableStringArrayParam.generated.txt
index 79ef0f04ef7f..d699063ef30b 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitQuery_NullableStringArrayParam.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitQuery_NullableStringArrayParam.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitQuery_StringArrayParam.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitQuery_StringArrayParam.generated.txt
index fe0fff0da4d2..60588b1eecb5 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitQuery_StringArrayParam.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitQuery_StringArrayParam.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitServiceParam_SimpleReturn_Snapshot.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitServiceParam_SimpleReturn_Snapshot.generated.txt
index 75ffcfe1d4cf..95956a2565fa 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitServiceParam_SimpleReturn_Snapshot.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitServiceParam_SimpleReturn_Snapshot.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -154,7 +154,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 26, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 27, 5)]
internal static RouteHandlerBuilder MapGet1(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -250,7 +250,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 27, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 28, 5)]
internal static RouteHandlerBuilder MapGet2(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitSource_SimpleReturn_Snapshot.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitSource_SimpleReturn_Snapshot.generated.txt
index 69ba4668b5c3..d3546f2a8f18 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitSource_SimpleReturn_Snapshot.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitSource_SimpleReturn_Snapshot.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -168,7 +168,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 26, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 27, 5)]
internal static RouteHandlerBuilder MapGet1(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -278,7 +278,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 27, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 28, 5)]
internal static RouteHandlerBuilder MapGet2(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -396,8 +396,8 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 28, 5)]
[InterceptsLocation(@"TestMapActions.cs", 29, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 30, 5)]
internal static RouteHandlerBuilder MapGet3(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ImplicitQuery_ComplexTypeArrayParam.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ImplicitQuery_ComplexTypeArrayParam.generated.txt
index b328c0c32155..b0a1f6106320 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ImplicitQuery_ComplexTypeArrayParam.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ImplicitQuery_ComplexTypeArrayParam.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ImplicitQuery_NullableStringArrayParam.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ImplicitQuery_NullableStringArrayParam.generated.txt
index 7920d281cfd7..734772471d34 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ImplicitQuery_NullableStringArrayParam.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ImplicitQuery_NullableStringArrayParam.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ImplicitQuery_NullableStringArrayParam_EmptyQueryValues.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ImplicitQuery_NullableStringArrayParam_EmptyQueryValues.generated.txt
index 7920d281cfd7..734772471d34 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ImplicitQuery_NullableStringArrayParam_EmptyQueryValues.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ImplicitQuery_NullableStringArrayParam_EmptyQueryValues.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ImplicitQuery_NullableStringArrayParam_QueryNotPresent.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ImplicitQuery_NullableStringArrayParam_QueryNotPresent.generated.txt
index 7920d281cfd7..734772471d34 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ImplicitQuery_NullableStringArrayParam_QueryNotPresent.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ImplicitQuery_NullableStringArrayParam_QueryNotPresent.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ImplicitQuery_StringArrayParam.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ImplicitQuery_StringArrayParam.generated.txt
index fb0963b57444..d76955e8fb68 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ImplicitQuery_StringArrayParam.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ImplicitQuery_StringArrayParam.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_JsonBodyOrService_HandlesBothJsonAndService.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_JsonBodyOrService_HandlesBothJsonAndService.generated.txt
index ca19d53c2cf1..43b0fad9d3cc 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_JsonBodyOrService_HandlesBothJsonAndService.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_JsonBodyOrService_HandlesBothJsonAndService.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] PostVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Post };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapPost0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_MultipleSpecialTypeParam_StringReturn.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_MultipleSpecialTypeParam_StringReturn.generated.txt
index 290109594795..8d118812dce3 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_MultipleSpecialTypeParam_StringReturn.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_MultipleSpecialTypeParam_StringReturn.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_MultipleStringParam_StringReturn.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_MultipleStringParam_StringReturn.generated.txt
index 0af76c61d49d..e2c50e8d5d0e 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_MultipleStringParam_StringReturn.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_MultipleStringParam_StringReturn.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_NoParam_StringReturn_WithFilter.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_NoParam_StringReturn_WithFilter.generated.txt
index 18756a88e913..a9790eec67d3 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_NoParam_StringReturn_WithFilter.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_NoParam_StringReturn_WithFilter.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ReturnsString_Has_Metadata.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ReturnsString_Has_Metadata.generated.txt
index 18756a88e913..a9790eec67d3 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ReturnsString_Has_Metadata.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ReturnsString_Has_Metadata.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ReturnsTodo_Has_Metadata.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ReturnsTodo_Has_Metadata.generated.txt
index 91e7079c9934..77f4ad1b9b71 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ReturnsTodo_Has_Metadata.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ReturnsTodo_Has_Metadata.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ReturnsValidationProblemResult_Has_Metadata.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ReturnsValidationProblemResult_Has_Metadata.generated.txt
index c485b6248813..b114fa5cb7bd 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ReturnsValidationProblemResult_Has_Metadata.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ReturnsValidationProblemResult_Has_Metadata.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ReturnsVoid_Has_No_Metadata.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ReturnsVoid_Has_No_Metadata.generated.txt
index b9b8a2890223..bbbc9e724b1e 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ReturnsVoid_Has_No_Metadata.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ReturnsVoid_Has_No_Metadata.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_SingleComplexTypeParam_StringReturn.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_SingleComplexTypeParam_StringReturn.generated.txt
index 46eee220fa3c..e566e6822dbe 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_SingleComplexTypeParam_StringReturn.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_SingleComplexTypeParam_StringReturn.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_SingleEnumParam_StringReturn.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_SingleEnumParam_StringReturn.generated.txt
index cc70fb7e27e8..d4414a8b1217 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_SingleEnumParam_StringReturn.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_SingleEnumParam_StringReturn.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_SingleNullableStringParam_WithEmptyQueryStringValueProvided_StringReturn.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_SingleNullableStringParam_WithEmptyQueryStringValueProvided_StringReturn.generated.txt
index c09d1e74d559..81e8c9156b87 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_SingleNullableStringParam_WithEmptyQueryStringValueProvided_StringReturn.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_SingleNullableStringParam_WithEmptyQueryStringValueProvided_StringReturn.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_TakesCustomMetadataEmitter_Has_Metadata.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_TakesCustomMetadataEmitter_Has_Metadata.generated.txt
index c437e7401640..06752765bb9d 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_TakesCustomMetadataEmitter_Has_Metadata.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_TakesCustomMetadataEmitter_Has_Metadata.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] PostVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Post };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapPost0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapMethods_Get_WithArrayQueryString_AndBody_ShouldUseQueryString.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapMethods_Get_WithArrayQueryString_AndBody_ShouldUseQueryString.generated.txt
index b77ab3122148..37e7815dd68e 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapMethods_Get_WithArrayQueryString_AndBody_ShouldUseQueryString.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapMethods_Get_WithArrayQueryString_AndBody_ShouldUseQueryString.generated.txt
@@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Http.Generated
{
private static readonly JsonOptions FallbackJsonOptions = new();
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapMethods0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapMethods_PostAndGet_WithArrayQueryString_AndBody_ShouldUseQueryString.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapMethods_PostAndGet_WithArrayQueryString_AndBody_ShouldUseQueryString.generated.txt
index b77ab3122148..37e7815dd68e 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapMethods_PostAndGet_WithArrayQueryString_AndBody_ShouldUseQueryString.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapMethods_PostAndGet_WithArrayQueryString_AndBody_ShouldUseQueryString.generated.txt
@@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Http.Generated
{
private static readonly JsonOptions FallbackJsonOptions = new();
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapMethods0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapMethods_PostAndPut_WithArrayQueryString_AndBody_ShouldUseBody.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapMethods_PostAndPut_WithArrayQueryString_AndBody_ShouldUseBody.generated.txt
index b77ab3122148..37e7815dd68e 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapMethods_PostAndPut_WithArrayQueryString_AndBody_ShouldUseBody.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapMethods_PostAndPut_WithArrayQueryString_AndBody_ShouldUseBody.generated.txt
@@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Http.Generated
{
private static readonly JsonOptions FallbackJsonOptions = new();
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapMethods0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapMethods_Post_WithArrayQueryString_AndBody_ShouldUseBody.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapMethods_Post_WithArrayQueryString_AndBody_ShouldUseBody.generated.txt
index b77ab3122148..37e7815dd68e 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapMethods_Post_WithArrayQueryString_AndBody_ShouldUseBody.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapMethods_Post_WithArrayQueryString_AndBody_ShouldUseBody.generated.txt
@@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Http.Generated
{
private static readonly JsonOptions FallbackJsonOptions = new();
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapMethods0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapPost_WithArrayQueryString_AndBody_ShouldUseBody.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapPost_WithArrayQueryString_AndBody_ShouldUseBody.generated.txt
index c22c5ba860c8..17f8bd727841 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapPost_WithArrayQueryString_AndBody_ShouldUseBody.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapPost_WithArrayQueryString_AndBody_ShouldUseBody.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] PostVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Post };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapPost0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapPost_WithArrayQueryString_ShouldFail.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapPost_WithArrayQueryString_ShouldFail.generated.txt
index 5723abe946b9..7a01bbe4ba22 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapPost_WithArrayQueryString_ShouldFail.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapPost_WithArrayQueryString_ShouldFail.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] PostVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Post };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapPost0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/Multiple_MapAction_NoParam_StringReturn.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/Multiple_MapAction_NoParam_StringReturn.generated.txt
index 0c31ddd4906f..3637cd7aba0d 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/Multiple_MapAction_NoParam_StringReturn.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/Multiple_MapAction_NoParam_StringReturn.generated.txt
@@ -58,8 +58,8 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
- [InterceptsLocation(@"TestMapActions.cs", 26, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 27, 5)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -148,7 +148,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 27, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 28, 5)]
internal static RouteHandlerBuilder MapGet1(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -240,7 +240,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 28, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 29, 5)]
internal static RouteHandlerBuilder MapGet2(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/Multiple_MapAction_WithParams_StringReturn.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/Multiple_MapAction_WithParams_StringReturn.generated.txt
index d47e7e402a01..5232ed8d5f0e 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/Multiple_MapAction_WithParams_StringReturn.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/Multiple_MapAction_WithParams_StringReturn.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -151,7 +151,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 26, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 27, 5)]
internal static RouteHandlerBuilder MapGet1(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -244,7 +244,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 27, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 28, 5)]
internal static RouteHandlerBuilder MapGet2(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/RequestDelegateValidateGeneratedFormCode.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/RequestDelegateValidateGeneratedFormCode.generated.txt
index 6bb8bc91cda8..f1ed3e6ca32b 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/RequestDelegateValidateGeneratedFormCode.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/RequestDelegateValidateGeneratedFormCode.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] PostVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Post };
- [InterceptsLocation(@"TestMapActions.cs", 29, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 30, 5)]
internal static RouteHandlerBuilder MapPost0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/SupportsDifferentInterceptorsFromSameLocation.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/SupportsDifferentInterceptorsFromSameLocation.generated.txt
index 6184bc259d40..913b5a01b0d3 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/SupportsDifferentInterceptorsFromSameLocation.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/SupportsDifferentInterceptorsFromSameLocation.generated.txt
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -169,7 +169,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"OtherTestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"OtherTestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet1(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/SupportsSameInterceptorsFromDifferentFiles.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/SupportsSameInterceptorsFromDifferentFiles.generated.txt
index 92e553936412..27f9fe079efd 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/SupportsSameInterceptorsFromDifferentFiles.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/SupportsSameInterceptorsFromDifferentFiles.generated.txt
@@ -58,9 +58,9 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly JsonOptions FallbackJsonOptions = new();
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
- [InterceptsLocation(@"TestMapActions.cs", 25, 13)]
- [InterceptsLocation(@"TestMapActions.cs", 25, 63)]
- [InterceptsLocation(@"OtherTestMapActions.cs", 25, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 13)]
+ [InterceptsLocation(@"TestMapActions.cs", 26, 63)]
+ [InterceptsLocation(@"OtherTestMapActions.cs", 26, 13)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/VerifyAsParametersBaseline.generated.txt b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/VerifyAsParametersBaseline.generated.txt
index a9f7236544d3..b76af2e7485a 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/VerifyAsParametersBaseline.generated.txt
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/VerifyAsParametersBaseline.generated.txt
@@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Http.Generated
private static readonly string[] PostVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Post };
private static readonly string[] PutVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Put };
- [InterceptsLocation(@"TestMapActions.cs", 44, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 45, 5)]
internal static RouteHandlerBuilder MapGet0(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -195,7 +195,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 45, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 46, 5)]
internal static RouteHandlerBuilder MapPost1(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -322,7 +322,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 46, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 47, 5)]
internal static RouteHandlerBuilder MapPut2(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -420,7 +420,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 47, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 48, 5)]
internal static RouteHandlerBuilder MapPatch3(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
@@ -537,7 +537,7 @@ namespace Microsoft.AspNetCore.Http.Generated
createRequestDelegate);
}
- [InterceptsLocation(@"TestMapActions.cs", 48, 5)]
+ [InterceptsLocation(@"TestMapActions.cs", 49, 5)]
internal static RouteHandlerBuilder MapGet4(
this IEndpointRouteBuilder endpoints,
[StringSyntax("Route")] string pattern,
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTestBase.cs b/src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTestBase.cs
index 47bac8f9cbe0..05eb91a97f62 100644
--- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTestBase.cs
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTestBase.cs
@@ -284,6 +284,7 @@ internal static string GetMapActionString(string sources, string className = "Te
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Http.Generators.Tests;
using Microsoft.Extensions.Primitives;
+using Microsoft.Extensions.DependencyInjection;
public static class {{className}}
{
diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTests.KeyServices.cs b/src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTests.KeyServices.cs
new file mode 100644
index 000000000000..040d6839264f
--- /dev/null
+++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTests.KeyServices.cs
@@ -0,0 +1,200 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+using Microsoft.AspNetCore.Http.Metadata;
+using Microsoft.AspNetCore.Http.RequestDelegateGenerator;
+using Microsoft.Extensions.DependencyInjection;
+namespace Microsoft.AspNetCore.Http.Generators.Tests;
+
+public partial class RequestDelegateCreationTests : RequestDelegateCreationTestBase
+{
+ [Fact]
+ public async Task SupportsSingleKeyedServiceWithStringKey()
+ {
+ var source = """
+app.MapGet("/", (HttpContext context, [FromKeyedServices("service1")] TestService arg) => context.Items["arg"] = arg);
+""";
+ var (_, compilation) = await RunGeneratorAsync(source);
+ var myOriginalService = new TestService();
+ var serviceProvider = CreateServiceProvider((serviceCollection) => serviceCollection.AddKeyedSingleton("service1", myOriginalService));
+ var endpoint = GetEndpointFromCompilation(compilation, serviceProvider: serviceProvider);
+
+ var httpContext = CreateHttpContext(serviceProvider);
+ await endpoint.RequestDelegate(httpContext);
+
+ Assert.Same(myOriginalService, httpContext.Items["arg"]);
+ }
+
+ [Fact]
+ public async Task ThrowsIfKeyedAndNonKeyedAttributesOnSameParameter()
+ {
+ var source = """
+app.MapGet("/", (HttpContext context, [FromKeyedServices("service1")] [FromServices] TestService arg) => context.Items["arg"] = arg);
+""";
+ var myOriginalService = new TestService();
+ var serviceProvider = CreateServiceProvider((serviceCollection) => serviceCollection.AddKeyedSingleton("service1", myOriginalService));
+
+ var (result, compilation) = await RunGeneratorAsync(source);
+
+ // When the generator is enabled, you'll get a compile-time warning in addition to the exception thrown at
+ // runtime.
+ if (IsGeneratorEnabled)
+ {
+ Assert.Contains(result.Value.Diagnostics, diagnostic => diagnostic.Id == DiagnosticDescriptors.KeyedAndNotKeyedServiceAttributesNotSupported.Id);
+ }
+
+ // Throw during endpoint construction
+ var exception = Assert.Throws(() => GetEndpointFromCompilation(compilation, serviceProvider: serviceProvider));
+ Assert.Equal($"The {nameof(FromKeyedServicesAttribute)} is not supported on parameters that are also annotated with {nameof(IFromServiceMetadata)}.", exception.Message);
+ }
+
+ [Fact]
+ public async Task SupportsKeyedServicesWithNullAndStringEmptyKeys()
+ {
+ var source = """
+app.MapGet("/string-empty", (HttpContext context, [FromKeyedServices("")] TestService arg) => context.Items["arg"] = arg);
+app.MapGet("/null", (HttpContext context, [FromKeyedServices(null!)] TestService arg) => context.Items["arg"] = arg);
+""";
+ var (_, compilation) = await RunGeneratorAsync(source);
+ var myOriginalService1 = new TestService();
+ var myOriginalService2 = new TestService();
+ var serviceProvider = CreateServiceProvider((serviceCollection) =>
+ {
+ serviceCollection.AddKeyedSingleton("", myOriginalService1);
+ serviceCollection.AddSingleton(myOriginalService2);
+ });
+ var endpoints = GetEndpointsFromCompilation(compilation, serviceProvider: serviceProvider);
+
+ var httpContext1 = CreateHttpContext(serviceProvider);
+ await endpoints[0].RequestDelegate(httpContext1);
+ var httpContext2 = CreateHttpContext(serviceProvider);
+ await endpoints[1].RequestDelegate(httpContext2);
+
+ Assert.Same(myOriginalService1, httpContext1.Items["arg"]);
+ Assert.Same(myOriginalService2, httpContext2.Items["arg"]);
+ }
+
+ [Fact]
+ public async Task SupportsSingleKeyedServiceWithCharKey()
+ {
+ var source = """
+app.MapGet("/", (HttpContext context, [FromKeyedServices('a')] TestService arg) => context.Items["arg"] = arg);
+""";
+ var (_, compilation) = await RunGeneratorAsync(source);
+ var myOriginalService = new TestService();
+ var serviceProvider = CreateServiceProvider((serviceCollection) => serviceCollection.AddKeyedSingleton('a', myOriginalService));
+ var endpoint = GetEndpointFromCompilation(compilation, serviceProvider: serviceProvider);
+
+ var httpContext = CreateHttpContext(serviceProvider);
+ await endpoint.RequestDelegate(httpContext);
+
+ Assert.Same(myOriginalService, httpContext.Items["arg"]);
+ }
+
+ [Theory]
+ [InlineData(10)]
+ [InlineData(false)]
+ [InlineData(12.3)]
+ public async Task SupportsSingleKeyedServiceWithPrimitiveKeyTypes(object key)
+ {
+ var source = $$"""
+app.MapGet("/", (HttpContext context, [FromKeyedServices({{key.ToString()?.ToLowerInvariant()}})] TestService arg) => context.Items["arg"] = arg);
+""";
+ var (_, compilation) = await RunGeneratorAsync(source);
+ var myOriginalService = new TestService();
+ var serviceProvider = CreateServiceProvider((serviceCollection) => serviceCollection.AddKeyedSingleton(key, myOriginalService));
+ var endpoint = GetEndpointFromCompilation(compilation, serviceProvider: serviceProvider);
+
+ var httpContext = CreateHttpContext(serviceProvider);
+ await endpoint.RequestDelegate(httpContext);
+
+ Assert.Same(myOriginalService, httpContext.Items["arg"]);
+ }
+
+ [Fact]
+ public async Task ThrowsForUnregisteredRequiredKeyService()
+ {
+ var source = """
+app.MapGet("/", (HttpContext context, [FromKeyedServices("service1")] TestService arg) => context.Items["arg"] = arg);
+""";
+ var (_, compilation) = await RunGeneratorAsync(source);
+ var endpoint = GetEndpointFromCompilation(compilation);
+
+ var httpContext = CreateHttpContext();
+ var exception = await Assert.ThrowsAsync(
+ async () => await endpoint.RequestDelegate(httpContext));
+
+ Assert.Equal("No service for type 'Microsoft.AspNetCore.Http.Generators.Tests.TestService' has been registered.", exception.Message);
+ }
+
+ [Fact]
+ public async Task DoesNotThrowForUnregisteredOptionalKeyService()
+ {
+ var source = """
+app.MapGet("/", (HttpContext context, [FromKeyedServices("service1")] TestService? arg) => context.Items["arg"] = arg);
+""";
+ var (_, compilation) = await RunGeneratorAsync(source);
+ var endpoint = GetEndpointFromCompilation(compilation);
+
+ var httpContext = CreateHttpContext();
+ await endpoint.RequestDelegate(httpContext);
+
+ Assert.Equal(StatusCodes.Status200OK, httpContext.Response.StatusCode);
+ Assert.Null(httpContext.Items["arg"]);
+ }
+
+ [Fact]
+ public async Task SupportsMultipleKeyedServiceWithStringKey()
+ {
+ var source = """
+app.MapGet("/", (HttpContext context, [FromKeyedServices("service1")] TestService arg1, [FromKeyedServices("service2")] TestService arg2) =>
+{
+ context.Items["arg1"] = arg1;
+ context.Items["arg2"] = arg2;
+});
+""";
+ var (_, compilation) = await RunGeneratorAsync(source);
+ var myOriginalService1 = new TestService();
+ var serviceProvider = CreateServiceProvider((serviceCollection) =>
+ {
+ serviceCollection.AddKeyedSingleton("service1", myOriginalService1);
+ serviceCollection.AddKeyedScoped("service2");
+ });
+ var endpoint = GetEndpointFromCompilation(compilation, serviceProvider: serviceProvider);
+
+ var httpContext = CreateHttpContext(serviceProvider);
+ await endpoint.RequestDelegate(httpContext);
+
+ Assert.Same(myOriginalService1, httpContext.Items["arg1"]);
+ Assert.IsType(httpContext.Items["arg2"]);
+ }
+
+ [Fact]
+ public async Task SupportsMultipleKeyedAndNonKeyedServices()
+ {
+ var source = """
+app.MapGet("/", (HttpContext context, [FromKeyedServices("service1")] TestService arg1, [FromKeyedServices("service2")] TestService arg2, TestService arg3) =>
+{
+ context.Items["arg1"] = arg1;
+ context.Items["arg2"] = arg2;
+ context.Items["arg3"] = arg3;
+});
+""";
+ var (_, compilation) = await RunGeneratorAsync(source);
+ var myOriginalService1 = new TestService();
+ var myOriginalService2 = new TestService();
+ var serviceProvider = CreateServiceProvider((serviceCollection) =>
+ {
+ serviceCollection.AddKeyedSingleton("service1", myOriginalService1);
+ serviceCollection.AddKeyedScoped("service2");
+ serviceCollection.AddSingleton(myOriginalService2);
+ });
+ var endpoint = GetEndpointFromCompilation(compilation, serviceProvider: serviceProvider);
+
+ var httpContext = CreateHttpContext(serviceProvider);
+ await endpoint.RequestDelegate(httpContext);
+
+ Assert.Same(myOriginalService1, httpContext.Items["arg1"]);
+ Assert.IsType(httpContext.Items["arg2"]);
+ Assert.Same(myOriginalService2, httpContext.Items["arg3"]);
+ }
+}
diff --git a/src/Shared/RoslynUtils/SymbolExtensions.cs b/src/Shared/RoslynUtils/SymbolExtensions.cs
index 28359b203ed3..58ec2bfe36d6 100644
--- a/src/Shared/RoslynUtils/SymbolExtensions.cs
+++ b/src/Shared/RoslynUtils/SymbolExtensions.cs
@@ -62,15 +62,22 @@ public static bool HasAttribute(this ISymbol symbol, INamedTypeSymbol attributeT
}
public static bool HasAttribute(this ImmutableArray attributes, INamedTypeSymbol attributeType)
+ {
+ return attributes.TryGetAttribute(attributeType, out _);
+ }
+
+ public static bool TryGetAttribute(this ImmutableArray attributes, INamedTypeSymbol attributeType, [NotNullWhen(true)] out AttributeData? matchedAttribute)
{
foreach (var attributeData in attributes)
{
if (SymbolEqualityComparer.Default.Equals(attributeData.AttributeClass, attributeType))
{
+ matchedAttribute = attributeData;
return true;
}
}
+ matchedAttribute = null;
return false;
}
diff --git a/src/Shared/RoslynUtils/WellKnownTypeData.cs b/src/Shared/RoslynUtils/WellKnownTypeData.cs
index 33170c0d1b23..6cd79a6c388c 100644
--- a/src/Shared/RoslynUtils/WellKnownTypeData.cs
+++ b/src/Shared/RoslynUtils/WellKnownTypeData.cs
@@ -111,6 +111,7 @@ public enum WellKnownType
Microsoft_AspNetCore_Authorization_AllowAnonymousAttribute,
Microsoft_AspNetCore_Authorization_AuthorizeAttribute,
Microsoft_Extensions_DependencyInjection_PolicyServiceCollectionExtensions,
+ Microsoft_Extensions_DependencyInjection_FromKeyedServicesAttribute,
Microsoft_AspNetCore_Authorization_AuthorizationOptions
}
@@ -220,6 +221,7 @@ public enum WellKnownType
"Microsoft.AspNetCore.Authorization.AllowAnonymousAttribute",
"Microsoft.AspNetCore.Authorization.AuthorizeAttribute",
"Microsoft.Extensions.DependencyInjection.PolicyServiceCollectionExtensions",
+ "Microsoft.Extensions.DependencyInjection.FromKeyedServicesAttribute",
"Microsoft.AspNetCore.Authorization.AuthorizationOptions"
};
}