Beispiel #1
0
        // Recipe 1 (slow)
        // Using reflection to access to the "TokenValue" property (non public)
        private static uint GetMethodToken_ByReflection(IMethodDefinition methodDefinition)
        {
            Type         type     = methodDefinition.GetType();
            PropertyInfo property = type.GetProperty("TokenValue", BindingFlags.Instance | BindingFlags.NonPublic);

            return((uint)property.GetValue(methodDefinition, null));
        }
Beispiel #2
0
        public virtual void Visit(IMethodDefinition method)
        {
            this.Visit(method.ReturnValueAttributes);
            if (method.ReturnValueIsModified)
            {
                this.Visit(method.ReturnValueCustomModifiers);
            }

            if (method.HasDeclarativeSecurity)
            {
                this.Visit(method.SecurityAttributes);
            }

            if (method.IsGeneric)
            {
                this.Visit(method.GenericParameters);
            }

            this.Visit(method.GetType(Context));
            this.Visit(method.Parameters);
            if (method.IsPlatformInvoke)
            {
                this.Visit(method.PlatformInvokeData);
            }
        }
Beispiel #3
0
        public static IMethodDefinition ResolveMethodThrowing(IMethodReference method)
        {
            IMethodDefinition result = method.ResolvedMethod;

            if (result == Dummy.Method ||
                result == null)
            {
                throw new Exception(String.Format("Cannot resolve member '{0}'. Are all dependent assemblies loaded?", method.ToString()));
            }

            Debug.Assert(!result.GetType().Name.Contains("Dummy"));
            return(result);
        }
Beispiel #4
0
        public virtual void Visit(IMethodDefinition method)
        {
            this.Visit(method.GetReturnValueAttributes(Context));
            this.Visit(method.RefCustomModifiers);
            this.Visit(method.ReturnValueCustomModifiers);

            if (method.IsGeneric)
            {
                this.Visit(method.GenericParameters);
            }

            this.Visit(method.GetType(Context));
            this.Visit(method.Parameters);
            if (method.IsPlatformInvoke)
            {
                this.Visit(method.PlatformInvokeData);
            }
        }
 public ITypeReference GetType(EmitContext context)
 {
     return(_containingMethod.GetType(context));
 }
Beispiel #6
0
        public virtual void Visit(IMethodDefinition method)
        {
            this.Visit(method.ReturnValueAttributes);
            this.Visit(method.ReturnValueCustomModifiers);

            if (method.HasDeclarativeSecurity)
            {
                this.Visit(method.SecurityAttributes);
            }

            if (method.IsGeneric)
            {
                this.Visit(method.GenericParameters);
            }

            this.Visit(method.GetType(Context));
            this.Visit(method.Parameters);
            if (method.IsPlatformInvoke)
            {
                this.Visit(method.PlatformInvokeData);
            }
        }
 public ITypeReference GetType(EmitContext context)
 {
     return(DeletedTypeDefinition.TryCreate(_oldMethod.GetType(context), _typesUsedByDeletedMembers));
 }
 // Recipe 1 (slow)
 // Using reflection to access to the "TokenValue" property (non public)
 private static uint GetMethodToken_ByReflection(IMethodDefinition methodDefinition)
 {
     Type type = methodDefinition.GetType();
     PropertyInfo property = type.GetProperty("TokenValue", BindingFlags.Instance | BindingFlags.NonPublic);
     return (uint)property.GetValue(methodDefinition, null);
 }