public void ToFuncWithTwoTypeParameter() { DynamicMethod method = new DynamicMethod(Guid.NewGuid().ToString(), typeof(int), new Type[] { typeof(int) }); var il = method.GetILGenerator(); il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ret); var func = DynamicMethodExtensions.ToFunc <int, int>(method); Assert.AreEqual(5, func(5)); }
public void ToFuncWithOneTypeParameter() { DynamicMethod method = new DynamicMethod(Guid.NewGuid().ToString(), typeof(int), null); var il = method.GetILGenerator(); il.Emit(OpCodes.Ldc_I4_1); il.Emit(OpCodes.Ret); var func = DynamicMethodExtensions.ToFunc <int>(method); Assert.AreEqual(1, func()); }