Mono doesn't respect explicit struct size when combined with sequential layout, i.e., when using [StructLayout(LayoutKind.Sequential, Size = X)], the structure doesn't have the desired size X.
Repro code:
using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Size = 12)]
struct F3_S0_S0
{
public nint F0;
public uint F1;
public F3_S0_S0(nint f0, uint f1)
{
F0 = f0;
F1 = f1;
}
}
private static void Main(string[] args)
{
Console.WriteLine(Marshal.SizeOf(typeof(F3_S0_S0)));
}
Mono output:
CoreCLR output: