Moved from sizeof to Marshal.SizeOf.
This prevents unsafe code basically being needed when doing writer.WriteArray.
Unit tests verify that the behavior works fine.