public IEncodedString Link(MethodReference method) { return(new RawString(_context.SignatureRenderer.Render( _context.Language, method.GetMethodSignature(_context.UrlResolver), MethodRenderOption.Link | MethodRenderOption.Name | MethodRenderOption.Parameters))); }
/// <summary> /// Decides if <paramref name="method"/> is an implementation to some of the methods declared in <paramref name="@interface"/>. /// </summary> /// <param name="method">The target method.</param> /// <param name="interface">The interface supposedly containing the target method's declaration.</param> /// <returns>Returns true, if the target method implements one of interface's methods.</returns> public static bool IsImplementationOf(this MethodReference method, TypeDefinition @interface) { if (@interface == null) { throw new ArgumentNullException("@interface can not be null."); } if ([email protected]) { throw new ArgumentOutOfRangeException("The @interface argument is not an interface definition."); } if (method.DeclaringType.FullName == @interface.FullName) { return(true); } if (method.IsExplicitImplementationOf(@interface)) { return(true); } bool hasSameSignatureMethod = false; string signature = method.GetMethodSignature(); foreach (MethodDefinition interfaceMethod in @interface.Methods) { if (interfaceMethod.GetMethodSignature() == signature) { hasSameSignatureMethod = true; } } if (!hasSameSignatureMethod) { return(false); } TypeDefinition declaringType = method.DeclaringType.Resolve(); if (declaringType == null) { return(false); } List <TypeDefinition> baseTypes = declaringType.GetBaseTypes(); foreach (TypeDefinition t in baseTypes) { if (t.FullName == @interface.FullName) { return(true); } } return(false); }
public static bool HasSameSignatureWith(this MethodReference self, MethodReference other) { if (!(self.GetMethodSignature() == other.GetMethodSignature())) { return(false); } if (self.ReturnType.FullName != other.ReturnType.FullName) { if (self.ReturnType is GenericParameter && other.ReturnType is GenericParameter) { if ((self.ReturnType as GenericParameter).Position == (other.ReturnType as GenericParameter).Position) { return(true); } } return(false); } return(true); }
public static bool HasSameSignatureWith(this MethodReference self, MethodReference other) { if (!(self.GetMethodSignature() == other.GetMethodSignature())) { return false; } if (self.ReturnType.FullName != other.ReturnType.FullName) { if (self.ReturnType is GenericParameter && other.ReturnType is GenericParameter) { if ((self.ReturnType as GenericParameter).Position == (other.ReturnType as GenericParameter).Position) { return true; } } return false; } return true; }