Ejemplo n.º 1
0
        private FindMethodResult FindMethodInCollection(IMethodDefinition targetMethod, IEnumerable <IMethodDefinition> collectionOfMethods, out IMethodDefinition foundMethod, bool removeExplicitName)
        {
            string targetMethodName         = (removeExplicitName) ? targetMethod.GetNameWithoutExplicitType() : targetMethod.Name.Value;
            bool   foundDifferentReturntype = false;

            foundMethod = null;
            foreach (IMethodDefinition potentialMatch in collectionOfMethods)
            {
                if (removeExplicitName && potentialMatch.IsExplicitInterfaceMethod())
                {
                    continue;
                }

                if (targetMethodName == potentialMatch.Name.Value)
                {
                    if (ParameterTypesAreEqual(potentialMatch, targetMethod))
                    {
                        if (!ReturnTypesMatch(potentialMatch, targetMethod))
                        {
                            foundDifferentReturntype = true;
                            foundMethod = potentialMatch;
                        }

                        if (!targetMethod.IsGeneric && !potentialMatch.IsGeneric)
                        {
                            foundMethod = potentialMatch;
                            return(FindMethodResult.Found);
                        }

                        if (targetMethod.GenericParameterCount == potentialMatch.GenericParameterCount)
                        {
                            foundMethod = potentialMatch;
                            return(FindMethodResult.Found);
                        }
                    }
                }
            }
            if (foundDifferentReturntype)
            {
                return(FindMethodResult.ReturnTypeChanged);
            }
            return(FindMethodResult.NotFound);
        }
Ejemplo n.º 2
0
        private FindMethodResult FindMethodInCollection(IMethodDefinition targetMethod, IEnumerable<IMethodDefinition> collectionOfMethods, out IMethodDefinition foundMethod, bool removeExplicitName)
        {
            string targetMethodName = (removeExplicitName) ? targetMethod.GetNameWithoutExplicitType() : targetMethod.Name.Value;
            bool foundDifferentReturntype = false;
            foundMethod = null;
            foreach (IMethodDefinition potentialMatch in collectionOfMethods)
            {
                if (removeExplicitName && potentialMatch.IsExplicitInterfaceMethod()) continue;

                if (targetMethodName == potentialMatch.Name.Value)
                {
                    if (ParameterTypesAreEqual(potentialMatch, targetMethod))
                    {
                        if (!ReturnTypesMatch(potentialMatch, targetMethod))
                        {
                            foundDifferentReturntype = true;
                            foundMethod = potentialMatch;
                        }

                        if (!targetMethod.IsGeneric && !potentialMatch.IsGeneric)
                        {
                            foundMethod = potentialMatch;
                            return FindMethodResult.Found;
                        }

                        if (targetMethod.GenericParameterCount == potentialMatch.GenericParameterCount)
                        {
                            foundMethod = potentialMatch;
                            return FindMethodResult.Found;
                        }
                    }
                }
            }
            if (foundDifferentReturntype)
                return FindMethodResult.ReturnTypeChanged;
            return FindMethodResult.NotFound;
        }