/// <summary> /// Determine if two method references are equal /// </summary> /// <param name="imr1">First method reference</param> /// <param name="imr2">Second method reference</param> /// <returns>true if equal</returns> internal static bool MethodReferencesAreEqual(IMethodReference imr1, IMethodReference imr2) { if (imr1 == imr2) { return(true); } // Method references and declaring types must be the same return(CompareItems.MethodReferencesAreEqualInner(imr1, imr2) && imr1.DeclaringType.Equals(imr2.DeclaringType)); }
/// <summary> /// Resolve the method reference /// </summary> /// <returns>The declaration for the reference</returns> public IMethodDeclaration Resolve() { // If we have already resolved this, and the reference is still // alive, then return it. if (this.methodDeclaration != null && this.methodDeclaration.IsAlive) { return((IMethodDeclaration)this.methodDeclaration.Target); } // Get the declaring type reference ITypeReference declrType = this.DeclaringType as ITypeReference; // Search up the inheritance chain for the method declaration while (declrType != null) { // Resolve the declaring type ITypeDeclaration decl = declrType.Resolve(); if (decl == null) { return(null); } // Look through the declaring type's methods foreach (IMethodDeclaration imd in decl.Methods) { if (CompareItems.MethodReferencesAreEqualInner(this, imd)) { this.methodDeclaration = new WeakReference(imd); return((IMethodDeclaration)(this.methodDeclaration.Target)); } } // Go up an inheritance level declrType = decl.BaseType; } // Nothing doing return(null); }