diff --git a/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/Emitters/EndpointParameterEmitter.cs b/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/Emitters/EndpointParameterEmitter.cs index ef8712e791fd..3d20278757ae 100644 --- a/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/Emitters/EndpointParameterEmitter.cs +++ b/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/Emitters/EndpointParameterEmitter.cs @@ -337,7 +337,7 @@ internal static void EmitKeyedServiceParameterPreparation(this EndpointParameter codeWriter.WriteLine("if (httpContext.RequestServices.GetService() is not IServiceProviderIsKeyedService)"); codeWriter.StartBlock(); - codeWriter.WriteLine(@"throw new InvalidOperationException($""Unable to resolve {nameof(FromKeyedServicesAttribute)}. This service provider doesn't support keyed services."");"); + codeWriter.WriteLine(@"throw new InvalidOperationException($""Unable to resolve service referenced by {nameof(FromKeyedServicesAttribute)}. The service provider doesn't support keyed services."");"); codeWriter.EndBlock(); var assigningCode = endpointParameter.IsOptional ? diff --git a/src/Http/Http.Extensions/src/RequestDelegateFactory.cs b/src/Http/Http.Extensions/src/RequestDelegateFactory.cs index 957a9aefff21..50b43f2ab027 100644 --- a/src/Http/Http.Extensions/src/RequestDelegateFactory.cs +++ b/src/Http/Http.Extensions/src/RequestDelegateFactory.cs @@ -790,7 +790,7 @@ private static Expression CreateArgument(ParameterInfo parameter, RequestDelegat { if (factoryContext.ServiceProviderIsService is not IServiceProviderIsKeyedService) { - throw new InvalidOperationException($"Unable to resolve {nameof(FromKeyedServicesAttribute)}. This service provider doesn't support keyed services."); + throw new InvalidOperationException($"Unable to resolve service referenced by {nameof(FromKeyedServicesAttribute)}. The service provider doesn't support keyed services."); } var key = keyedServicesAttribute.Key; return BindParameterFromKeyedService(parameter, key, factoryContext); diff --git a/src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTests.KeyServices.cs b/src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTests.KeyServices.cs index a50ab15cf25e..32c08cd4e22b 100644 --- a/src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTests.KeyServices.cs +++ b/src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTests.KeyServices.cs @@ -214,14 +214,14 @@ public async Task ThrowsIfDiContainerDoesNotSupportKeyedServices() if (!IsGeneratorEnabled) { var runtimeException = Assert.Throws(() => GetEndpointFromCompilation(compilation, serviceProvider: serviceProvider)); - Assert.Equal("Unable to resolve FromKeyedServicesAttribute. This service provider doesn't support keyed services.", runtimeException.Message); + Assert.Equal("Unable to resolve service referenced by FromKeyedServicesAttribute. The service provider doesn't support keyed services.", runtimeException.Message); return; } var endpoint = GetEndpointFromCompilation(compilation, serviceProvider: serviceProvider); var httpContext = CreateHttpContext(serviceProvider); var exception = await Assert.ThrowsAsync(async () => await endpoint.RequestDelegate(httpContext)); - Assert.Equal("Unable to resolve FromKeyedServicesAttribute. This service provider doesn't support keyed services.", exception.Message); + Assert.Equal("Unable to resolve service referenced by FromKeyedServicesAttribute. The service provider doesn't support keyed services.", exception.Message); } private class MockServiceProvider : IServiceProvider, ISupportRequiredService diff --git a/src/SignalR/server/Core/src/Internal/HubMethodDescriptor.cs b/src/SignalR/server/Core/src/Internal/HubMethodDescriptor.cs index 4ea62842e762..b10e83eeecd3 100644 --- a/src/SignalR/server/Core/src/Internal/HubMethodDescriptor.cs +++ b/src/SignalR/server/Core/src/Internal/HubMethodDescriptor.cs @@ -110,7 +110,7 @@ public HubMethodDescriptor(ObjectMethodExecutor methodExecutor, IServiceProvider } else { - throw new InvalidOperationException($"This service provider doesn't support keyed services."); + throw new InvalidOperationException($"Unable to resolve service referenced by {nameof(FromKeyedServicesAttribute)}. The service provider doesn't support keyed services."); } }