stuw
✅ Marshal.SizeOf is not what I'm thinking
ChunkDataBackupWrapper.SIZE is one byte smaller than Marshal.SizeOf()
ChunkData: 40430 Marshal.SizeOf, 40430 SIZE
ChunkDataBackupWrapper: 40432 Marshal.SizeOf, 40432 SIZE
I'm trying to read https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.structlayoutattribute.pack?redirectedfrom=MSDN&view=net-7.0 but there's a lot of stuff that I can't wrap my head around.
"The alignment of the type is the size of its largest element (1, 2, 4, 8, etc., bytes) or the specified packing size, whichever is smaller."
"Byte fields align on 1-byte boundaries, Int16 fields align on 2-byte boundaries, and Int32 fields align on 4-byte boundaries."
1. I'm using bytes/bool everywhere, why didn't the second struct align to 1s?
2. Also is "volumeData" considered as an element of size "1" or size "35937"?
3. What's the rules for the size of the struct? I'm not sure I understand
9 replies