Skip to content

Conversation

@pavelsavara
Copy link
Member

  • remove DLL suffix for GetAssemblyExport
  • don't stackRestore on aborted runtime
  • add lazy WBT

Fixes #117780

@pavelsavara
Copy link
Member Author

expected BTW output

[debug] MONO_WASM: Binding [JSExport] .SatelliteAssembliesTest:Run from WasmBasicTestApp assembly
[debug] MONO_WASM: Attempting to download 'http://127.0.0.1:56058/_framework/Json.8lyzvxjbal.wasm' for Json.8lyzvxjbal.wasm
[debug] MONO_WASM: Attempting to download 'http://127.0.0.1:56058/_framework/Json.02sl3e3dwj.pdb' for Json.02sl3e3dwj.pdb
[log] TestOutput -> {"FirstName":"John","LastName":"Doe"}
[debug] MONO_WASM: Attempting to download 'http://127.0.0.1:56058/_framework/LazyLibrary.atba1goc0h.wasm' for LazyLibrary.atba1goc0h.wasm
[debug] MONO_WASM: Attempting to download 'http://127.0.0.1:56058/_framework/LazyLibrary.0oyotd78vm.pdb' for LazyLibrary.0oyotd78vm.pdb
[debug] MONO_WASM: Binding [JSExport] LazyLibrary.Foo:Bar from LazyLibrary assembly
[log] Hello from Foo.Bar!
Exited with 0
[info] WASM EXIT 0

@pavelsavara
Copy link
Member Author

\Microsoft.NET.Sdk.WebAssembly.Browser.targets(803,5): error BLAZORSDK1001: Unable to find 'Json.dll;LazyLibrary.dll' to be lazy

@maraf hints ?

@maraf
Copy link
Member

maraf commented Jul 25, 2025

My first guess would be that the assembly was trimmed away. Binlog would help to validate it

EDIT: But a) that should not happen if there is JSExport b) it shouldn't scream with both assemblies

@pavelsavara pavelsavara marked this pull request as ready for review July 25, 2025 14:58
@Copilot Copilot AI review requested due to automatic review settings July 25, 2025 14:58
Copy link
Contributor

Copilot AI left a comment

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 fixes JSExport functionality in lazy loaded assemblies by addressing several critical issues: removing the DLL suffix when calling GetAssemblyExport, preventing stack restoration when the runtime is not running, and adding comprehensive test coverage.

Key Changes:

  • Fixed GetAssemblyExport to use assembly name without ".dll" suffix
  • Added runtime state checks before calling Module.stackRestore to prevent crashes
  • Added new test infrastructure for lazy loading JSExport functionality

Reviewed Changes

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

Show a summary per file
File Description
JSHostImplementation.cs Removes ".dll" suffix from assembly name passed to GetAssemblyExport
memory.ts Adds runtime state check before stack restoration in withStackAlloc
managed-exports.ts Adds runtime state checks before all Module.stackRestore calls
invoke-cs.ts Adds runtime state checks before Module.stackRestore in binding functions
GenerateWasmBootJson.cs Fixes variable reference in error message generation
LazyLibrary/* New test library with JSExport functionality for lazy loading tests
main.js Adds test case for JSExport in lazy loaded assembly
WasmBasicTestApp.csproj Adds LazyLibrary reference and lazy load configuration
LazyLoadingTest.cs Adds DynamicDependency attribute for lazy loaded assembly

@pavelsavara pavelsavara merged commit 5922fd3 into dotnet:main Jul 28, 2025
32 of 34 checks passed
@pavelsavara pavelsavara deleted the lazy_jsexport branch July 28, 2025 09:07
@github-actions github-actions bot locked and limited conversation to collaborators Aug 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript os-browser Browser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[browser] JSExport in lazy loaded assembly

2 participants