From 2bc5913222b5c6acda6d34c933644c8b112b8dda Mon Sep 17 00:00:00 2001 From: NicoBrabers Date: Sat, 18 May 2024 01:47:39 +0200 Subject: [PATCH] Fix for issue #54500: Refactored the TryGetServiceKey method and added the NotNullWhen(true) attribute. Also changed the Inherit param from true to false when obtaining the custom attribute FromKeyedServicesAttribute. --- .../src/Extensions/UseMiddlewareExtensions.cs | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/Http/Http.Abstractions/src/Extensions/UseMiddlewareExtensions.cs b/src/Http/Http.Abstractions/src/Extensions/UseMiddlewareExtensions.cs index 16140612435b..f6d4bdc1b884 100644 --- a/src/Http/Http.Abstractions/src/Extensions/UseMiddlewareExtensions.cs +++ b/src/Http/Http.Abstractions/src/Extensions/UseMiddlewareExtensions.cs @@ -214,7 +214,8 @@ private static Func ReflectionFallback ReflectionFallback(false)?.Key; - return false; + return key != null; } private static UnaryExpression GetMethodArgument(ParameterInfo parameter, ParameterExpression providerArg, Type parameterType, Type? declaringType)