You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running Type.TypeInitializer.Invoke() does not run the type initializer under net7, where it was under net6.
Reproduction Steps
Considering this code:
Console.WriteLine($"Before Test TypeInitializer");typeof(Test).TypeInitializer.Invoke(null,null);Console.WriteLine($"After Test TypeInitializer");publicstaticclassTest{staticTest(){Console.WriteLine("Test: Type Initializer");}}
Expected behavior
net6 shows this:
Before Test TypeInitializer
Test: Type Initializer
After Test TypeInitializer
Actual behavior
net7 shows this:
Before Test TypeInitializer
After Test TypeInitializer
Regression?
Yes
Known Workarounds
Use System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor instead.
Description
Running
Type.TypeInitializer.Invoke()does not run the type initializer under net7, where it was under net6.Reproduction Steps
Considering this code:
Expected behavior
net6 shows this:
Actual behavior
net7 shows this:
Regression?
Yes
Known Workarounds
Use
System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructorinstead.Configuration
net7 build: 58fa90b
Other information
I have not tested on the desktop runtime yet.