[blazor][wasm] Convert more interop to JSImport#65895
[blazor][wasm] Convert more interop to JSImport#65895pavelsavara merged 5 commits intodotnet:mainfrom
Conversation
- NavigateTo - Refresh
Co-authored-by: campersau <buchholz.bastian@googlemail.com>
- NotifyLocationChangingAsync
This reverts commit 0db89dc.
There was a problem hiding this comment.
Pull request overview
This PR continues the Blazor WebAssembly move away from IJSRuntime-based interop by converting additional navigation and console logging calls to use System.Runtime.InteropServices.JavaScript ([JSImport]) bindings.
Changes:
- Switch
WebAssemblyNavigationManager.NavigateToandRefreshto[JSImport]calls and introduce a new JS entrypoint (navigateToWithArgs) to avoid passingNavigationOptionsas an object. - Update WebAssembly console logging to call
globalThis.console.*via[JSImport], removing the need to flowWebAssemblyJSRuntimeinto the logger/provider. - Update BasicTestApp and host builder wiring to match the new logger/provider constructors.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Components/test/testassets/BasicTestApp/Program.cs | Updates logger provider registration to no longer resolve/pass IJSRuntime. |
| src/Components/test/testassets/BasicTestApp/PrependMessageLoggerProvider.cs | Removes IJSRuntime dependency and uses the updated WebAssemblyConsoleLogger API. |
| src/Components/WebAssembly/WebAssembly/src/Services/WebAssemblyNavigationManager.cs | Converts navigation/refresh interop to [JSImport] and adds a dedicated interop wrapper. |
| src/Components/WebAssembly/WebAssembly/src/Services/WebAssemblyConsoleLoggerProvider.cs | Removes WebAssemblyJSRuntime from provider construction and creates loggers without JS runtime injection. |
| src/Components/WebAssembly/WebAssembly/src/Services/WebAssemblyConsoleLogger.cs | Replaces InvokeVoid("console.*") usage with [JSImport] console bindings. |
| src/Components/WebAssembly/WebAssembly/src/Hosting/WebAssemblyHostBuilder.cs | Updates default logging provider registration to the new constructor. |
| src/Components/Web.JS/src/Services/NavigationManager.ts | Exposes navigateToWithArgs and adds an implementation that matches the new .NET JSImport signature. |
| src/Components/Shared/src/BrowserNavigationManagerInterop.cs | Adds a shared interop constant for the new navigateToWithArgs identifier. |
|
What are we trying to achieve here? There's no related issue and this is introducing a separate path for navigation manager. We don't want to have separate paths for different hosts, and this now introduces two ways of achieving the same thing. The path in server uses a function and the path in wasm uses another. Now we need to be aware of that when we make changes. I'd like to better understand the rationale behind this change, as it only seems to bring drawbacks. If AOT is the concern, the plan is to more broadly pass in serialization context/options that can be source generated and that are compatible. |
@javiercn This is in prep for rendering at distance. Perf as side-effect. There will be more. |
This reverts commit 8bba19e.
Uh oh!
There was an error while loading. Please reload this page.