src/Shared/EntityFramework/Core/Objects/ELinq/ReflectionUtil.cs
// <remarks>
// Requires:
// - no collisions on type names
// - no output or reference method parameters
// </remarks>
// <summary>
// Produces a string description of a method consisting of the name and all parameters,
// where all generic type parameters have been substituted with number identifiers.
// </summary>
// <param name="method"> Method to identify. </param>
// <returns> Canonical description of method (suitable for lookup) </returns>
Produces a string description of a method consisting of the name and all parameters,
where all generic type parameters have been substituted with number identifiers.
Produces a string description of a method consisting of the name and all parameters where all generic type parameters have been substituted with number identifiers .
internal static string GetCanonicalMethodDescription(MethodInfo method)
        {
            DebugCheck.NotNull(method);
            Dictionary<Type, int> genericArgumentOrdinals = null;
            if (method.IsGenericMethodDefinition)
            {
                genericArgumentOrdinals = method.GetGenericArguments()
                                                .Where(t => t.IsGenericParameter())
                                                .Select((t, i) => new KeyValuePair<Type, int>(t, i))
                                                .ToDictionary(r => r.Key, r => r.Value);
            }
            var description = new StringBuilder();
            description.Append(method.Name).Append("(");
            var first = true;
            foreach (var parameter in method.GetParameters())
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    description.Append(", ");
                }
                AppendCanonicalTypeDescription(parameter.ParameterType, genericArgumentOrdinals, description);
            }
            description.Append(")");
            if (null != method.ReturnType)
            {
                description.Append("->");
                AppendCanonicalTypeDescription(method.ReturnType, genericArgumentOrdinals, description);
            }
            return description.ToString();
        }
internal static string GetCanonicalMethodDescription ( MethodInfo method ) { DebugCheck . NotNull ( method ) ; Dictionary < Type , int > genericArgumentOrdinals = null ; if ( method . IsGenericMethodDefinition ) { genericArgumentOrdinals = method . GetGenericArguments ( ) . Where ( t => t . IsGenericParameter ( ) ) . Select ( ( t , i ) => new KeyValuePair < Type , int > ( t , i ) ) . ToDictionary ( r => r . Key , r => r . Value ) ; } var description = new StringBuilder ( ) ; description . Append ( method . Name ) . Append ( " " ) ; var first = true ; foreach ( var parameter in method . GetParameters ( ) ) { if ( first ) { first = false ; } else { description . Append ( " " ) ; } AppendCanonicalTypeDescription ( parameter . ParameterType , genericArgumentOrdinals , description ) ; } description . Append ( " " ) ; if ( null != method . ReturnType ) { description . Append ( " " ) ; AppendCanonicalTypeDescription ( method . ReturnType , genericArgumentOrdinals , description ) ; } return description . ToString ( ) ; }
Produces a string description of a method consisting of the name and all parameters,
where all generic type parameters have been substituted with number identifiers.
Produces a string description of a method consisting of the name and all parameters where all generic type parameters have been substituted with number identifiers .
// retrieve all generic type arguments and assign them numbers based on order // append types for all method parameters // include return type
Canonical description of method (suitable for lookup)
Canonical description of method ( suitable for lookup )
method
MethodInfo
Method to identify.
Method to identify .
remarks
no collisions on type names
no output or reference method parameters
no collisions on type names no output or reference method parameters