Skip to content

[browser][coreCLR] implement JS interop#123131

Merged
pavelsavara merged 6 commits intodotnet:mainfrom
pavelsavara:browser_js_interop
Jan 14, 2026
Merged

[browser][coreCLR] implement JS interop#123131
pavelsavara merged 6 commits intodotnet:mainfrom
pavelsavara:browser_js_interop

Conversation

@pavelsavara
Copy link
Member

  • implement JS interop with camelCase names
  • pass JS interop unit tests
  • reverse PInvoke for JS Interop
  • consume SystemInteropJS_* as LibraryImport for CoreCLR and keep Icall for Mono
  • JavaScriptExports as UnmanagedCallersOnly for CoreCLR and keep reflection for Mono
  • BindManagedFunction via reclection on C# side for CoreCLR, keep C API for Mono reflection
  • disable HTTP test until implemented [browser][coreclr] HTTP client #120216
  • more ems prefix for emscripten functions, EmsAmbientSymbolsType rename and move
  • register forceDisposeProxies into exit sequence
  • implement I53 memory operations

Fixes #120703

- consume SystemInteropJS_* as LibraryImport for CoreCLR and keep Icall for Mono
- JavaScriptExports as UnmanagedCallersOnly for CoreCLR and keep reflection for Mono
- BindManagedFunction via reclection on C# side for CoreCLR, keep C API for Mono reflection
- disable HTTP test until implemented dotnet#120216
- more _ems_ prefix for emscripten functions, EmsAmbientSymbolsType rename and move
- register forceDisposeProxies into exit sequence
- implement I53 memory operations
- implement JS interop with camelCase names
- pass JS interop unit tests
@pavelsavara pavelsavara added this to the 11.0.0 milestone Jan 13, 2026
@pavelsavara pavelsavara self-assigned this Jan 13, 2026
@pavelsavara pavelsavara requested a review from lewing as a code owner January 13, 2026 15:30
@pavelsavara pavelsavara added the arch-wasm WebAssembly architecture label Jan 13, 2026
Copilot AI review requested due to automatic review settings January 13, 2026 15:30
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 implements JavaScript interop functionality for CoreCLR on the browser platform with camelCase naming conventions. It introduces significant infrastructure for marshaling data between JavaScript and C#, handling promises/tasks, managing object lifetimes, and providing bidirectional function calls.

Changes:

  • Implements complete JS interop marshaling system with type-safe conversions between JS and C# types
  • Adds CoreCLR-specific implementations separate from Mono using LibraryImport and UnmanagedCallersOnly
  • Implements I53 (53-bit integer) memory operations for safe integer marshaling
  • Establishes reverse PInvoke infrastructure for C++ to call managed JavaScript exports

Reviewed changes

Copilot reviewed 46 out of 48 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/native/rollup.config.plugins.js Suppresses circular dependency warnings for marshal files
src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts Implements SystemInteropJS_* exports for JS interop
src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/*.ts Core marshaling, type definitions, and interop logic
src/native/libs/System.Native.Browser/utils/*.ts Adds I53 operations and updates to use ems ambient symbols
src/native/libs/Common/JavaScript/types/*.ts Type definitions for EmsAmbientSymbolsType and exchanges
src/libraries/System.Runtime.InteropServices.JavaScript/src/*.cs Splits Mono/CoreCLR implementations
src/coreclr/vm/wasm/callhelpers-reverse.cpp Adds reverse PInvoke thunks for JavaScriptExports
src/mono/sample/wasm/browser/* Updates sample to test JSExport functionality

@pavelsavara
Copy link
Member Author

Log

[18:55:07] info: === TEST EXECUTION SUMMARY ===
[18:55:07] info: Tests run: 391 Passed: 389 Inconclusive: 0 Failed: 0 Ignored: 0 Skipped: 2
[18:55:07] info: 
[18:55:07] info: test-main.js exiting WasmTestRunner.dll System.Runtime.InteropServices.JavaScript.Tests.dll after 0.27203333333333335 minutes with result 0 and linear memory 231997440 bytes

Copy link
Member

@maraf maraf left a comment

Choose a reason for hiding this comment

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

Looks great!

pavelsavara and others added 3 commits January 14, 2026 21:19
…stem/Runtime/InteropServices/JavaScript/JSProxyContext.cs

Co-authored-by: Marek Fišera <[email protected]>
safeSetTimeout public
stringToUTF8
fix JSExportByHandle
@pavelsavara pavelsavara enabled auto-merge (squash) January 14, 2026 21:13
@pavelsavara pavelsavara merged commit ccedd75 into dotnet:main Jan 14, 2026
169 checks passed
@pavelsavara pavelsavara deleted the browser_js_interop branch January 14, 2026 23:36
@github-actions github-actions bot locked and limited conversation to collaborators Feb 14, 2026
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][coreclr] make JSImport work on coreclr

3 participants