-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
PseudoCustomAttribute.GetStructLayoutCustomAttribute currently returns incorrect values for various types. See the implementation here: https://github.com/dotnet/coreclr/blob/72d49127a0c25e4b931c81e621c2411bfb6633a5/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs#L2058-L2096
Namely, for the packing it currently changes 0 to 8; but it doesn't take into account any changes that the VM may have made for a given types data.
I would expect that this API either return the exact values in metadata or it should return the correct values computed by the VM at runtime.
An example of where this is problematic is for types like float it reports 8, when the actual packing is 4. Likewise, for Vector128<>, the packing of 16 is preserved by the VM. Vector<T> is another case where it currently reports Pack = 8, but Size = 0.