Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[net7][Wasm] Type.TypeInitializer.Invoke() does not run the type initializer #69516

Copy link
Copy link

Description

@jeromelaban
Issue body actions

Description

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");

public static class Test
{
    static Test()
    {
        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.

Configuration

net7 build: 58fa90b

Other information

I have not tested on the desktop runtime yet.

Reactions are currently unavailable

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

Morty Proxy This is a proxified and sanitized view of the page, visit original site.