/// <summary> /// Compares two methods or constructors /// </summary> /// <param name="a">First method or constructor</param> /// <param name="b">Second method or constructor</param> /// <returns></returns> public bool Equals(DmdMethodBase a, DmdMethodBase b) { if ((object)a == b) { return(true); } if ((object)a == null || (object)b == null) { return(false); } return(MemberNameEquals(a.Name, b.Name) && Equals(a.GetMethodSignature(), b.GetMethodSignature()) && (!CompareDeclaringType || Equals(a.DeclaringType, b.DeclaringType))); }
/// <summary> /// Gets the hash code of a method or constructor /// </summary> /// <param name="a">Method or constructor</param> /// <returns></returns> public int GetHashCode(DmdMethodBase a) { if ((object)a == null) { return(0); } int hc = MemberNameGetHashCode(a.Name); hc ^= GetHashCode(a.GetMethodSignature()); if (CompareDeclaringType) { hc ^= GetHashCode(a.DeclaringType); } return(hc); }
static IList <DmdType> GetGenericArguments(DmdMethodBase method) { if (method.GetMethodSignature().GenericParameterCount == 0) { return(Array.Empty <DmdType>()); } if (!method.IsMetadataReference) { return(method.GetGenericArguments()); } var resolvedMethod = method.ResolveMethodBaseNoThrow(); if ((object)resolvedMethod != null) { return(resolvedMethod.GetGenericArguments()); } return(Array.Empty <DmdType>()); }
void Write(DmdMethodBase method) => WriteMethod(method.Name, method.GetMethodSignature(), GetGenericArguments(method), isMethod: true);