Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        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>());
        }
Esempio n. 3
0
 void Write(DmdMethodBase method) => WriteMethod(method.Name, method.GetMethodSignature(), GetGenericArguments(method), isMethod: true);
Esempio n. 4
0
 string FormatCore(DmdMethodBase method)
 {
     Write(method);
     return(writer.ToString());
 }
Esempio n. 5
0
 public static string Format(DmdMethodBase method, bool serializable = false)
 {
     using (var formatter = new DmdMemberFormatter(serializable ? GlobalFlags.Serializable : GlobalFlags.None))
         return(formatter.FormatCore(method));
 }
Esempio n. 6
0
 /// <summary>
 /// Executes a method
 /// </summary>
 /// <param name="context">Evaluation context</param>
 /// <param name="method">Method to call</param>
 /// <param name="obj">Instance object or null if it's a static method</param>
 /// <param name="parameters">Parameters passed to the method</param>
 /// <returns></returns>
 public abstract object Invoke(object context, DmdMethodBase method, object obj, object[] parameters);
Esempio n. 7
0
 /// <summary>
 /// Makes a generic method parameter
 /// </summary>
 /// <param name="position">Position</param>
 /// <param name="declaringMethod">Declaring method</param>
 /// <param name="name">Name</param>
 /// <param name="attributes">Attributes</param>
 /// <param name="customModifiers">Custom modifiers or null</param>
 /// <param name="options">Options</param>
 /// <returns></returns>
 public abstract DmdType MakeGenericMethodParameter(int position, DmdMethodBase declaringMethod, string name, DmdGenericParameterAttributes attributes, IList <DmdCustomModifier> customModifiers, DmdMakeTypeOptions options = DmdMakeTypeOptions.None);
Esempio n. 8
0
 /// <summary>
 /// Makes a generic method parameter
 /// </summary>
 /// <param name="position">Position</param>
 /// <param name="declaringMethod">Declaring method</param>
 /// <returns></returns>
 public DmdType MakeGenericMethodParameter(int position, DmdMethodBase declaringMethod) => MakeGenericMethodParameter(position, declaringMethod, string.Empty, 0, null);
Esempio n. 9
0
 /// <summary>
 /// Executes a method
 /// </summary>
 /// <param name="context">Evaluation context</param>
 /// <param name="method">Method to call</param>
 /// <param name="obj">Instance object or null if it's a constructor or a static method</param>
 /// <param name="parameters">Parameters passed to the method</param>
 /// <param name="callback">Notified when the method is complete</param>
 public abstract void Invoke(object context, DmdMethodBase method, object obj, object[] parameters, Action <object> callback);
Esempio n. 10
0
 /// <summary>
 /// Executes a method
 /// </summary>
 /// <param name="context">Evaluation context</param>
 /// <param name="method">Method to call</param>
 /// <param name="obj">Instance object or null if it's a static method</param>
 /// <param name="parameters">Parameters passed to the method</param>
 /// <returns></returns>
 public abstract object?Invoke(object?context, DmdMethodBase method, object?obj, object?[]?parameters);
Esempio n. 11
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="method">Method that couldn't be resolved</param>
 public MethodResolveException(DmdMethodBase method) : base("Couldn't resolve method: " + method.ToString() + ", type: " + method.DeclaringType !.ToString()) => Method = method;