Closed justinstenning closed 8 years ago
The following field will not work correctly in FastStructure:
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8, ArraySubType = UnmanagedType.U1)] public byte[] Contents;
Instead it needs to be in a LayoutKind.Explicit struct with a fixed byte array, e.g.
[FieldOffset(48)] public fixed byte Contents[8];
However this will then not work correctly with Marshal.PtrToStructure either. Instead only the first byte will be copied into the structure.
Need to either implement checks in FastStructure static constructor so that users of the library are notified of issues ASAP, or find a work around.
Testing shows that it can be in a LayoutKind.Sequential without the FieldOffset
Implemented
The following field will not work correctly in FastStructure:
Instead it needs to be in a LayoutKind.Explicit struct with a fixed byte array, e.g.
However this will then not work correctly with Marshal.PtrToStructure either. Instead only the first byte will be copied into the structure.
Need to either implement checks in FastStructure static constructor so that users of the library are notified of issues ASAP, or find a work around.