Ejemplo 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);
        }
Ejemplo 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>());
        }
Ejemplo n.º 3
0
 void Write(DmdMethodBase method) => WriteMethod(method.Name, method.GetMethodSignature(), GetGenericArguments(method), isMethod: true);
Ejemplo n.º 4
0
 string FormatCore(DmdMethodBase method)
 {
     Write(method);
     return(writer.ToString());
 }
Ejemplo 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));
 }
Ejemplo 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);
Ejemplo 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);
Ejemplo 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);
Ejemplo 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);
Ejemplo 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);
Ejemplo 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;