public void GetCallbackPtrReturnsPointerToShadow() { using (var callback = new CallbackImpl()) { Assert.NotEqual(IntPtr.Zero, CppObject.ToCallbackPtr <ICallback>(callback)); } }
public void CanRoundTripCallThroughNativeVtblToManagedObject() { using (var callback = new CallbackImpl()) { var callbackPtr = CppObject.ToCallbackPtr <ICallback>(callback); var methodPtr = Marshal.ReadIntPtr(Marshal.ReadIntPtr(callbackPtr)); var delegateObject = Marshal.GetDelegateForFunctionPointer <CallbackShadow.CallbackVbtl.IncrementDelegate>(methodPtr); Assert.Equal(3, delegateObject(callbackPtr, 2)); } }