[StaticWebAssets] Add MAUI Blazor Hybrid + BlazorWebView regression test (dotnet/sdk#54779)#54932
[StaticWebAssets] Add MAUI Blazor Hybrid + BlazorWebView regression test (dotnet/sdk#54779)#54932javiercn wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
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
MauiBlazorHybridWebViewtest 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
MauiBlazorHybridWebViewIntegrationTestcovering the regression (expected failure) and the fixed behavior (publish succeeds and selects the correct_framework/blazor.modules.jsonendpoint). - 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>
a41b85f to
8e71402
Compare
|
|
||
| namespace Microsoft.NET.Sdk.StaticWebAssets.Tests | ||
| { | ||
| // Regression coverage for https://github.com/dotnet/sdk/issues/54779. |
There was a problem hiding this comment.
Tests should also validate the contents of the modules.json file for correctness
There was a problem hiding this comment.
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>
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/MauiBlazorHybridWebViewpacks a simulated BlazorWebView package that modelsblazor.modules.jsonas a Framework asset (StaticWebAssetFrameworkPattern), mirroring howMicrosoft.AspNetCore.Components.WebAssemblyships 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/.propscarry comments pointing at the real aspnetcore/maui sources and the tracking issues.MauiBlazorHybridWebViewIntegrationTesttracks both outcomes of the scenario:Publish_FrameworkModulesAsset_AppHasModules_AppManifestWins— the app contributes JS modules, so a single_framework/blazor.modules.jsonendpoint is produced and the app's generated (Computed) manifest wins (the package fallback is not used).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.jsoncontents:[]).The package is consumed as a real
PackageReference(packed to$(AspNetTestPackageSource), restored viaIsolatedNuGetPackageFolderAspNetSdkBaselineTest) so publish-time framework-asset materialization is exercised faithfully — a project-to-project reference would not materialize framework assets at publish.Validation
Related
GenerateStaticWebAssetEndpointsManifestthrowsSequence contains more than one elementwhen a MAUI Blazor Hybrid project references a Razor class library and the BlazorWebView package #54779 — the publish-timeSequence contains more than one elementcrash this scenario regressed into.JSModulesEnabled=false).