Closed GoldenretriverYT closed 8 months ago
I feel like this is related to IL2CPU, not Cosmos. For reference, the code dealing with handling different kinds of structures can be found here: https://github.com/CosmosOS/IL2CPU/blob/c8a113f51f7621b598ea8a0469e2ece0730c0a67/source/Cosmos.IL2CPU/ILOp.cs#L267
does it happen when pack is 0?
Thanks for the easily reproducible case, I hope to look into it when I have some time.
I feel like this is related to IL2CPU, not Cosmos. For reference, the code dealing with handling different kinds of structures can be found here: https://github.com/CosmosOS/IL2CPU/blob/c8a113f51f7621b598ea8a0469e2ece0730c0a67/source/Cosmos.IL2CPU/ILOp.cs#L267
mmm looking at this so when pack is 0 we then set it to (int)SizeOfType(typeof(IntPtr)) i think that is 4 but with all the others we just take the value given in this case 1 could it be that we need to just add (int)SizeOfType(typeof(IntPtr)) to pack
Should be fixed by https://github.com/CosmosOS/IL2CPU/pull/215 and https://github.com/CosmosOS/Cosmos/pull/2866
Thank you for giving such an easy reproduction of the issue!
Area of Cosmos - What area of Cosmos are we dealing with?
Unsure
Expected Behaviour - What do you think that should happen?
The assignment should work fine and not corrupt data, as shown by the screenshot without the attribute: This is definitely expected behaviour as this works fine when running that code with the .NET CLR
Actual Behaviour - What unexpectedly happens?
The data gets corrupted when assigning the struct to the class property. This does not happen without the sequential struct layout, not sure if the Pack plays a role.
Reproduction - How did you get this error to appear?
Version - Were you using the User Kit or Dev Kit? And what User Kit version or Dev Kit commit (Cosmos, IL2CPU, X#)?
a78f61d