You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This method was identified as a hot path in profiling JsonApiDotNetCoreExample tests.
Type.GetGenericTypeDefinition() on the incoming parameter was called inside the loop, which is unneeded. And it compared generic type parameters before looking at the type itself, potentially evaluating too much.
This change makes it run 30% faster. This change also improves input validation and fixes the bug where only the first type parameter was matched against found types.
if(genericInterfaceArguments.Length==0)thrownewArgumentException("No arguments supplied for the generic interface.",nameof(genericInterfaceArguments));
57
-
if(!openGenericInterface.IsGenericType)thrownewArgumentException("Requested type is not a generic type.",nameof(openGenericInterface));
$"Interface '{openGenericInterface.FullName}' requires {openGenericInterface.GetGenericArguments().Length} type parameters instead of {interfaceGenericTypeArguments.Length}.",
0 commit comments