public void SimpleCallStringStringIntParam() { Action <Func <object, object[], object> > action = method => { MethodContainer mc = new MethodContainer(); var ret = method(mc, new object[] { "test", 42 }); Assert.False(method.Method.DeclaringType.Is <MethodBase>()); Assert.Equal("test42", ret); Assert.Equal(mc.callCounter, 1); }; var methodInfo = new MethodContainer().Reflection().GetDescriptor(c => c.SimpleCallStringStringIntParam("", 0)) as IMethodDescriptor; action(methodInfo.ToCompiledMethodInvoke()); action(methodInfo.ToCompiledMethodInvoke(false)); }
public void SimpleOverloadedSuperCall() { Action <Func <object, object[], object> > action = method => { MethodContainerParent mc = new MethodContainerParent(); var ret = method(mc, new object[] { 42 }); Assert.False(method.Method.DeclaringType.Is <MethodBase>()); Assert.Equal(ret, 44); Assert.Equal(mc.callCounter, 2); }; var methodInfo = new MethodContainer().Reflection().GetDescriptor(c => c.SimpleVirtualMethod(0)) as IMethodDescriptor; action(methodInfo.ToCompiledMethodInvoke()); action(methodInfo.ToCompiledMethodInvoke(false)); }
public void GenericCallIntIntParam() { Action <Func <object, object[], object> > action = method => { MethodContainer <int> mc = new MethodContainer <int>(); var ret = method(mc, new object[] { 42 }); Assert.False(method.Method.DeclaringType.Is <MethodBase>()); Assert.Equal(ret, 42); Assert.Equal(mc.callCounter, 1); }; var methodInfo = new MethodContainer <int>().Reflection().GetDescriptor(c => c.SimpleCallIntIntParam(0)) as IMethodDescriptor; action(methodInfo.ToCompiledMethodInvoke()); action(methodInfo.ToCompiledMethodInvoke(false)); }
public void SimpleStaticCallIntIntParam() { Action <Func <object, object[], object> > action = method => { int originalCount = MethodContainer.staticCallCounter; var ret = method(null, new object[] { 42 }); Assert.False(method.Method.DeclaringType.Is <MethodBase>()); Assert.Equal(ret, 43); Assert.Equal(originalCount + 1, MethodContainer.staticCallCounter); }; var methodInfo = new MethodContainer().Reflection().GetDescriptor(c => MethodContainer.SimpleStaticCallIntIntParam(0)) as IMethodDescriptor; action(methodInfo.ToCompiledMethodInvoke()); action(methodInfo.ToCompiledMethodInvoke(false)); }
public void SimpleCallRefIntParam() { Action <Func <object, object[], object> > action = method => { MethodContainer mc = new MethodContainer(); var array = new object[] { 21 }; var ret = method(mc, array); Assert.True(method.Method.DeclaringType.Is <MethodBase>()); Assert.Equal(42, ret); Assert.Equal(42, array[0]); Assert.Equal(mc.callCounter, 1); }; int outValue = 0; var methodInfo = new MethodContainer().Reflection().GetDescriptor(c => c.SimpleCallRefIntParam(ref outValue)) as IMethodDescriptor; action(methodInfo.ToCompiledMethodInvoke()); action(methodInfo.ToCompiledMethodInvoke(false)); }