We have some structs where the method bridge generation code was calculating a different size than the runtime code was. So we were getting some missing method bridge errors at runtime when we ran the hot loaded code. The problem was that the structs have FieldOffset attributes and ExplicitLayout, but the code in ValueTypeSizeAligmentCalculator.cs wasn’t accounting for it. The struct’s TypeDef had a null ClassLayout so it never entered the section of code that checks the FieldOffset.
To work around this, I removed the check for (sa != null) so that the size calculation code will check the FieldOffset value even if the ClassLayout is null.
Here are the details asked for in the bug report template:
Unity version: 2021.3.1f1
Operating system: Windows 10
Target: Windows
Version of com.focus-creative-games.hybridclr_unity: 0.9.0
Version of hybridclr and il2cpp_plus: Version that goes with the 0.9.0 package, from about a month ago. However, the code where I found the problem is the same in the latest versions of HybridCLR.
Code location:
com.focus-creative-games.hybridclr_unity\Editor\ABI\ValueTypeSizeAligmentCalculator.cs
SizeAndAligmentOfStruct function
Line 78
Please let me know if I can provide any more information.
We have some structs where the method bridge generation code was calculating a different size than the runtime code was. So we were getting some missing method bridge errors at runtime when we ran the hot loaded code. The problem was that the structs have FieldOffset attributes and ExplicitLayout, but the code in ValueTypeSizeAligmentCalculator.cs wasn’t accounting for it. The struct’s TypeDef had a null ClassLayout so it never entered the section of code that checks the FieldOffset.
To work around this, I removed the check for (sa != null) so that the size calculation code will check the FieldOffset value even if the ClassLayout is null.
Here are the details asked for in the bug report template: Unity version: 2021.3.1f1 Operating system: Windows 10 Target: Windows Version of com.focus-creative-games.hybridclr_unity: 0.9.0 Version of hybridclr and il2cpp_plus: Version that goes with the 0.9.0 package, from about a month ago. However, the code where I found the problem is the same in the latest versions of HybridCLR.
Code location: com.focus-creative-games.hybridclr_unity\Editor\ABI\ValueTypeSizeAligmentCalculator.cs SizeAndAligmentOfStruct function Line 78
Please let me know if I can provide any more information.