Skip to content

Enums are not considered blittable by Emscripten / Blazor WASM AOT #61144

@HurricanKai

Description

@HurricanKai

Description

In P/Invoke callbacks, Enums are not considered blittable.
This means no enums can be used as parameters of P/Invoke callbacks.

Reproduction Steps

Attempt to compile a method like

[UnmanagedCallersOnly]
public static void M(StringComparison myEnum) { }

using Emscripten / WASM AOT

Expected behavior

The above code should be possible. Enums should be considered blittable.

Actual behavior

An error is shown, enums are not considered blittable.

Regression?

No response

Known Workarounds

Use the underlying type of the enum (usually int) instead and manually cast.

Configuration

Tested in .NET 6 RC2

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions