+ // Size should be 16 in both 32 and 64 bits win/linux
+ // Size should be 12 on 32bits OSX size alignment of long is 4
+ [StructLayout (LayoutKind.Explicit)]
+ struct TestStruct8 {
+ [FieldOffset (0)]
+ public int a;
+ [FieldOffset (4)]
+ public ulong b;
+ }
+
+ // Size should be 12 in both 32 and 64 bits
+ [StructLayout (LayoutKind.Explicit, Size=12)]
+ struct TestStruct9 {
+ [FieldOffset (0)]
+ public int a;
+ [FieldOffset (4)]
+ public ulong b;
+ }
+
+ // Size should be 16 in both 32 and 64 bits
+ // Size should be 12 on 32bits OSX size alignment of long is 4
+ [StructLayout (LayoutKind.Explicit)]
+ struct TestStruct10 {
+ [FieldOffset (0)]
+ public int a;
+ [FieldOffset (3)]
+ public ulong b;
+ }
+
+ // Size should be 11 in both 32 and 64 bits
+ [StructLayout (LayoutKind.Explicit, Size=11)]
+ struct TestStruct11 {
+ [FieldOffset (0)]
+ public int a;
+ [FieldOffset (3)]
+ public ulong b;
+ }
+
+ [StructLayout (LayoutKind.Explicit, Pack=1)]
+ struct TestStruct12 {
+ [FieldOffset (0)]
+ public short a;
+ [FieldOffset (2)]
+ public int b;
+ }
+
+ // Size should always be 12, since pack = 0, size = 0 and min alignment = 4
+ //When pack is not set, we default to 8, so min (8, min alignment) -> 4
+ [StructLayout (LayoutKind.Explicit)]
+ struct TestStruct13 {
+ [FieldOffset(0)]
+ int one;
+ [FieldOffset(4)]
+ int two;
+ [FieldOffset(8)]
+ int three;
+ }
+
+ // Size should always be 12, since pack = 8, size = 0 and min alignment = 4
+ //It's aligned to min (pack, min alignment) -> 4
+ [StructLayout (LayoutKind.Explicit)]
+ struct TestStruct14 {
+ [FieldOffset(0)]
+ int one;
+ [FieldOffset(4)]
+ int two;
+ [FieldOffset(8)]
+ int three;
+ }
+ static bool IsOSX ()
+ {
+ return (int)typeof (Environment).GetMethod ("get_Platform", BindingFlags.Static | BindingFlags.NonPublic).Invoke (null, null) == 6;
+ }
+