public static unsafe void Main() { // The nulls should be first to test for "Value does not fall within the expected range." exception of .BaseType MyClass nullMyClass = null; object nullObject = null; string nullString = null; object obj = new Object(); int loc = 42; int locByRef = 43; int* locPtr = &loc; int* locPtrByRef = &loc; int** locPtrPtr = &locPtr; void* locVoidPtr = &loc; object locObj = new object(); object locObjByRef = new object(); char[] locSZArray = "Test".ToCharArray(); char[,] locArray = new char[2,2]; Point locStruct; Point* locStructPtr = &locStruct; object box = 40; MyInterfaceImpl myInterfaceImpl = new MyInterfaceImpl(); MyInterface myInterface = myInterfaceImpl; System.Diagnostics.Debugger.Break(); Fun(loc, ref locByRef, locPtr, ref locPtrByRef, locPtrPtr, locVoidPtr, locObj, ref locObjByRef, locSZArray, locArray, locStruct, ref locStruct, locStructPtr, box, ref box); }
public void MixinForInterfaces() { ProxyGenerationOptions proxyGenerationOptions = new ProxyGenerationOptions(); SimpleMixin mixin_instance = new SimpleMixin(); proxyGenerationOptions.AddMixinInstance(mixin_instance); AssertInvocationInterceptor interceptor = new AssertInvocationInterceptor(); MyInterfaceImpl target = new MyInterfaceImpl(); object proxy = generator.CreateInterfaceProxyWithTarget( typeof(IMyInterface), target, proxyGenerationOptions, interceptor); Assert.IsNotNull(proxy); Assert.IsTrue(typeof(IMyInterface).IsAssignableFrom(proxy.GetType())); Assert.IsFalse(interceptor.Invoked); ISimpleMixin mixin = proxy as ISimpleMixin; Assert.IsNotNull(mixin); Assert.AreEqual(1, mixin.DoSomething()); Assert.IsTrue(interceptor.Invoked); Assert.AreSame(proxy, interceptor.proxy); Assert.AreSame(mixin_instance, interceptor.mixin); }
public void MixinForInterfaces() { GeneratorContext context = new GeneratorContext(); SimpleMixin mixin_instance = new SimpleMixin(); context.AddMixinInstance(mixin_instance); AssertInvocationInterceptor interceptor = new AssertInvocationInterceptor(); MyInterfaceImpl target = new MyInterfaceImpl(); object proxy = _generator.CreateCustomProxy( typeof(IMyInterface), interceptor, target, context); Assert.IsNotNull(proxy); Assert.IsTrue(typeof(IMyInterface).IsAssignableFrom(proxy.GetType())); Assert.IsFalse(interceptor.Invoked); ISimpleMixin mixin = proxy as ISimpleMixin; Assert.IsNotNull(mixin); Assert.AreEqual(1, mixin.DoSomething()); Assert.IsTrue(interceptor.Invoked); Assert.AreSame(proxy, interceptor.proxy); Assert.AreSame(mixin_instance, interceptor.mixin); }
public void testGenericConstraint1() { var impl = new MyInterfaceImpl(); TestGenericConstraint1Helper(ref impl); }