Skip to content

[StaticWebAssets] Add MAUI Blazor Hybrid + BlazorWebView regression test (dotnet/sdk#54779)#54932

Open
javiercn wants to merge 3 commits into
mainfrom
javiercn/swa-maui-blazorwebview-modules-test
Open

[StaticWebAssets] Add MAUI Blazor Hybrid + BlazorWebView regression test (dotnet/sdk#54779)#54932
javiercn wants to merge 3 commits into
mainfrom
javiercn/swa-maui-blazorwebview-modules-test

Conversation

@javiercn

@javiercn javiercn commented Jun 22, 2026

Copy link
Copy Markdown
Member

Summary

Adds integration coverage for the MAUI Blazor Hybrid scenario from #54779: an app (Microsoft.NET.Sdk.Razor) that references a Razor class library and the BlazorWebView package, where the package contributes a fallback _framework/blazor.modules.json.

This is test-only — there is no SDK product code change. The actual fix belongs upstream in dotnet/aspnetcore (tracked by dotnet/aspnetcore#67374); this PR locks in coverage so the scenario keeps working in the SDK.

What the test covers

test/TestAssets/TestProjects/MauiBlazorHybridWebView packs a simulated BlazorWebView package that models blazor.modules.json as a Framework asset (StaticWebAssetFrameworkPattern), mirroring how Microsoft.AspNetCore.Components.WebAssembly ships its framework assets. The asset encodes the idiomatic behavior: the manifest is materialized once into the consuming project at build, becomes an ordinary project asset, and the app's own generated manifest wins — with the package manifest serving as the fallback when the app has no JS modules. The .csproj/.props carry comments pointing at the real aspnetcore/maui sources and the tracking issues.

MauiBlazorHybridWebViewIntegrationTest tracks both outcomes of the scenario:

  1. Publish_FrameworkModulesAsset_AppHasModules_AppManifestWins — the app contributes JS modules, so a single _framework/blazor.modules.json endpoint is produced and the app's generated (Computed) manifest wins (the package fallback is not used).
  2. Publish_FrameworkModulesAsset_NoAppModules_UsesMaterializedPackageFallback — with no app JS modules, the materialized package manifest (Discovered) is the one that is served.

In addition to endpoint/source selection, the tests now also validate the published _framework/blazor.modules.json contents:

  • app-manifest-wins case contains the app + RCL JS module entries;
  • package-fallback case contains the expected empty array ([]).

The package is consumed as a real PackageReference (packed to $(AspNetTestPackageSource), restored via IsolatedNuGetPackageFolderAspNetSdkBaselineTest) so publish-time framework-asset materialization is exercised faithfully — a project-to-project reference would not materialize framework assets at publish.

Validation

Microsoft.NET.Sdk.StaticWebAssets.Tests  Total: 2, Errors: 0, Failed: 0, Skipped: 0

Related

Copilot AI review requested due to automatic review settings June 22, 2026 23:25

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

Adds an integration regression test for the MAUI Blazor Hybrid + BlazorWebView scenario from #54779 by introducing a new test asset that simulates the package/app/library shape and a corresponding dotnet publish-driven test that asserts the failure and the fixed behavior.

Changes:

  • Adds a new MauiBlazorHybridWebView test asset containing a simulated app, Razor class library, and a packable “BlazorWebViewPackage” that can author the fallback modules manifest via two modes (group vs framework asset).
  • Adds MauiBlazorHybridWebViewIntegrationTest covering the regression (expected failure) and the fixed behavior (publish succeeds and selects the correct _framework/blazor.modules.json endpoint).
  • Introduces minimal JS/CSS/Razor content to ensure JS module manifest generation and static web asset flows are exercised.

Reviewed changes

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

Show a summary per file
File Description
test/TestAssets/TestProjects/MauiBlazorHybridWebView/MauiRazorClassLibrary/wwwroot/MauiRazorClassLibrary.lib.module.js Provides an RCL JS module input to trigger JS module manifest generation.
test/TestAssets/TestProjects/MauiBlazorHybridWebView/MauiRazorClassLibrary/wwwroot/css/rcl.css Adds RCL static web asset content for realism.
test/TestAssets/TestProjects/MauiBlazorHybridWebView/MauiRazorClassLibrary/MauiRazorClassLibrary.csproj Defines the Razor class library used by the simulated app.
test/TestAssets/TestProjects/MauiBlazorHybridWebView/MauiRazorClassLibrary/Component1.razor.css Adds scoped CSS to more closely match real RCL usage.
test/TestAssets/TestProjects/MauiBlazorHybridWebView/MauiRazorClassLibrary/Component1.razor Adds a simple component to ensure the project is a Razor class library.
test/TestAssets/TestProjects/MauiBlazorHybridWebView/MauiBlazorApp/wwwroot/MauiBlazorApp.lib.module.js Provides app-side JS module input to produce an app-generated modules manifest.
test/TestAssets/TestProjects/MauiBlazorHybridWebView/MauiBlazorApp/MauiBlazorApp.csproj Simulates the MAUI hybrid app shape (Root static web assets mode + package + P2P reference).
test/TestAssets/TestProjects/MauiBlazorHybridWebView/MauiBlazorApp/Class1.cs Minimal compile-time marker for the simulated app project.
test/TestAssets/TestProjects/MauiBlazorHybridWebView/BlazorWebViewPackage/wwwroot/_framework/blazor.webview.js Simulated framework script shipped by the BlazorWebView-like package.
test/TestAssets/TestProjects/MauiBlazorHybridWebView/BlazorWebViewPackage/wwwroot/_framework/blazor.modules.json Simulated fallback blazor.modules.json shipped by the package.
test/TestAssets/TestProjects/MauiBlazorHybridWebView/BlazorWebViewPackage/Class1.cs Minimal compile-time marker for the simulated package project.
test/TestAssets/TestProjects/MauiBlazorHybridWebView/BlazorWebViewPackage/build/BlazorWebViewPackage.props Implements the two authoring modes (group vs framework asset) to reproduce and validate the regression/fix behavior.
test/TestAssets/TestProjects/MauiBlazorHybridWebView/BlazorWebViewPackage/BlazorWebViewPackage.csproj Packs the simulated package and toggles framework-asset modeling via StaticWebAssetFrameworkPattern.
test/Microsoft.NET.Sdk.StaticWebAssets.Tests/MauiBlazorHybridWebViewIntegrationTest.cs New integration test asserting the regression failure and validating the fixed behavior and fallback behavior.

Adds integration coverage for the MAUI Blazor Hybrid shape from
#54779: an app that references a Razor class library and the
BlazorWebView package, where the package contributes a fallback
_framework/blazor.modules.json.

The test asset packs a simulated BlazorWebView package that models
blazor.modules.json as a Framework asset (StaticWebAssetFrameworkPattern),
mirroring Microsoft.AspNetCore.Components.WebAssembly. The asset encodes the
idiomatic behavior tracked by dotnet/aspnetcore#67374; the csproj comments
point at the real aspnetcore/maui sources and issues.

Two facts track both outcomes of the scenario:

* App has its own JS modules -> the app's generated manifest wins and a
  single _framework/blazor.modules.json endpoint is produced (no fallback).
* App has no JS modules -> the materialized package manifest is served as
  the fallback.

The package is consumed as a real PackageReference (packed to
$(AspNetTestPackageSource), restored via IsolatedNuGetPackageFolderAspNetSdkBaselineTest)
so publish-time framework-asset materialization is exercised faithfully.

No SDK product code changes; the fix belongs in dotnet/aspnetcore
(dotnet/aspnetcore#67374).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

namespace Microsoft.NET.Sdk.StaticWebAssets.Tests
{
// Regression coverage for https://github.com/dotnet/sdk/issues/54779.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Tests should also validate the contents of the modules.json file for correctness

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@copilot chop chop

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.

Addressed in ab5a12d. The integration tests now assert _framework/blazor.modules.json content for both scenarios: app+RCL modules are present when the app manifest wins, and the fallback manifest is empty when app modules are removed.

Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
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.

3 participants