Skip to content

Fixes capability detection for hosted Blazor apps #49037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 13, 2025

Conversation

tmat
Copy link
Member

@tmat tmat commented May 17, 2025

@tmat tmat force-pushed the BlazorWasmHostedTest branch from dd3189f to aa4bed4 Compare June 9, 2025 20:19
@tmat tmat changed the title Add BlazorWasmHosted test Fixes capability detection for hosted Blazor apps Jun 9, 2025
@tmat tmat marked this pull request as ready for review June 9, 2025 20:20
@Copilot Copilot AI review requested due to automatic review settings June 9, 2025 20:20
@tmat tmat requested review from arunchndr and a team as code owners June 9, 2025 20:20
@tmat
Copy link
Member Author

tmat commented Jun 9, 2025

@phil-allen-msft @DustinCampbell ptal

Copy link
Contributor

@Copilot Copilot AI 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 fixes capability detection for hosted Blazor apps by replacing the legacy HotReloadProfile mechanism with a new HotReloadAppModel abstraction. The changes include updating test assets and project files for Blazor WASM/hosted apps, removing the HotReloadProfile and related files, and adapting the Browser Refresh and Delta Applier logic to use the new app model.

Reviewed Changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/TestAssets/TestProjects/WatchBlazorWasmHosted/blazorwasm/_Imports.razor Adds necessary using directives.
test/TestAssets/TestProjects/WatchBlazorWasmHosted/blazorwasm/Program.cs Introduces a sample entry point for the Blazor WASM project.
test/TestAssets/TestProjects/WatchBlazorWasmHosted/blazorwasm/Pages/Index.razor Adds a simple page view.
test/TestAssets/TestProjects/WatchBlazorWasmHosted/blazorwasm/LinkToWebRoot/css/app.css Adds an empty style rule for publishing.
test/TestAssets/TestProjects/WatchBlazorWasmHosted/blazorwasm/App.razor Sets up the app router with a fallback view.
test/TestAssets/TestProjects/WatchBlazorWasmHosted/blazorhosted/blazorhosted.csproj Updates the project file to reference the WASM project.
test/TestAssets/TestProjects/WatchBlazorWasmHosted/blazorhosted/Properties/launchSettings.json Provides launch settings for the hosted project.
test/TestAssets/TestProjects/WatchBlazorWasmHosted/blazorhosted/Program.cs Implements a top‑level statement loop for the hosted app sample.
src/BuiltInTools/dotnet-watch/HotReload/ProjectLauncher.cs Replaces profile-based logic with the new app model.
src/BuiltInTools/dotnet-watch/HotReload/HotReloadProfileReader.cs Removes the old HotReloadProfileReader implementation.
src/BuiltInTools/dotnet-watch/HotReload/HotReloadProfile.cs Removes legacy HotReloadProfile definitions.
src/BuiltInTools/dotnet-watch/HotReload/HotReloadAppModel.cs Introduces the new abstraction to infer hot reload behavior.
src/BuiltInTools/dotnet-watch/HotReload/DefaultAppModel.cs Provides the default hot reload model implementation.
src/BuiltInTools/dotnet-watch/HotReload/CompilationHandler.cs Adjusts delta applier creation to use the app model.
src/BuiltInTools/dotnet-watch/HotReload/BlazorWebAssemblyHostedDeltaApplier.cs Renames parameter to clarify that it represents the client project.
src/BuiltInTools/dotnet-watch/HotReload/BlazorWebAssemblyHostedAppModel.cs Adds the hosted model for Blazor WebAssembly apps.
src/BuiltInTools/dotnet-watch/HotReload/BlazorWebAssemblyDeltaApplier.cs Enhances logging with project display names.
src/BuiltInTools/dotnet-watch/HotReload/BlazorWebAssemblyAppModel.cs Adds the client-only model for Blazor WebAssembly apps.
src/BuiltInTools/dotnet-watch/DotNetWatcher.cs Updates server creation to use DefaultAppModel.
src/BuiltInTools/dotnet-watch/Browser/BrowserConnector.cs Updates browser refresh logic to work with the app model.

Copy link
Member

@DustinCampbell DustinCampbell left a comment

Choose a reason for hiding this comment

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

The refactoring into HotReloadAppModel looks solid, but I didn't spot the actual fix. The code to read project capabilities seems to be the same as it was before. and it doesn't look to me like there were any conditions in CompilationHandler the project capabilities wouldn't have been checked before. Could you describe the fix or point me in the right direction?

@tmat
Copy link
Member Author

tmat commented Jun 10, 2025

The difference is the project that we read the capability msbuild property from (the one stored in the app model instance). We need to read it from the client project, but we read it from the server.

@DustinCampbell
Copy link
Member

The difference is the project that we read the capability msbuild property from (the one stored in the app model instance). We need to read it from the client project, but we read it from the server.

Ah-ha - thanks for the clarification!

@tmat tmat force-pushed the BlazorWasmHostedTest branch from e389d0f to 652836e Compare June 12, 2025 19:07
@tmat tmat enabled auto-merge (squash) June 12, 2025 20:22
@tmat tmat merged commit ef93823 into dotnet:main Jun 13, 2025
30 checks passed
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.

2 participants