AreAliases() public static method

public static AreAliases ( string typeA, string typeB ) : bool
typeA string
typeB string
return bool
Exemplo n.º 1
0
        private MethodDefinition GetMethodDefinition(IEnumerable <MethodDefinition> methods, MethodReference reference)
        {
            foreach (var methodDefinition in methods)
            {
                bool isSameName = methodDefinition.Name == reference.Name || MethodAliases.AreAliases(methodDefinition.Name, reference.Name);
                bool isSameGenericParameters = methodDefinition.HasGenericParameters == reference.HasGenericParameters &&
                                               (!methodDefinition.HasGenericParameters || methodDefinition.GenericParameters.Count == reference.GenericParameters.Count);

                bool isSameReturnType = AreSame(methodDefinition.ReturnType, reference.ReturnType);

                if (isSameName && isSameGenericParameters && isSameReturnType && methodDefinition.HasParameters == reference.HasParameters)
                {
                    if (!methodDefinition.HasParameters && !reference.HasParameters)
                    {
                        return(methodDefinition);
                    }

                    if (AreSame(methodDefinition.Parameters, reference.Parameters))
                    {
                        return(methodDefinition);
                    }
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        private MethodDefinition GetCompatibleMethodDefinition(IEnumerable <MethodDefinition> methods, MethodReference reference)
        {
            foreach (var methodDefinition in methods)
            {
                bool isSameName = methodDefinition.Name == reference.Name || MethodAliases.AreAliases(methodDefinition.Name, reference.Name);
                bool isSameGenericParameters = methodDefinition.HasGenericParameters == reference.HasGenericParameters &&
                                               (!methodDefinition.HasGenericParameters || methodDefinition.GenericParameters.Count == reference.GenericParameters.Count);

                bool isSameReturnType = AreSame(methodDefinition.ReturnType, reference.ReturnType);

                if (isSameName && isSameGenericParameters && isSameReturnType)
                {
                    if (ArgsMatchParamsList(methodDefinition.Parameters, reference.Parameters))
                    {
                        ParamsMethod          = Context.TargetModule.Import(methodDefinition);
                        MethodChanged         = true;
                        Context.RewriteTarget = true;
                        return(methodDefinition);
                    }
                }
            }

            return(null);
        }