示例#1
0
        /// <summary>
        /// Determine if two method references are equal, ignoring declaring type
        /// </summary>
        /// <param name="imr1">Method reference 1</param>
        /// <param name="imr2">Method reference 2</param>
        /// <returns>true if equal</returns>
        internal static bool MethodReferencesAreEqualInner(IMethodReference imr1, IMethodReference imr2)
        {
            // Nme and generic arguments must be the same...
            if (imr1.Name != imr2.Name ||
                imr1.GenericArguments.Count != imr2.GenericArguments.Count)
            {
                return(false);
            }

            // ... and generic method defining this specialization (if it is one)
            IMethodReference genericRef1 = imr1.GenericMethod;
            IMethodReference genericRef2 = imr2.GenericMethod;

            if (genericRef1 == null)
            {
                if (genericRef2 != null)
                {
                    return(false);
                }
            }
            else
            {
                if (genericRef2 == null)
                {
                    return(false);
                }

                if (!genericRef1.Equals(genericRef2))
                {
                    return(false);
                }

                for (int i = 0; i < imr2.GenericArguments.Count; i++)
                {
                    IType tRef1 = imr1.GenericArguments[i];
                    IType tRef2 = imr2.GenericArguments[i];
                    if (tRef1 == null || tRef2 == null || !tRef1.Equals(tRef2))
                    {
                        return(false);
                    }
                }
            }

            // ... and method signatures
            if (!CompareItems.MethodSignaturesAreEqual(imr1, imr2))
            {
                return(false);
            }

            return(true);
        }