Beispiel #1
0
 /// <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()})");
 }
Beispiel #2
0
 /// <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()})");
 }
Beispiel #3
0
        /// <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()));
        }
Beispiel #4
0
        /// <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()));
        }
Beispiel #5
0
        /// <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()));
        }
Beispiel #6
0
        /// <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()})");
        }
Beispiel #7
0
        /// <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));
        }
Beispiel #8
0
        /// <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));
        }
Beispiel #9
0
        /// <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));
        }
Beispiel #10
0
 /// <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);
 }
Beispiel #11
0
 /// <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);
 }
Beispiel #12
0
 /// <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;
Beispiel #13
0
 /// <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;