Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[browser][coreCLR] running main/exit/abort/logging and infra for unit testing#122646

Merged
pavelsavara merged 14 commits intodotnet:mainfrom
pavelsavara:browser_diag
Dec 30, 2025
Merged

[browser][coreCLR] running main/exit/abort/logging and infra for unit testing#122646
pavelsavara merged 14 commits intodotnet:mainfrom
pavelsavara:browser_diag

Conversation

@pavelsavara
Copy link
Member

@pavelsavarapavelsavara commentedDec 18, 2025
edited
Loading

  • Addeddotnet.runMainAndExit() anddotnet.runMain() APIs. For Mono too.
  • makedotnet.run() to not callexit() and keep runtime alive, only for CoreCLR
    • This will be breaking change for CoreCLR vs Mono.
    • Because previous behavior was just confusing everyone.
    • Make it deprecated and point torunMain()
  • new internal MSbuild property<WasmTestSupport>true</WasmTestSupport> which deploysdotnet.diagnostics.js
  • loaddotnet.diagnostics.js early when available in the boot config
  • add internal support for unit testing viadotnet.diagnostics.js
    • skeleton ofsymbolicateStackTrace
    • exitOnUnhandledError
    • appendElementOnExit
    • logExitCode
    • asyncFlushOnExit
    • forwardConsole
  • new internal MSbuild propertiesWasmTestExitOnUnhandledError,WasmTestAppendElementOnExit,WasmTestLogExitCode,WasmTestAsyncFlushOnExit,WasmTestForwardConsole
  • setWasmTestSupport for library tests and WBT
  • set-sEXIT_RUNTIME=1 - this enables C++ global destructors
  • implementedabortStartup(),abortTimers(),abortPosix()
  • implementedisExited(),isRuntimeRunning()
  • invokeLoadBootResourceCallback for Blazor
  • invokeModule.onConfigLoaded andModule.onDotnetReady
  • capturesExitStatus type
  • capture posix/emscriptenabort()/exit() events
  • fixedlocateFile - for query string propagation
  • hidesBrowserHost_InitializeCoreCLR,BrowserHost_ExecuteAssembly from Module exports
  • reporting not found assemblies to debug log

Fixes#101169
Fixes#75335
On top of#122616
On top of#122495

@pavelsavarapavelsavara added this to the11.0.0 milestoneDec 18, 2025
@pavelsavarapavelsavara self-assigned thisDec 18, 2025
@pavelsavarapavelsavara added arch-wasmWebAssembly architecture area-Host os-browserBrowser variant of arch-wasm labelsDec 18, 2025
@pavelsavarapavelsavaraforce-pushed thebrowser_diag branch 3 times, most recently from6b91c6a to3a18853CompareDecember 19, 2025 21:03
@pavelsavarapavelsavara marked this pull request as ready for reviewDecember 22, 2025 12:21
CopilotAI review requested due to automatic review settingsDecember 22, 2025 12:21
Copy link
Contributor

CopilotAI 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 adds comprehensive exit/abort/logging infrastructure for unit testing in browser/CoreCLR environments, enabling better diagnostics and test harness integration.

Key Changes:

  • Introduces new test instrumentation viadotnet.diagnostics.js module with exit handlers, console forwarding, and symbolication skeleton
  • Breaking API change:dotnet.run() now keeps the runtime alive; newdotnet.runAndExit() method exits runtime after Main() completes
  • Adds internal MSBuild properties (WasmTestSupport,WasmTestExitOnUnhandledError, etc.) to control test behavior and diagnostics deployment

Reviewed changes

Copilot reviewed 37 out of 38 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/GenerateWasmBootJson.csAdds five new boolean properties for test instrumentation flags, gated by version 11.0+
src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/BootJsonData.csDefines the five new test instrumentation properties in boot config JSON schema
src/native/libs/System.Native.Browser/utils/index.tsReplacesexit export withabortTimers andabortPosix for better separation of concerns
src/native/libs/System.Native.Browser/utils/host.tsRemoves oldexit() function, addsabortTimers() andabortPosix() for cleanup
src/native/libs/System.Native.Browser/native/cross-linked.tsDeclares globalABORT andEXITSTATUS variables for emscripten integration
src/native/libs/System.Native.Browser/diagnostics/types.tsNew file defining types for marshaling, diagnostics exports, and measured blocks
src/native/libs/System.Native.Browser/diagnostics/symbolicate.tsSkeleton implementation of stack trace symbolication (placeholder for future work)
src/native/libs/System.Native.Browser/diagnostics/per-module.tsRe-exports common per-module definitions for diagnostics
src/native/libs/System.Native.Browser/diagnostics/index.tsMain entry point for diagnostics module initialization
src/native/libs/System.Native.Browser/diagnostics/exit.tsImplements exit handlers, unhandled error handlers, and exit code logging
src/native/libs/System.Native.Browser/diagnostics/cross-module.tsRe-exports common cross-module definitions for diagnostics
src/native/libs/System.Native.Browser/diagnostics/console-proxy.tsImplements console forwarding to WebSocket for test runners
src/native/libs/Common/JavaScript/types/public-api.tsUpdates API: removeswithConfigSrc() docs, addsrun() andrunAndExit() with clear behavior distinction
src/native/libs/Common/JavaScript/types/internal.tsAddsDiagnosticsExportsTable to internal exchange, updates asset entry fields, addsOnExitListener type
src/native/libs/Common/JavaScript/types/exchange.tsAdds diagnostics exports, exit lifecycle functions, and additional browser host exports
src/native/libs/Common/JavaScript/cross-module/index.tsIntegrates diagnostics exports into cross-module exchange system
src/native/libs/Common/JavaScript/CMakeLists.txtAdds new diagnostics TypeScript source files to build
src/native/corehost/browserhost/loader/run.tsMajor refactoring: moves runtime creation logic here, addscreateRuntime() andabortStartup(), improvedinitializeCoreCLR()
src/native/corehost/browserhost/loader/lib-initializers.tsAdds comment clarifying expected function names
src/native/corehost/browserhost/loader/index.tsRegisters exit handlers, adds exit-related exports, changes defaultruntimeId to undefined
src/native/corehost/browserhost/loader/host-builder.tsImplements newrun() (keeps runtime alive) andrunAndExit() methods, exportsloadBootResourceCallback
src/native/corehost/browserhost/loader/exit.tsComplete rewrite withruntimeState, exit listeners, Emscripten integration, proper exit/abort handling
src/native/corehost/browserhost/loader/dotnet.d.tsUpdates type definitions forrun() andrunAndExit() methods, removeswithConfigSrc()
src/native/corehost/browserhost/loader/config.tsRenamesnetLoaderConfig toloaderConfig for consistency
src/native/corehost/browserhost/loader/bootstrap.tsFixeslocateFile() to properly handle query strings for modules vs. assets
src/native/corehost/browserhost/loader/assets.tsMoves runtime creation to run.ts, implements BlazorloadBootResourceCallback support, adds proper cache/integrity handling
src/native/corehost/browserhost/libBrowserHost.footer.jsHidesBrowserHost_InitializeCoreCLR andBrowserHost_ExecuteAssembly from Module exports
src/native/corehost/browserhost/host/index.tsExportsgetExitStatus andinitializeCoreCLR functions
src/native/corehost/browserhost/host/host.tsImplementsgetExitStatus(),initializeCoreCLR(), improves assembly probing with debug logging, refactorsrunMain() andrunMainAndExit() error handling
src/native/corehost/browserhost/host/cross-linked.tsDeclares_BrowserHost_InitializeCoreCLR,_BrowserHost_ExecuteAssembly, andExitStatus globals
src/native/corehost/browserhost/CMakeLists.txtRemoves specific functions from exported list, relying on generic export configuration
src/mono/wasm/testassets/WasmBrowserRunMainOnly/wwwroot/main.jsSimplifies to singlerunAndExit() call instead of manual error handling
src/mono/wasm/testassets/WasmBrowserRunMainOnly/WasmBrowserRunMainOnly.csprojEnables all test instrumentation flags
src/mono/wasm/Wasm.Build.Tests/Common/BuildEnvironment.csEnablesWasmTestSupport for CoreCLR builds
src/mono/sample/wasm/Directory.Build.targetsAdds test support properties to nested build
src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targetsWires up test instrumentation properties to boot config generation, conditionally includes diagnostics module
src/mono/browser/test-main.jsChanges defaultforwardConsole to only enable on Firefox (not for other browsers in debug mode)
eng/testing/tests.browser.targetsEnablesWasmTestSupport for CoreCLR library tests

@pavelsavarapavelsavara changed the title[browser][coreCLR] exit/abort/logging infra for unit testing[browser][coreCLR] running main/exit/abort/logging and infra for unit testingDec 23, 2025
Copy link
Member

@javiercnjaviercn left a comment

Choose a reason for hiding this comment

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

Looks good to me. Is it fair to assume that most of the testing is essentially existing tests continue to pass?

@pavelsavara
Copy link
MemberAuthor

/ba-g unrelated failures

@pavelsavarapavelsavara merged commit3cacfdd intodotnet:mainDec 30, 2025
161 of 164 checks passed
@pavelsavarapavelsavara deleted the browser_diag branchDecember 30, 2025 21:19
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJan 30, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

Copilot code reviewCopilotCopilot left review comments

@javiercnjaviercnjaviercn approved these changes

@marafmarafAwaiting requested review from marafmaraf is a code owner

@ilonatommyilonatommyAwaiting requested review from ilonatommyilonatommy is a code owner

@lewinglewingAwaiting requested review from lewinglewing is a code owner

@akoeplingerakoeplingerAwaiting requested review from akoeplingerakoeplinger is a code owner

Assignees

@pavelsavarapavelsavara

Labels

arch-wasmWebAssembly architecturearea-Hostos-browserBrowser variant of arch-wasm

Projects

None yet

Milestone

11.0.0

Development

Successfully merging this pull request may close these issues.

[browser] move console proxy from runtime code into test-main [wasm] Better communication between apphost and browser

2 participants

@pavelsavara@javiercn

[8]ページ先頭

©2009-2026 Movatter.jp