Skip to content

[wasm] Use lightweight marshal for enums - #118991

Merged
lewing merged 11 commits into
dotnet:mainfrom
maraf:MonoInteropEnum
Sep 3, 2025
Merged

[wasm] Use lightweight marshal for enums#118991
lewing merged 11 commits into
dotnet:mainfrom
maraf:MonoInteropEnum

Conversation

@maraf

@marafmaraf commented Aug 22, 2025

Copy link
Copy Markdown
Member

Based on MinimalMarshalingTypeCompatibilityProvider.cs we mark enums as marshallable by lightweight marshaller on build.
We were missing enums when checking for supported types in marshal-ilgen-stub.c on runtime.

Fixes#115780
Contributes to #94187

@marafmaraf added this to the 11.0.0 milestone Aug 22, 2025
@marafmaraf self-assigned this Aug 22, 2025
@marafmaraf added arch-wasm WebAssembly architecture area-Interop-mono labels Aug 22, 2025
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Comment threadsrc/mono/mono/component/marshal-ilgen-stub.c Outdated
@maraf
maraf marked this pull request as ready for review September 2, 2025 12:30
CopilotAI review requested due to automatic review settings September 2, 2025 12:30

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enables lightweight marshalling for enum types in WebAssembly builds. The fix addresses a runtime marshalling issue where enums were not being recognized as supported types by the lightweight marshaller, even though they were marked as marshallable during the build process.

Key changes:

  • Updated runtime marshalling logic to recognize enums as lightweight-marshallable types
  • Added test coverage for enum marshalling through ZipArchive interop functionality

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

FileDescription
src/mono/mono/component/marshal-ilgen-stub.cAdded enum type check to allow lightweight marshalling for enums
src/mono/wasm/testassets/WasmBasicTestApp/App/ZipArchiveInteropTest.csAdded test class that exercises enum marshalling through ZipArchive operations
src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/main.jsAdded test case entry point for ZipArchiveInteropTest
src/mono/wasm/Wasm.Build.Tests/NativeBuildTests.csAdded test method to verify ZipArchive enum marshalling functionality

Comment threadsrc/mono/wasm/testassets/WasmBasicTestApp/App/ZipArchiveInteropTest.cs Outdated
@maraf
maraf requested a review from kgSeptember 2, 2025 12:33
…pTest.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@lewing
lewing enabled auto-merge (squash) September 2, 2025 23:26
Comment threadsrc/mono/mono/component/marshal-ilgen-stub.c
@lewing
lewing merged commit 20a932e into dotnet:mainSep 3, 2025
70 checks passed
@maraf

maraf commented Sep 3, 2025

Copy link
Copy Markdown
MemberAuthor

/backport to release/10.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/10.0: https://github.com/dotnet/runtime/actions/runs/17425549273

@maraf
maraf deleted the MonoInteropEnum branch September 3, 2025 06:55
filipnavara pushed a commit to filipnavara/runtime that referenced this pull request Sep 5, 2025
* Use lightweight marshal for enums
* Wasm build test
* Fix
* Fix test app build
* Fix test app build
* Fix test asserts
* Fix test case
* Build tests are not JS bundler friendly
* Update src/mono/mono/component/marshal-ilgen-stub.c
Co-authored-by: Larry Ewing <lewing@microsoft.com>
* Update src/mono/wasm/testassets/WasmBasicTestApp/App/ZipArchiveInteropTest.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---------
Co-authored-by: Larry Ewing <lewing@microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Oct 3, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Interop-mono

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blazor WebAssembly - ZipArchiveEntry.Open causes unexpected termination at runtime in published app on .NET 10 Preview 3 and 4

4 participants

@maraf@lewing@pavelsavara