dotnet/pinvoke#463 (comment)
Marshal.SizeOf returns the size of the unmanaged view of the struct. sizeof returns the size of the managed view of the struct.
Unmanaged and managed views are identical for the blittable structs. It is better to use sizeof instead of Marshal.SizeOf for blittable structs. They return the same number and sizeof is much cheaper.
There are many uses of Marshal.SizeOf in the codebase - many of them likely for blittable types - that could be identified and updated to use faster sizeof.
/cc @dotnet/dotnet-winforms - This probably applies to Winforms as well.
dotnet/pinvoke#463 (comment)
There are many uses of
Marshal.SizeOfin the codebase - many of them likely for blittable types - that could be identified and updated to use fastersizeof./cc @dotnet/dotnet-winforms - This probably applies to Winforms as well.