Repository navigation
Browser refresh server cleanup and .NET Framework impl - #56568
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
3af1569 to
fe34b7f
Compare
|
@javiercn @dotnet/hot-reload ptal |
There was a problem hiding this comment.
🟡 Changes recommended
The .NET Framework listener cannot start with its generated prefixes and has blocking disposal and request-serialization defects.
3 open findings
What changed in this PR
Consolidates browser-refresh hosting and adds a .NET Framework HttpListener implementation for Visual Studio scenarios.
Changes:
- Merges routing and refresh-server behavior into
BrowserRefreshServer. - Adds .NET Framework HTTP/WebSocket hosting and async disposal.
- Updates app models, dependencies, and tests for the new architecture.
| File | Description |
|---|---|
test/Microsoft.Extensions.DotNetDeltaApplier.Tests/WebAssemblyHotReloadClientTests.cs |
Uses async server disposal. |
test/Microsoft.Extensions.DotNetDeltaApplier.Tests/Mocks/TestBrowserRefreshServer.cs |
Adapts the test server to the consolidated implementation. |
test/Microsoft.Extensions.DotNetDeltaApplier.Tests/HotReloadClientsTests.cs |
Uses async server disposal. |
test/Microsoft.Extensions.DotNetDeltaApplier.Tests/BrowserToolsEndpointRouterTests.cs |
Tests request handling through BrowserRefreshServer. |
test/Microsoft.Extensions.DotNetDeltaApplier.Tests/BrowserRefreshServerReplayTests.cs |
Uses async server disposal. |
test/Microsoft.DotNet.HotReload.Client.Tests/Microsoft.DotNet.HotReload.Client.Tests.csproj |
Adds VS threading support. |
test/dotnet-watch.Tests/Web/WebSocketConfigTests.cs |
Moves URL-conversion tests to WebSocketConfig. |
test/dotnet-watch.Tests/TestUtilities/TestBrowserRefreshServer.cs |
Updates the watch test server abstraction. |
test/dotnet-watch.Tests/TestUtilities/InProcTestWatcher.cs |
Disposes the watch context asynchronously. |
test/dotnet-watch.Tests/Browser/BrowserToolsEndpointRouterTests.cs |
Tests consolidated endpoint handling. |
test/dotnet-watch.Tests/Browser/BrowserToolsBuildOutputsTests.cs |
Updates session-key failure expectations. |
test/dotnet-watch.Tests/Browser/BrowserRefreshServerTests.cs |
Updates hosting and environment tests. |
start-vs.cmd |
Supports an optional solution path. |
src/Resolvers/Microsoft.DotNet.MSBuildSdkResolver/Microsoft.DotNet.MSBuildSdkResolver.csproj |
Updates expected dependency closure. |
src/Dotnet.Watch/Watch/UI/IReporter.cs |
Reuses shared browser-tools log events. |
src/Dotnet.Watch/Watch/Context/DotNetWatchContext.cs |
Converts context cleanup to async disposal. |
src/Dotnet.Watch/Watch/Build/ProjectGraphUtilities.cs |
Adds nullable Boolean property lookup. |
src/Dotnet.Watch/Watch/Browser/BrowserToolsBuildOutputsExtensions.cs |
Maps evaluated projects to browser-tools outputs. |
src/Dotnet.Watch/Watch/Browser/BrowserRefreshServerFactory.cs |
Starts and disposes refresh servers asynchronously. |
src/Dotnet.Watch/Watch/Browser/BrowserLauncher.cs |
Uses the consolidated server type. |
src/Dotnet.Watch/Watch/AppModels/WebServerAppModel.cs |
Declares gateway-proxy behavior. |
src/Dotnet.Watch/Watch/AppModels/WebApplicationAppModel.cs |
Centralizes server creation and WebSocket configuration. |
src/Dotnet.Watch/Watch/AppModels/BlazorWebAssemblyHostedAppModel.cs |
Declares hosted-app proxy behavior. |
src/Dotnet.Watch/Watch/AppModels/BlazorWebAssemblyAppModel.cs |
Declares standalone gateway-proxy behavior. |
src/Dotnet.Watch/Watch.Aspire/Server/AspireWatcherLauncher.cs |
Disposes watcher context asynchronously. |
src/Dotnet.Watch/HotReloadClient/WebSocketClientTransport.cs |
Adjusts synchronous MemoryStream access. |
src/Dotnet.Watch/HotReloadClient/Web/WebSocketConfig.cs |
Owns HTTP-to-WebSocket URL conversion. |
src/Dotnet.Watch/HotReloadClient/Web/WebServerHost.cs |
Adds async listener ownership and endpoint naming. |
src/Dotnet.Watch/HotReloadClient/Web/WebAssemblyHotReloadClient.cs |
Uses the consolidated refresh server. |
src/Dotnet.Watch/HotReloadClient/Web/NetFrameworkWebSocketServer.cs |
Adds the .NET Framework listener implementation. |
src/Dotnet.Watch/HotReloadClient/Web/KestrelWebSocketServer.cs |
Adds async-disposal compatibility. |
src/Dotnet.Watch/HotReloadClient/Web/HttpContextWrappers.cs |
Adapts HttpListener requests to the shared handler. |
src/Dotnet.Watch/HotReloadClient/Web/BrowserToolsEndpointRouter.cs |
Removes the standalone router. |
src/Dotnet.Watch/HotReloadClient/Web/BrowserToolsBuildOutputs.cs |
Makes key loading shared and failure-tolerant. |
src/Dotnet.Watch/HotReloadClient/Web/BrowserRefreshServer.cs |
Consolidates hosting, routing, and browser communication. |
src/Dotnet.Watch/HotReloadClient/Web/BrowserConnection.cs |
Removes the custom initialization wait helper. |
src/Dotnet.Watch/HotReloadClient/Web/AbstractBrowserRefreshServer.cs |
Removes the former base implementation. |
src/Dotnet.Watch/HotReloadClient/Utilities/TaskExtensions.cs |
Adds .NET Framework async polyfills. |
src/Dotnet.Watch/HotReloadClient/Utilities/DisposalCancellationSource.cs |
Adds disposal-driven cancellation support. |
src/Dotnet.Watch/HotReloadClient/Microsoft.DotNet.HotReload.Client.Package.csproj |
Adds VS threading dependency. |
src/Dotnet.Watch/HotReloadClient/Logging/LogEvents.cs |
Adds shared browser-tools events. |
src/Dotnet.Watch/HotReloadClient/HotReloadClients.cs |
Uses the consolidated server type. |
src/Dotnet.Watch/HotReloadClient/HotReloadClient.cs |
Renames the queued-update method. |
src/Dotnet.Watch/HotReloadClient/DefaultHotReloadClient.cs |
Updates async method naming and calls. |
src/Dotnet.Watch/HotReloadClient/.editorconfig |
Configures VS threading diagnostics. |
src/Dotnet.Watch/dotnet-watch/Program.cs |
Disposes watch context asynchronously. |
eng/Versions.props |
Updates async-support packages and adds VS threading. |
🧠 Review effort: Balanced
76581b1 to
757532d
Compare
Add Microsoft.VisualStudio.Threading package reference to supply .NET Framework polyfills and analyzer.
757532d to
6abc96f
Compare
58e09d2 to
5898c71
Compare
…tools implementation. Browser tools is used by all Hot Reload hosts (VS, CDK) not just by dotnet-watch.
|
@rainersigwald for MSBuild version changes approval |
DustinCampbell
left a comment
There was a problem hiding this comment.
Looks good. I skimmed through all of the staticwebassets.json files and didn't spot anything off. (My eyes did start to swim a bit though. 😄)
| public int StatusCode | ||
| { | ||
| set => response.StatusCode = value; | ||
| } | ||
|
|
||
| public string? ContentType | ||
| { | ||
| set => response.ContentType = value; | ||
| } |
There was a problem hiding this comment.
Is there value in using setter-only properties?
There was a problem hiding this comment.
These wrappers are adapting .NET Framework API to the shape used by .NET.
I only got Copilot generate those APIs that are currently used.
|
/backport to release/11.0.1xx |
|
Started backporting to |
|
@tmat backporting to git am output$ git cherry-pick 680d5f1e3c8cab8342a5e939389696deea0a9286
CONFLICT (modify/delete): .github/memory/ARCHITECTURE.md deleted in HEAD and modified in 680d5f1e3c (Browser refresh server cleanup and .NET Framework impl (#56568)). Version 680d5f1e3c (Browser refresh server cleanup and .NET Framework impl (#56568)) of .github/memory/ARCHITECTURE.md left in tree.
Auto-merging eng/Versions.props
Auto-merging src/Dotnet.Watch/AGENTS.md
Auto-merging src/Dotnet.Watch/HotReloadClient/DefaultHotReloadClient.cs
CONFLICT (content): Merge conflict in src/Dotnet.Watch/HotReloadClient/DefaultHotReloadClient.cs
Auto-merging src/Dotnet.Watch/HotReloadClient/HotReloadClient.cs
Auto-merging src/Dotnet.Watch/HotReloadClient/HotReloadClients.cs
CONFLICT (modify/delete): src/Dotnet.Watch/HotReloadClient/Web/AbstractBrowserRefreshServer.cs deleted in 680d5f1e3c (Browser refresh server cleanup and .NET Framework impl (#56568)) and modified in HEAD. Version HEAD of src/Dotnet.Watch/HotReloadClient/Web/AbstractBrowserRefreshServer.cs left in tree.
Auto-merging src/Dotnet.Watch/HotReloadClient/Web/BrowserConnection.cs
Auto-merging src/Dotnet.Watch/HotReloadClient/Web/WebAssemblyHotReloadClient.cs
Auto-merging src/Dotnet.Watch/Watch/AppModels/BlazorWebAssemblyHostedAppModel.cs
Auto-merging src/Dotnet.Watch/Watch/AppModels/WebServerAppModel.cs
Auto-merging test/Microsoft.DotNet.HotReload.Client.Tests/Microsoft.DotNet.HotReload.Client.Tests.csproj
Auto-merging test/Microsoft.NET.Sdk.StaticWebAssets.Tests/StaticWebAssetsBaselines/Build_DoesNotFailToCompress_TwoAssetsWith_TheSameContent.Build.staticwebassets.json
CONFLICT (content): Merge conflict in test/Microsoft.NET.Sdk.StaticWebAssets.Tests/StaticWebAssetsBaselines/Build_DoesNotFailToCompress_TwoAssetsWith_TheSameContent.Build.staticwebassets.json
Auto-merging test/dotnet-watch.Tests/dotnet-watch.Tests.csproj
error: could not apply 680d5f1e3c... Browser refresh server cleanup and .NET Framework impl (#56568)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Move environment configuration back to AbstractBrowserRefreshServer
Using index info to reconstruct a base tree...
M src/Dotnet.Watch/HotReloadClient/Web/AbstractBrowserRefreshServer.cs
M src/Dotnet.Watch/Watch/AppModels/BlazorWebAssemblyHostedAppModel.cs
M src/Dotnet.Watch/Watch/AppModels/WebServerAppModel.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Dotnet.Watch/HotReloadClient/Web/AbstractBrowserRefreshServer.cs
Auto-merging src/Dotnet.Watch/Watch/AppModels/BlazorWebAssemblyHostedAppModel.cs
Auto-merging src/Dotnet.Watch/Watch/AppModels/WebServerAppModel.cs
Applying: Move BrowserToolsBuildOutputs to client package
Applying: SessionKeyFactory
Applying: Update start-vs.cmd to accept optional solution path argument
Applying: Fold BrowserToolsEndpointRouter into BrowserRefreshServer
Applying: Add NetFrameworkBrowserRefreshServer
Using index info to reconstruct a base tree...
M eng/Versions.props
M src/Dotnet.Watch/HotReloadClient/DefaultHotReloadClient.cs
M src/Dotnet.Watch/HotReloadClient/HotReloadClient.cs
M src/Dotnet.Watch/HotReloadClient/Web/AbstractBrowserRefreshServer.cs
M src/Dotnet.Watch/HotReloadClient/Web/BrowserConnection.cs
M src/Dotnet.Watch/HotReloadClient/Web/WebAssemblyHotReloadClient.cs
M test/Microsoft.DotNet.HotReload.Client.Tests/Microsoft.DotNet.HotReload.Client.Tests.csproj
Falling back to patching base and 3-way merge...
Auto-merging eng/Versions.props
Auto-merging src/Dotnet.Watch/HotReloadClient/DefaultHotReloadClient.cs
CONFLICT (content): Merge conflict in src/Dotnet.Watch/HotReloadClient/DefaultHotReloadClient.cs
Auto-merging src/Dotnet.Watch/HotReloadClient/HotReloadClient.cs
Auto-merging src/Dotnet.Watch/HotReloadClient/Web/AbstractBrowserRefreshServer.cs
Auto-merging src/Dotnet.Watch/HotReloadClient/Web/BrowserConnection.cs
Auto-merging src/Dotnet.Watch/HotReloadClient/Web/WebAssemblyHotReloadClient.cs
Auto-merging test/Microsoft.DotNet.HotReload.Client.Tests/Microsoft.DotNet.HotReload.Client.Tests.csproj
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0006 Add NetFrameworkBrowserRefreshServer
Error: The process '/usr/bin/git' failed with exit code 128 |
yeah, lgtm |


Follow up on #56118.
Simplifies Browser Refresh Server implementation and adds .NET Framework implementation with functionality on par with Kestrel.
The .NET Framework implementation is needed for VS.
Best to review commit by commit.