/// <summary> /// Resolves a method /// </summary> /// <param name="self">this</param> /// <param name="memberRef">A method reference</param> /// <returns>A <see cref="MethodDef"/> instance or <c>null</c> if it couldn't be resolved.</returns> /// <exception cref="MemberRefResolveException">If the method couldn't be resolved</exception> public static MethodDef ResolveMethodThrow(this IMemberRefResolver self, MemberRef memberRef) { if (self.Resolve(memberRef) is MethodDef method) { return(method); } throw new MemberRefResolveException($"Could not resolve method: {memberRef} ({memberRef?.GetDefinitionAssembly()})"); }
/// <summary> /// Resolves a field /// </summary> /// <param name="self">this</param> /// <param name="memberRef">A field reference</param> /// <returns>A <see cref="FieldDef"/> instance or <c>null</c> if it couldn't be resolved.</returns> /// <exception cref="MemberRefResolveException">If the field couldn't be resolved</exception> public static FieldDef ResolveFieldThrow(this IMemberRefResolver self, MemberRef memberRef) { if (self.Resolve(memberRef) is FieldDef field) { return(field); } throw new MemberRefResolveException($"Could not resolve field: {memberRef} ({memberRef?.GetDefinitionAssembly()})"); }
/// <summary> /// Resolves a method or a field /// </summary> /// <param name="self">this</param> /// <param name="memberRef">A method/field reference</param> /// <returns>A <see cref="MethodDef"/> or a <see cref="FieldDef"/> instance</returns> /// <exception cref="MemberRefResolveException">If the method/field couldn't be resolved</exception> public static IMemberForwarded ResolveThrow(this IMemberRefResolver self, MemberRef memberRef) { var memberDef = self.Resolve(memberRef); if (memberDef != null) { return(memberDef); } throw new MemberRefResolveException(string.Format("Could not resolve method/field: {0} ({1})", memberRef, memberRef == null ? null : memberRef.GetDefinitionAssembly())); }
/// <summary> /// Resolves a method /// </summary> /// <param name="self">this</param> /// <param name="memberRef">A method reference</param> /// <returns>A <see cref="MethodDef"/> instance or <c>null</c> if it couldn't be resolved.</returns> /// <exception cref="MemberRefResolveException">If the method couldn't be resolved</exception> public static MethodDef ResolveMethodThrow(this IMemberRefResolver self, MemberRef memberRef) { var method = self.Resolve(memberRef) as MethodDef; if (method != null) { return(method); } throw new MemberRefResolveException(string.Format("Could not resolve method: {0} ({1})", memberRef, memberRef == null ? null : memberRef.GetDefinitionAssembly())); }
/// <summary> /// Resolves a field /// </summary> /// <param name="self">this</param> /// <param name="memberRef">A field reference</param> /// <returns>A <see cref="FieldDef"/> instance or <c>null</c> if it couldn't be resolved.</returns> /// <exception cref="MemberRefResolveException">If the field couldn't be resolved</exception> public static FieldDef ResolveFieldThrow(this IMemberRefResolver self, MemberRef memberRef) { var field = self.Resolve(memberRef) as FieldDef; if (field != null) { return(field); } throw new MemberRefResolveException(string.Format("Could not resolve field: {0} ({1})", memberRef, memberRef == null ? null : memberRef.GetDefinitionAssembly())); }
/// <summary> /// Resolves a method or a field /// </summary> /// <param name="self">this</param> /// <param name="memberRef">A method/field reference</param> /// <returns>A <see cref="MethodDef"/> or a <see cref="FieldDef"/> instance</returns> /// <exception cref="MemberRefResolveException">If the method/field couldn't be resolved</exception> public static IMemberForwarded ResolveThrow(this IMemberRefResolver self, MemberRef memberRef) { var memberDef = self.Resolve(memberRef); if (memberDef != null) { return(memberDef); } throw new MemberRefResolveException($"Could not resolve method/field: {memberRef} ({memberRef?.GetDefinitionAssembly()})"); }
/// <summary> /// Resolves a method or a field /// </summary> /// <param name="self">this</param> /// <param name="memberRef">A method/field reference</param> /// <returns>A <see cref="MethodDef"/> or a <see cref="FieldDef"/> instance</returns> /// <exception cref="MemberRefResolveException">If the method/field couldn't be resolved</exception> public static IMemberForwarded ResolveThrow(this IMemberRefResolver self, MemberRef memberRef) { var memberDef = self.Resolve(memberRef); if (memberDef != null) { return(memberDef); } throw new MemberRefResolveException(string.Format("Could not resolve method/field: {0}", memberRef)); }
/// <summary> /// Resolves a method /// </summary> /// <param name="self">this</param> /// <param name="memberRef">A method reference</param> /// <returns>A <see cref="MethodDef"/> instance or <c>null</c> if it couldn't be resolved.</returns> /// <exception cref="MemberRefResolveException">If the method couldn't be resolved</exception> public static MethodDef ResolveMethodThrow(this IMemberRefResolver self, MemberRef memberRef) { var method = self.Resolve(memberRef) as MethodDef; if (method != null) { return(method); } throw new MemberRefResolveException(string.Format("Could not resolve method: {0}", memberRef)); }
/// <summary> /// Resolves a field /// </summary> /// <param name="self">this</param> /// <param name="memberRef">A field reference</param> /// <returns>A <see cref="FieldDef"/> instance or <c>null</c> if it couldn't be resolved.</returns> /// <exception cref="MemberRefResolveException">If the field couldn't be resolved</exception> public static FieldDef ResolveFieldThrow(this IMemberRefResolver self, MemberRef memberRef) { var field = self.Resolve(memberRef) as FieldDef; if (field != null) { return(field); } throw new MemberRefResolveException(string.Format("Could not resolve field: {0}", memberRef)); }
/// <summary> /// Resolves a method /// </summary> /// <param name="self">this</param> /// <param name="memberRef">A method reference</param> /// <returns>A <see cref="MethodDef"/> instance or <c>null</c> if it couldn't be resolved.</returns> public static MethodDef ResolveMethod(this IMemberRefResolver self, MemberRef memberRef) { return(self.Resolve(memberRef) as MethodDef); }
/// <summary> /// Resolves a field /// </summary> /// <param name="self">this</param> /// <param name="memberRef">A field reference</param> /// <returns>A <see cref="FieldDef"/> instance or <c>null</c> if it couldn't be resolved.</returns> public static FieldDef ResolveField(this IMemberRefResolver self, MemberRef memberRef) { return(self.Resolve(memberRef) as FieldDef); }
/// <summary> /// Resolves a field /// </summary> /// <param name="self">this</param> /// <param name="memberRef">A field reference</param> /// <returns>A <see cref="FieldDef"/> instance or <c>null</c> if it couldn't be resolved.</returns> public static FieldDef ResolveField(this IMemberRefResolver self, MemberRef memberRef) => self.Resolve(memberRef) as FieldDef;
/// <summary> /// Resolves a method /// </summary> /// <param name="self">this</param> /// <param name="memberRef">A method reference</param> /// <returns>A <see cref="MethodDef"/> instance or <c>null</c> if it couldn't be resolved.</returns> public static MethodDef ResolveMethod(this IMemberRefResolver self, MemberRef memberRef) => self.Resolve(memberRef) as MethodDef;