From: Jan Kotas Date: Wed, 18 Mar 2020 03:22:39 +0000 (-0700) Subject: Avoid unnecessary use of Linq (#33700) X-Git-Tag: submit/tizen/20210909.063632~9105 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eb2477c94a188749198d3acdedc9f682bdb69dfa;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Avoid unnecessary use of Linq (#33700) --- diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceLookup/CallSiteFactory.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceLookup/CallSiteFactory.cs index 71c70cee8d3..13f93b99bfb 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceLookup/CallSiteFactory.cs +++ b/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceLookup/CallSiteFactory.cs @@ -134,7 +134,7 @@ namespace Microsoft.Extensions.DependencyInjection.ServiceLookup if (serviceType.IsConstructedGenericType && serviceType.GetGenericTypeDefinition() == typeof(IEnumerable<>)) { - var itemType = serviceType.GenericTypeArguments.Single(); + var itemType = serviceType.GenericTypeArguments[0]; var cacheLocation = CallSiteResultCacheLocation.Root; var callSites = new List(); diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/Utils/MultiServiceHelpers.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/Utils/MultiServiceHelpers.cs index c1ab996e9dd..ab44b14269b 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/Utils/MultiServiceHelpers.cs +++ b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/Utils/MultiServiceHelpers.cs @@ -5,7 +5,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq; using System.Reflection; namespace Microsoft.Extensions.DependencyInjection.Tests @@ -43,7 +42,7 @@ namespace Microsoft.Extensions.DependencyInjection.Tests private static Type FirstGenericArgument(Type type) { - return type.GetTypeInfo().GenericTypeArguments.Single(); + return type.GetTypeInfo().GenericTypeArguments[0]; } private static IList CreateEmptyList(Type innerType)