From e93b6b4eec9a823290b7a8c6e5ecbb2af7e1fb19 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Tue, 15 Aug 2023 15:43:35 -0700 Subject: [PATCH 1/3] Support resolving keyed services from DI in RDF and RDG --- .../Emitters/EndpointEmitter.cs | 3 + .../Emitters/EndpointParameterEmitter.cs | 10 ++ .../EndpointParameter.cs | 6 + .../EndpointParameterSource.cs | 1 + .../src/RequestDelegateFactory.cs | 22 +++ ...ion_BindAsync_NullableReturn.generated.txt | 6 +- ...MapAction_BindAsync_Snapshot.generated.txt | 40 ++--- ...Param_ComplexReturn_Snapshot.generated.txt | 4 +- ...Header_ComplexTypeArrayParam.generated.txt | 2 +- ...der_NullableStringArrayParam.generated.txt | 2 +- ...licitHeader_StringArrayParam.generated.txt | 2 +- ...tQuery_ComplexTypeArrayParam.generated.txt | 2 +- ...ery_NullableStringArrayParam.generated.txt | 2 +- ...plicitQuery_StringArrayParam.generated.txt | 2 +- ...eParam_SimpleReturn_Snapshot.generated.txt | 6 +- ...Source_SimpleReturn_Snapshot.generated.txt | 8 +- ...tQuery_ComplexTypeArrayParam.generated.txt | 2 +- ...ery_NullableStringArrayParam.generated.txt | 2 +- ...gArrayParam_EmptyQueryValues.generated.txt | 2 +- ...ngArrayParam_QueryNotPresent.generated.txt | 2 +- ...plicitQuery_StringArrayParam.generated.txt | 2 +- ...ce_HandlesBothJsonAndService.generated.txt | 2 +- ...pecialTypeParam_StringReturn.generated.txt | 2 +- ...ipleStringParam_StringReturn.generated.txt | 2 +- ...aram_StringReturn_WithFilter.generated.txt | 2 +- ...n_ReturnsString_Has_Metadata.generated.txt | 2 +- ...ion_ReturnsTodo_Has_Metadata.generated.txt | 2 +- ...onProblemResult_Has_Metadata.generated.txt | 2 +- ..._ReturnsVoid_Has_No_Metadata.generated.txt | 2 +- ...omplexTypeParam_StringReturn.generated.txt | 2 +- ...SingleEnumParam_StringReturn.generated.txt | 2 +- ...ngValueProvided_StringReturn.generated.txt | 2 +- ...MetadataEmitter_Has_Metadata.generated.txt | 2 +- ...AndBody_ShouldUseQueryString.generated.txt | 2 +- ...AndBody_ShouldUseQueryString.generated.txt | 2 +- ...String_AndBody_ShouldUseBody.generated.txt | 2 +- ...String_AndBody_ShouldUseBody.generated.txt | 2 +- ...String_AndBody_ShouldUseBody.generated.txt | 2 +- ...hArrayQueryString_ShouldFail.generated.txt | 2 +- ...pAction_NoParam_StringReturn.generated.txt | 8 +- ...tion_WithParams_StringReturn.generated.txt | 6 +- ...ateValidateGeneratedFormCode.generated.txt | 2 +- ...InterceptorsFromSameLocation.generated.txt | 4 +- ...terceptorsFromDifferentFiles.generated.txt | 6 +- .../VerifyAsParametersBaseline.generated.txt | 10 +- .../RequestDelegateCreationTestBase.cs | 1 + ...equestDelegateCreationTests.KeyServices.cs | 149 ++++++++++++++++++ src/Shared/RoslynUtils/SymbolExtensions.cs | 15 ++ src/Shared/RoslynUtils/WellKnownTypeData.cs | 2 + 49 files changed, 288 insertions(+), 79 deletions(-) create mode 100644 src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTests.KeyServices.cs 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.AssigningCode});" : + $"httpContext.RequestServices.GetRequiredKeyedService<{endpointParameter.Type}>({endpointParameter.AssigningCode})"; + 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..0424fc350366 100644 --- a/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/EndpointParameter.cs +++ b/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/EndpointParameter.cs @@ -139,6 +139,12 @@ private void ProcessEndpointParameterSource(Endpoint endpoint, ISymbol symbol, I { Source = EndpointParameterSource.Service; } + else if (attributes.TryGetAttribute(wellKnownTypes.Get(WellKnownType.Microsoft_Extensions_DependencyInjection_FromKeyedServicesAttribute), out var keyedServicesAttribute)) + { + Source = EndpointParameterSource.KeyedService; + var constructorArgument = keyedServicesAttribute.ConstructorArguments.FirstOrDefault(); + AssigningCode = constructorArgument.IsNull ? string.Empty : SymbolDisplay.FormatPrimitive(constructorArgument.Value!, true, true); + } else if (attributes.HasAttribute(wellKnownTypes.Get(WellKnownType.Microsoft_AspNetCore_Http_AsParametersAttribute))) { Source = EndpointParameterSource.AsParameters; 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..03fbd949c7fc 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)!; @@ -764,6 +766,11 @@ private static Expression CreateArgument(ParameterInfo parameter, RequestDelegat 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 +1570,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..b281d2d8c5ab --- /dev/null +++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTests.KeyServices.cs @@ -0,0 +1,149 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +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 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..c5a171cd2ac1 100644 --- a/src/Shared/RoslynUtils/SymbolExtensions.cs +++ b/src/Shared/RoslynUtils/SymbolExtensions.cs @@ -74,6 +74,21 @@ public static bool HasAttribute(this ImmutableArray attributes, I return false; } + 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; + } + public static bool HasAttributeImplementingInterface(this ISymbol symbol, INamedTypeSymbol interfaceType) { return symbol.TryGetAttributeImplementingInterface(interfaceType, out var _); 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" }; } From 52a85b211222a4645257b2022146affed007c1e4 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Wed, 16 Aug 2023 12:03:34 -0700 Subject: [PATCH 2/3] Address feedback from peer review --- .../gen/DiagnosticDescriptors.cs | 8 +++ src/Http/Http.Extensions/gen/Resources.resx | 6 +++ .../EndpointParameter.cs | 7 ++- .../src/RequestDelegateFactory.cs | 5 ++ ...equestDelegateCreationTests.KeyServices.cs | 51 +++++++++++++++++++ src/Shared/RoslynUtils/SymbolExtensions.cs | 10 +--- 6 files changed, 77 insertions(+), 10 deletions(-) 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/EndpointParameter.cs b/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/EndpointParameter.cs index 0424fc350366..133b7708b8ee 100644 --- a/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/EndpointParameter.cs +++ b/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/EndpointParameter.cs @@ -138,12 +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(); - AssigningCode = constructorArgument.IsNull ? string.Empty : SymbolDisplay.FormatPrimitive(constructorArgument.Value!, true, true); + AssigningCode = SymbolDisplay.FormatPrimitive(constructorArgument.Value!, true, true); } else if (attributes.HasAttribute(wellKnownTypes.Get(WellKnownType.Microsoft_AspNetCore_Http_AsParametersAttribute))) { diff --git a/src/Http/Http.Extensions/src/RequestDelegateFactory.cs b/src/Http/Http.Extensions/src/RequestDelegateFactory.cs index 03fbd949c7fc..139190ef23ec 100644 --- a/src/Http/Http.Extensions/src/RequestDelegateFactory.cs +++ b/src/Http/Http.Extensions/src/RequestDelegateFactory.cs @@ -763,6 +763,11 @@ 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); } diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTests.KeyServices.cs b/src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTests.KeyServices.cs index b281d2d8c5ab..9f37db71d5ed 100644 --- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTests.KeyServices.cs +++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTests.KeyServices.cs @@ -1,5 +1,7 @@ // 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; @@ -22,6 +24,55 @@ public async Task SupportsSingleKeyedServiceWithStringKey() 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 arg1) => context.Items["arg1"] = arg1); +app.MapGet("/null", (HttpContext context, [FromKeyedServices(null!)] TestService arg2) => context.Items["arg2"] = arg2); +"""; + 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["arg1"]); + Assert.Same(myOriginalService2, httpContext2.Items["arg2"]); + } + [Fact] public async Task SupportsSingleKeyedServiceWithCharKey() { diff --git a/src/Shared/RoslynUtils/SymbolExtensions.cs b/src/Shared/RoslynUtils/SymbolExtensions.cs index c5a171cd2ac1..58ec2bfe36d6 100644 --- a/src/Shared/RoslynUtils/SymbolExtensions.cs +++ b/src/Shared/RoslynUtils/SymbolExtensions.cs @@ -63,15 +63,7 @@ public static bool HasAttribute(this ISymbol symbol, INamedTypeSymbol attributeT public static bool HasAttribute(this ImmutableArray attributes, INamedTypeSymbol attributeType) { - foreach (var attributeData in attributes) - { - if (SymbolEqualityComparer.Default.Equals(attributeData.AttributeClass, attributeType)) - { - return true; - } - } - - return false; + return attributes.TryGetAttribute(attributeType, out _); } public static bool TryGetAttribute(this ImmutableArray attributes, INamedTypeSymbol attributeType, [NotNullWhen(true)] out AttributeData? matchedAttribute) From 2c4b2ef6bf35b1aa63683a5521f81bac6b06483f Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Wed, 16 Aug 2023 15:09:47 -0700 Subject: [PATCH 3/3] Support keyed services with different keys but same arg name --- .../Emitters/EndpointParameterEmitter.cs | 4 ++-- .../gen/StaticRouteHandlerModel/EndpointParameter.cs | 9 ++++++--- .../RequestDelegateCreationTests.KeyServices.cs | 8 ++++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/Emitters/EndpointParameterEmitter.cs b/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/Emitters/EndpointParameterEmitter.cs index 2497e0375b53..2d69230eaf29 100644 --- a/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/Emitters/EndpointParameterEmitter.cs +++ b/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/Emitters/EndpointParameterEmitter.cs @@ -329,8 +329,8 @@ internal static void EmitKeyedServiceParameterPreparation(this EndpointParameter codeWriter.WriteLine(endpointParameter.EmitParameterDiagnosticComment()); var assigningCode = endpointParameter.IsOptional ? - $"httpContext.RequestServices.GetKeyedService<{endpointParameter.Type}>({endpointParameter.AssigningCode});" : - $"httpContext.RequestServices.GetRequiredKeyedService<{endpointParameter.Type}>({endpointParameter.AssigningCode})"; + $"httpContext.RequestServices.GetKeyedService<{endpointParameter.Type}>({endpointParameter.KeyedServiceKey});" : + $"httpContext.RequestServices.GetRequiredKeyedService<{endpointParameter.Type}>({endpointParameter.KeyedServiceKey})"; codeWriter.WriteLine($"var {endpointParameter.EmitHandlerArgument()} = {assigningCode};"); } diff --git a/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/EndpointParameter.cs b/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/EndpointParameter.cs index 133b7708b8ee..5bc8b8471113 100644 --- a/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/EndpointParameter.cs +++ b/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/EndpointParameter.cs @@ -148,7 +148,7 @@ private void ProcessEndpointParameterSource(Endpoint endpoint, ISymbol symbol, I { Source = EndpointParameterSource.KeyedService; var constructorArgument = keyedServicesAttribute.ConstructorArguments.FirstOrDefault(); - AssigningCode = SymbolDisplay.FormatPrimitive(constructorArgument.Value!, true, true); + KeyedServiceKey = SymbolDisplay.FormatPrimitive(constructorArgument.Value!, true, true); } else if (attributes.HasAttribute(wellKnownTypes.Get(WellKnownType.Microsoft_AspNetCore_Http_AsParametersAttribute))) { @@ -271,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 @@ -624,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 && @@ -632,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/test/RequestDelegateGenerator/RequestDelegateCreationTests.KeyServices.cs b/src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTests.KeyServices.cs index 9f37db71d5ed..040d6839264f 100644 --- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTests.KeyServices.cs +++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTests.KeyServices.cs @@ -51,8 +51,8 @@ public async Task ThrowsIfKeyedAndNonKeyedAttributesOnSameParameter() public async Task SupportsKeyedServicesWithNullAndStringEmptyKeys() { var source = """ -app.MapGet("/string-empty", (HttpContext context, [FromKeyedServices("")] TestService arg1) => context.Items["arg1"] = arg1); -app.MapGet("/null", (HttpContext context, [FromKeyedServices(null!)] TestService arg2) => context.Items["arg2"] = arg2); +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(); @@ -69,8 +69,8 @@ public async Task SupportsKeyedServicesWithNullAndStringEmptyKeys() var httpContext2 = CreateHttpContext(serviceProvider); await endpoints[1].RequestDelegate(httpContext2); - Assert.Same(myOriginalService1, httpContext1.Items["arg1"]); - Assert.Same(myOriginalService2, httpContext2.Items["arg2"]); + Assert.Same(myOriginalService1, httpContext1.Items["arg"]); + Assert.Same(myOriginalService2, httpContext2.Items["arg"]); } [Fact]