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
{{ message }}
Repository navigation
[net7][Wasm] Type.TypeInitializer.Invoke() does not run the type initializer #69516
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.
Activity
dakersnar commentedon Aug 8, 2022
@jkotas We think this might be VM related, can you take a look?
jkotas commentedon Aug 8, 2022
cc @steveharter
steveharter commentedon Aug 10, 2022
cc @BrzVlad
SamMonoRT commentedon Aug 12, 2022
cc @BrzVlad @lambdageek -- marking this a blocking-release, considering its a regression. Assigning to @BrzVlad for tracking.
jkotas commentedon Aug 12, 2022
It is this TODO:
runtime/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.Mono.cs
Lines 805 to 809 in 51df356
Related to #40351