Skip to content

Commit

Permalink
[DependencyInjection] Avoid useless reflection call in ActivatorUtili…
Browse files Browse the repository at this point in the history
…ties (#90378)
  • Loading branch information
benjaminpetit committed Aug 14, 2023
1 parent 9f24667 commit 3eeb275
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -583,16 +583,10 @@ private static bool IsService(IServiceProviderIsService serviceProviderIsService

private static bool TryGetServiceKey(ParameterInfo parameterInfo, out object? key)
{
if (parameterInfo.CustomAttributes != null)
foreach (var attribute in parameterInfo.GetCustomAttributes<FromKeyedServicesAttribute>(false))
{
foreach (var attribute in parameterInfo.GetCustomAttributes(true))
{
if (attribute is FromKeyedServicesAttribute keyed)
{
key = keyed.Key;
return true;
}
}
key = attribute.Key;
return true;
}
key = null;
return false;
Expand Down

0 comments on commit 3eeb275

Please sign in to comment.