public void CouldWriteBlittableStruct1() { var ptr = Marshal.AllocHGlobal(1024); var dest = new DirectBuffer(1024, ptr); var myBlittableStruct1 = new BlittableStruct1 { Value1 = 12345 }; TypeHelper <BlittableStruct1> .Write(myBlittableStruct1, ref dest); var newBlittableStruct1 = default(BlittableStruct1); TypeHelper <BlittableStruct1> .Read(ptr, ref newBlittableStruct1); Assert.AreEqual(myBlittableStruct1.Value1, newBlittableStruct1.Value1); }
public unsafe void CouldWriteBlittableStruct1() { var dest = (OwnedBuffer <byte>) new byte[1024]; var buffer = dest.Buffer; var myBlittableStruct1 = new BlittableStruct1 { Value1 = 12345 }; TypeHelper <BlittableStruct1> .Write(myBlittableStruct1, ref buffer); var handle = buffer.Pin(); TypeHelper <BlittableStruct1> .Read((IntPtr)handle.PinnedPointer, out var newBlittableStruct1); Assert.AreEqual(myBlittableStruct1.Value1, newBlittableStruct1.Value1); }