Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
HurricanKai opened this issue Nov 3, 2021 · 4 comments · Fixed by #61377
Closed

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

HurricanKai opened this issue Nov 3, 2021 · 4 comments · Fixed by #61377
Assignees
Labels
arch-wasm WebAssembly architecture area-Interop-mono

Comments

@HurricanKai
Copy link
Member

HurricanKai commented Nov 3, 2021

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

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Nov 3, 2021
@SingleAccretion SingleAccretion added arch-wasm WebAssembly architecture area-Interop-mono labels Nov 3, 2021
@ghost
Copy link

ghost commented Nov 3, 2021

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

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

Author: HurricanKai
Assignees: -
Labels:

arch-wasm, untriaged, area-Interop-mono

Milestone: -

@lambdageek
Copy link
Member

related to #61146

@lewing lewing removed the untriaged New issue has not been triaged by the area owner label Nov 3, 2021
mattleibow added a commit to mono/SkiaSharp that referenced this issue Nov 9, 2021
vargaz added a commit to vargaz/runtime that referenced this issue Nov 9, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Nov 9, 2021
@lambdageek
Copy link
Member

I think the code in the runtime handles this. There just needs to be an IsEnum check in the pinvoke table generator.

lewing pushed a commit that referenced this issue Nov 10, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Nov 10, 2021
github-actions bot pushed a commit that referenced this issue Nov 10, 2021
Anipik pushed a commit that referenced this issue Nov 12, 2021
Fixes #61144.

Co-authored-by: Zoltan Varga <vargaz@gmail.com>
@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-Interop-mono
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants