// // Returns the MethodBase for "Invoke" from a delegate type, this is used // to extract the signature of a delegate. // public static MethodInfo GetInvokeMethod(CompilerContext ctx, Type container_type, Type delegate_type) { Type dt = delegate_type; Type[] g_args = null; if (TypeManager.IsGenericType(delegate_type)) { g_args = TypeManager.GetTypeArguments(delegate_type); delegate_type = TypeManager.DropGenericTypeArguments(delegate_type); } Delegate d = TypeManager.LookupDelegate(delegate_type); MethodInfo invoke; if (d != null) { #if GMCS_SOURCE if (g_args != null) { invoke = TypeBuilder.GetMethod(dt, d.InvokeBuilder); #if MS_COMPATIBLE ParametersCompiled p = (ParametersCompiled)d.Parameters.InflateTypes(g_args, g_args); TypeManager.RegisterMethod(invoke, p); #endif return(invoke); } #endif return(d.InvokeBuilder); } Expression ml = Expression.MemberLookup(ctx, container_type, null, dt, "Invoke", Location.Null); MethodGroupExpr mg = ml as MethodGroupExpr; if (mg == null) { ctx.Report.Error(-100, Location.Null, "Internal error: could not find Invoke method!"); // FIXME: null will cause a crash later return(null); } invoke = (MethodInfo)mg.Methods[0]; #if MS_COMPATIBLE if (g_args != null) { AParametersCollection p = TypeManager.GetParameterData(invoke); p = p.InflateTypes(g_args, g_args); TypeManager.RegisterMethod(invoke, p); return(invoke); } #endif return(invoke); }