28 public static void ActionThunk(Func<
object[],
object> handler)
30 handler(
Array.Empty<
object>());
35 handler(
new object[1] { t1 });
40 handler(
new object[2] { t1, t2 });
45 return (TReturn)handler(
Array.Empty<
object>());
50 return (TReturn)handler(
new object[1] { t1 });
55 return (TReturn)handler(
new object[2] { t1, t2 });
60 return typeof(
Array).GetMethod(
"Empty").MakeGenericMethod(typeof(
object));
85 [UnconditionalSuppressMessage(
"ReflectionAnalysis",
"IL2060:MakeGenericMethod", Justification =
"The above ActionThunk and FuncThunk methods don't have trimming annotations.")]
90 if (parameters.Length > 2)
106 int num = parameters.Length;
112 for (
int j = 0; j < parameters.Length; j++)
114 array[j] = parameters[j].ParameterType;
119 array[^1] = returnType;
138 MethodInfo invokeMethod = delegateType.GetInvokeMethod();
140 bool flag = returnType != typeof(
void);
141 ParameterInfo[] parametersCached = invokeMethod.GetParametersCached();
147 array[0] = typeof(Func<
object[],
object>);
149 stringBuilder.
Append(
"Thunk");
150 stringBuilder.
Append(value2);
153 stringBuilder.
Append(
"ret_");
156 for (
int i = 0; i < parametersCached.Length; i++)
158 stringBuilder.
Append(
'_');
159 stringBuilder.
Append(parametersCached[i].ParameterType.
Name);
163 value = dynamicMethod;
167 if (parametersCached.Length == 0)
178 for (
int j = 0; j < parametersCached.Length; j++)
186 flag2 = flag2 || isByRef;
209 for (
int k = 0; k < parametersCached.Length; k++)
211 if (parametersCached[k].ParameterType.IsByRef)
233 return value.CreateDelegate(delegateType, handler);
static readonly MethodInfo[] s_ActionThunks
static TReturn FuncThunk< TReturn >(Func< object[], object > handler)
static MethodInfo GetCSharpThunk(Type returnType, bool hasReturnValue, ParameterInfo[] parameters)
static MethodInfo GetEmptyObjectArrayMethod()
static readonly MethodInfo[] s_FuncThunks
static readonly MethodInfo s_ArrayEmpty
static readonly CacheDict< Type, MethodInfo > s_thunks
static void ActionThunk2< T1, T2 >(Func< object[], object > handler, T1 t1, T2 t2)
static MethodInfo[] GetFuncThunks()
static int s_ThunksCreated
static MethodInfo[] GetActionThunks()
static void ActionThunk(Func< object[], object > handler)
static Type ConvertToBoxableType(Type t)
static TReturn FuncThunk1< T1, TReturn >(Func< object[], object > handler, T1 t1)
static Delegate CreateObjectArrayDelegateRefEmit(Type delegateType, Func< object[], object > handler)
static TReturn FuncThunk2< T1, T2, TReturn >(Func< object[], object > handler, T1 t1, T2 t2)
static readonly MethodInfo s_FuncInvoke
static Delegate CreateObjectArrayDelegate(Type delegateType, Func< object[], object > handler)
static void ActionThunk1< T1 >(Func< object[], object > handler, T1 t1)
ILGenerator GetILGenerator()
virtual void EndExceptionBlock()
virtual LocalBuilder DeclareLocal(Type localType)
virtual void BeginFinallyBlock()
virtual void Emit(OpCode opcode)
virtual Label BeginExceptionBlock()
static readonly OpCode Unbox_Any
static readonly OpCode Callvirt
static readonly OpCode Stloc
static readonly OpCode Ldobj
static readonly OpCode Ldc_I4
static readonly OpCode Stelem_Ref
static readonly OpCode Ldelem_Ref
static readonly OpCode Stobj
static readonly OpCode Call
static readonly OpCode Ret
static readonly OpCode Ldloc
static readonly OpCode Box
static readonly OpCode Ldarg_0
static readonly OpCode Newarr
static readonly OpCode Ldarg
virtual MethodInfo MakeGenericMethod(params Type[] typeArguments)
virtual Type ParameterType
override string ToString()
StringBuilder Append(char value, int repeatCount)
static int Increment(ref int location)
static readonly Type[] EmptyTypes
MethodInfo? GetMethod(string name)