-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Field offset not being set when offset is 0 on explicit layout types. #105795
Comments
Tagging subscribers to this area: @dotnet/area-system-reflection |
Tagging subscribers to this area: @dotnet/area-system-reflection-emit |
Thank you for reporting this @TrueLunacy! Looks you found the root cause, would you like to offer a fix (with a test repro) |
PersistedAssemblyBuilder didn't write field offset correctly when field offset was 0. This fixes that, and adds a test to ensure the behaviour is working. Fixes dotnet#105795
I've made a pull request with the change and a test for it, but I'm not 100% if that's enough or I've done it right. Hopefully I have! |
Description
Field offsets aren't being set in the IL for types with an offset of zero. This causes the types to fail to load at runtime.
The cause, as far as I can tell, seems to be from lines 641 in the WriteFields function in ModuleBuilderImpl.cs
Reproduction Steps
Expected behavior
Type loads, program prints 15.
Actual behavior
Regression?
No response
Known Workarounds
No response
Configuration
Arch Linux x64, dotnet 9.0.100-rc.1.24381.3
Other information
No response
The text was updated successfully, but these errors were encountered: