Skip to content

Flow mapped assemblies to the Router - #68471

Open
PureWeen with Copilot wants to merge 7 commits into
mainfrom
copilot/update-router-default-assembly
Open

Flow mapped assemblies to the Router#68471
PureWeen with Copilot wants to merge 7 commits into
mainfrom
copilot/update-router-default-assembly

Conversation

Copilot AI commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Flow mapped assemblies to the Router

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Flow mapped assemblies to the Router

Description

Router required applications to duplicate assembly configuration already supplied to MapRazorComponents. This change flows that configuration through persistent component state.

  • Endpoint configuration

    • Captures the root and additional mapped assemblies as endpoint metadata.
    • Persists their names for interactive Server, WebAssembly, and Auto render modes.
  • Router behavior

    • Uses mapped assemblies when AppAssembly or AdditionalAssemblies are omitted.
    • Preserves explicitly supplied parameters.
    • Retains existing requirements for standalone and classic hosted WebAssembly applications.
  • Templates

    • Simplifies mapped Blazor Web Apps to:
<Router NotFoundPage="typeof(Pages.NotFound)">
    ...
</Router>

Copilot AI and others added 3 commits August 13, 2026 09:00
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
Copilot AI changed the title [WIP] Update router to default to current executing assembly Flow mapped assemblies to the Router Aug 13, 2026
Copilot AI requested a review from PureWeen August 13, 2026 09:21
@PureWeen

Copy link
Copy Markdown
Member

@copilot Please revise this draft at 51ee336150fc448ed889ed8766d48f9563b7c5b9 to fix a deterministic Router lifecycle regression.

RouterTest.CanceledFailedOnNavigateAsyncDoesNothing now reaches RefreshRouteTable through RunOnNavigateAsync without first calling SetParametersAsync. The PR makes _appAssembly and _additionalAssemblies authoritative for the route key, but assigns them only in SetParametersAsync. The effective key therefore remains default, Routes is not initialized, and Router.Refresh throws NullReferenceException at line 296. The same failure appeared in Components CI on macOS, Linux, and Windows.

Please remove the SetParameters-only snapshot dependency. Resolve effective assemblies at route-table consumption, with explicit AppAssembly/AdditionalAssemblies taking precedence and configured assemblies used only as fallback. Preserve the endpoint RouteData bypass, the missing-AppAssembly error, explicit parameter authority, and standalone WebAssembly behavior.

Use the existing failing test as the regression, run it directly, then run the complete RouterTest class and the failed Components CI leg. The focused correction has been independently shown to turn the failing test green while all 16 adjacent Router tests pass. After the lifecycle correction, strengthen coverage so at least one test witnesses the mapped-assembly producer/transport path instead of manually seeding only Router state. Keep the PR draft and summarize the correction and exact test results when done.

Copilot AI and others added 2 commits August 13, 2026 14:04
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>

Copilot AI commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Please revise this draft at 51ee336150fc448ed889ed8766d48f9563b7c5b9 to fix a deterministic Router lifecycle regression.

`RouterTest.CanceledFailedOnNavigateAsyncDoesNothi...

Addressed in e1378128 and 3f653b6e. Router now resolves explicit-or-configured assemblies when consuming the route table, without SetParameters-only snapshots. Added endpoint metadata → persistent state → assembly provider coverage. Results: focused regression 1/1 passed; complete RouterTest 16/16 passed; complete Components test assembly 1,291 total (1,283 passed, 8 skipped); complete Endpoints test assembly 877/877 passed. The broader ./src/Components/build.sh -test was also attempted but remained blocked by unrelated local environment failures (missing Playwright browsers and a Photino static-asset conflict). The PR remains draft.

@PureWeen

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.

@PureWeen
PureWeen marked this pull request as ready for review August 18, 2026 21:27
@PureWeen
PureWeen requested a review from a team as a code owner August 18, 2026 21:27
Copilot AI lite review requested due to automatic review settings August 18, 2026 21:27

Copilot AI 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 removes the need for Blazor apps to duplicate MapRazorComponents assembly configuration in <Router> by flowing the mapped assemblies through endpoint metadata and persistent component state, allowing Router to default AppAssembly/AdditionalAssemblies when they’re not explicitly provided.

Changes:

  • Captures mapped assemblies as endpoint metadata and persists their names into PersistentComponentState during prerendering.
  • Updates Router to use configured assemblies when AppAssembly / AdditionalAssemblies are omitted, while preserving explicitly supplied parameters.
  • Simplifies template/test usage by omitting explicit router assembly parameters in mapped Blazor Web App scenarios.
Show a summary per file
File Description
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Routes.razor Simplifies template router usage by removing explicit assembly parameters.
src/Components/test/testassets/Components.WasmMinimal/Routes.razor Adds a switch to test Router behavior with/without explicitly supplied assemblies.
src/Components/test/testassets/Components.TestServer/RazorComponents/GlobalInteractivityApp.razor Exercises configured-assemblies routing path in a test host app.
src/Components/Endpoints/test/RazorComponentEndpointFactoryTest.cs Updates endpoint factory tests for the new assemblies metadata parameter.
src/Components/Endpoints/test/RazorComponentEndpointDataSourceTest.cs Verifies endpoints include the new assemblies metadata.
src/Components/Endpoints/test/EndpointHtmlRendererTest.cs Adds coverage ensuring mapped assemblies are restored via endpoint metadata + persistent state.
src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.cs Seeds and persists configured assembly names into component state during endpoint initialization.
src/Components/Endpoints/src/Discovery/ComponentApplicationBuilder.cs Exposes configured assembly names for metadata construction.
src/Components/Endpoints/src/Builder/RazorComponentEndpointFactory.cs Attaches the new assemblies metadata to endpoints.
src/Components/Endpoints/src/Builder/RazorComponentEndpointDataSource.cs Builds the configured assembly-name list and creates assemblies metadata.
src/Components/Endpoints/src/Builder/RazorComponentApplicationAssembliesMetadata.cs Introduces endpoint metadata type carrying configured assembly names.
src/Components/Components/test/Routing/RouterTest.cs Adds a test validating Router defaults to configured assemblies when AppAssembly is omitted.
src/Components/Components/src/Routing/Router.cs Implements defaulting logic for AppAssembly / AdditionalAssemblies using configured assemblies.
src/Components/Components/src/Routing/RazorComponentApplicationAssemblyProvider.cs Adds a provider that restores configured assemblies from persistent component state.
src/Components/Components/src/PersistentState/PersistentStateProviderServiceCollectionExtensions.cs Registers the new assembly provider with the persistent-state services.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 15/15 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread src/Components/Components/src/Routing/Router.cs
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 66f5fa5c-4468-42a4-b23d-69ad8b2f1550
@PureWeen

Copy link
Copy Markdown
Member

🕵️ 🤖 LGTM ✅

Agents used: blazor-components-reviewer, cross-cutting-reviewer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Router to default to the current executing assembly for the app assembly if it isn't explicitly specified

4 participants