Description
When Assembly2's [ModuleInitializer] uses UnsafeAccessor to set a private variable in Assembly3, the changes are not observed. This only seems to happen when ReadyToRun is enabled.
Reproduction Steps
Run the code below in VS. It will correctly show:
IsSet: True
Then, publish it using the included publishing profile. When you run it, it will INCORRECTLY show:
IsSet: False
StaticTests.zip
Expected behavior
When published with ReadyToRun, it should show:
IsSet: True
Actual behavior
When published with ReadyToRun, it incorrectly shows:
IsSet: False
Regression?
I tested this in .NET 10 and observed the same problem.
Known Workarounds
It seems like refactoring the code so that things aren't called from within the module initializer seem to work.
Configuration
.NET 11 RC1. x64.
ReadyToRun
Other information
No response
Description
When Assembly2's
[ModuleInitializer]usesUnsafeAccessorto set a private variable in Assembly3, the changes are not observed. This only seems to happen when ReadyToRun is enabled.Reproduction Steps
Run the code below in VS. It will correctly show:
IsSet: TrueThen, publish it using the included publishing profile. When you run it, it will INCORRECTLY show:
IsSet: FalseStaticTests.zip
Expected behavior
When published with ReadyToRun, it should show:
IsSet: TrueActual behavior
When published with ReadyToRun, it incorrectly shows:
IsSet: FalseRegression?
I tested this in .NET 10 and observed the same problem.
Known Workarounds
It seems like refactoring the code so that things aren't called from within the module initializer seem to work.
Configuration
.NET 11 RC1. x64.
ReadyToRun
Other information
No response