// 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)); }
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); } }
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); }
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)); }
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); }