public void MethodDelegateParameter_SystemPointer(int value) { var obj = new PointerHolder(); MethodDelegateWithSystemPointer d = obj.MethodWithSystemPointer; d.DynamicInvoke(Pointer.Box(unchecked ((void *)value), typeof(byte *)), value); }
public void PointerMethodDelegateParameter_InvalidType_SystemPointer(int value) { // Although the type boxed doesn't match, when unboxing void* is returned. var obj = new PointerHolder(); MethodDelegateWithSystemPointer d = obj.MethodWithSystemPointer; d.DynamicInvoke(Pointer.Box(unchecked ((void *)value), typeof(long *)), value); }
public void IntPtrMethodDelegateParameter_InvalidType_SystemPointer(int value) { // An IntPtr is not converted to a System.Pointer. var obj = new PointerHolder(); MethodDelegateWithSystemPointer d = obj.MethodWithSystemPointer; AssertExtensions.Throws <ArgumentException>(null, () => { d.DynamicInvoke((IntPtr)value, value); }); }
public void PointerNullMethodDelegateParameter_InvalidType_SystemPointer() { // An null is not converted to a System.Pointer. var obj = new PointerHolder(); MethodDelegateWithSystemPointer d = obj.MethodWithSystemPointer; try { d.DynamicInvoke(null, 0); } catch (TargetInvocationException e) when(e.InnerException is ArgumentException) { return; } Assert.Fail("Inner exception should be ArgumentException."); }