Skip to content

[dotnet-watch] http transport for mobile#52581

Open
jonathanpeppers wants to merge 10 commits intodotnet:release/10.0.3xxfrom
jonathanpeppers:dev/peppers/watch-http-transport
Open

[dotnet-watch] http transport for mobile#52581
jonathanpeppers wants to merge 10 commits intodotnet:release/10.0.3xxfrom
jonathanpeppers:dev/peppers/watch-http-transport

Conversation

@jonathanpeppers
Copy link
Member

@jonathanpeppers jonathanpeppers commented Jan 20, 2026

Context: #52492

dotnet watch for .NET MAUI Scenarios

Overview

This implements dotnet watch / Hot Reload for mobile platforms (Android, iOS), which cannot use the standard named pipe transport. Similar to how web applications already use websockets for reloading CSS and JavaScript, we will use the same model for mobile applications.

Transport Selection

Platform Transport Reason
Desktop/Console Named Pipe Existing implementation, Fast, local IPC
Android/iOS WebSocket Named pipes don't work over the network; adb reverse tunnels the connection

dotnet-watch detects WebSocket transport via the HotReloadWebSockets capability:

<ProjectCapability Include="HotReloadWebSockets" />

Mobile workloads (Android, iOS) add this capability to their SDK targets. This allows any workload to opt into WebSocket-based hot reload.

SDK Changes

WebSocket Details

dotnet-watch already has a WebSocket server for web apps: BrowserRefreshServer. This server:

  • Hosts via Kestrel on https://localhost:<port>
  • Communicates with JavaScript (aspnetcore-browser-refresh.js) injected into web pages
  • Sends commands like "refresh CSS", "reload page", "apply Blazor delta"

For mobile, we reuse the Kestrel infrastructure but with a different protocol:

Server Client Protocol
BrowserRefreshServer JavaScript in browser JSON messages for CSS/page refresh
HotReloadWebSocketServer Startup hook on device Binary delta payloads (same as named pipe)

The mobile server (HotReloadWebSocketServer) extends KestrelWebSocketServer and speaks the same binary protocol as the named pipe transport, just over WebSocket instead.

1. WebSocket Capability Detection

ProjectGraphUtilities.cs checks for the HotReloadWebSockets capability (case-insensitive).

2. MobileAppModel

Creates a MobileHotReloadClient with a WebSocket server instead of named pipes.

3. Environment Variables

dotnet-watch launches the app via:

dotnet run --no-build \
  -e DOTNET_WATCH=1 \
  -e DOTNET_MODIFIABLE_ASSEMBLIES=debug \
  -e DOTNET_WATCH_HOTRELOAD_WEBSOCKET_ENDPOINT=ws://127.0.0.1:<port> \
  -e DOTNET_STARTUP_HOOKS=<path to DeltaApplier.dll>

The port is dynamically assigned (defaults to 0, meaning the OS picks an available port) to avoid conflicts in CI and parallel test scenarios. The DOTNET_WATCH_HOTRELOAD_HTTP_PORT environment variable can override this if a specific port is needed.

These environment variables are passed as @(RuntimeEnvironmentVariable) MSBuild items to the workload. See dotnet-run-for-maui.md for details on dotnet run and environment variables.

Android Workload Changes (Example Integration)

dotnet/android#10770 — RuntimeEnvironmentVariable Support

Enables the Android workload to receive env vars from dotnet run -e:

  • Adds <ProjectCapability Include="RuntimeEnvironmentVariableSupport" />
  • Configures @(RuntimeEnvironmentVariable) items, so they will apply to Android.

dotnet/android#10778 — dotnet-watch Integration

  1. Startup Hook: Parses DOTNET_STARTUP_HOOKS, includes the assembly in the app package, rewrites the path to just the assembly name (since the full path doesn't exist on device)
  2. Port Forwarding: Runs adb reverse tcp:<port> tcp:<port> so the device can reach the host's WebSocket server via 127.0.0.1:<port> (port is parsed from the endpoint URL)
  3. Prevents Double Connection: Disables startup hooks in Microsoft.Android.Run (the desktop launcher) so only the mobile app connects
  4. Adds <ProjectCapability Include="HotReloadWebSockets" /> to opt into WebSocket-based hot reload.

Data Flow

  1. Build: dotnet-watch builds the project, detects HotReloadWebSockets capability
  2. Launch: dotnet run -e DOTNET_WATCH_HOTRELOAD_WEBSOCKET_ENDPOINT=ws://127.0.0.1:<port> -e DOTNET_STARTUP_HOOKS=...
  3. Workload: Android build tasks:
    • Include the startup hook DLL in the APK
    • Set up ADB port forwarding for the dynamically assigned port
    • Rewrite env vars for on-device paths
  4. Device: App starts → StartupHook loads → Transport.TryCreate() reads env vars → WebSocketTransport connects to ws://127.0.0.1:<port>
  5. Hot Reload: File change → delta compiled → sent over WebSocket → applied on device

iOS

Similar changes will be made in the iOS workload to opt into WebSocket-based hot reload:

  • Add <ProjectCapability Include="HotReloadWebSockets" />
  • Handle startup hooks and port forwarding similar to Android

Dependencies

  • runtime#123964: [mono] read $DOTNET_STARTUP_HOOKS — needed for Mono runtime to honor startup hooks (temporary workaround via RuntimeHostConfigurationOption)

jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this pull request Feb 6, 2026
Context: dotnet/sdk#52492
Context: dotnet/sdk#52581

`dotnet-watch` now runs Android applications via:

    dotnet watch 🚀 [helloandroid (net10.0-android)] Launched 'D:\src\xamarin-android\bin\Debug\dotnet\dotnet.exe' with arguments 'run --no-build -e DOTNET_WATCH=1 -e DOTNET_WATCH_ITERATION=1 -e DOTNET_MODIFIABLE_ASSEMBLIES=debug -e DOTNET_WATCH_HOTRELOAD_WEBSOCKET_ENDPOINT=ws://localhost:9000 -e DOTNET_STARTUP_HOOKS=D:\src\xamarin-android\bin\Debug\dotnet\sdk\10.0.300-dev\DotnetTools\dotnet-watch\10.0.300-dev\tools\net10.0\any\hotreload\net10.0\Microsoft.Extensions.DotNetDeltaApplier.dll -bl': process id 3356

And so the pieces on Android for this to work are:

~~ Startup Hook Assembly ~~

Parse out the value:

    <_AndroidHotReloadAgentAssemblyPath>@(RuntimeEnvironmentVariable->WithMetadataValue('Identity', 'DOTNET_STARTUP_HOOKS')->'%(Value)'->Exists())</_AndroidHotReloadAgentAssemblyPath>

And verify this assembly is included in the app:

    <ResolvedFileToPublish Include="$(_AndroidHotReloadAgentAssemblyPath)" />

Then, for Android, we need to patch up `$DOTNET_STARTUP_HOOKS` to be
just the assembly name, not the full path:

    <_AndroidHotReloadAgentAssemblyName>$([System.IO.Path]::GetFileNameWithoutExtension('$(_AndroidHotReloadAgentAssemblyPath)'))</_AndroidHotReloadAgentAssemblyName>
    ...
    <RuntimeEnvironmentVariable Include="DOTNET_STARTUP_HOOKS" Value="$(_AndroidHotReloadAgentAssemblyName)" />

~~ Port Forwarding ~~

A new `_AndroidConfigureAdbReverse` target runs after deploying apps,
that does:

    adb reverse tcp:9000 tcp:9000

I parsed the value out of:

    <_AndroidWebSocketEndpoint>@(RuntimeEnvironmentVariable->WithMetadataValue('Identity', 'DOTNET_WATCH_HOTRELOAD_WEBSOCKET_ENDPOINT')->'%(Value)')</_AndroidWebSocketEndpoint>
    <_AndroidWebSocketPort>$([System.Text.RegularExpressions.Regex]::Match('$(_AndroidWebSocketEndpoint)', ':(\d+)').Groups[1].Value)</_AndroidWebSocketPort>

~~ Prevent Startup Hooks in Microsoft.Android.Run ~~

When I was implementing this, I keep seeing *two* clients connect to
`dotnet-watch` and I was pulling my hair to figure out why!

Then I realized that `Microsoft.Android.Run` was also getting
`$DOTNET_STARTUP_HOOKS`, and so we had a desktop process + mobile
process both trying to connect!

Easiest fix, is to disable startup hook support in
`Microsoft.Android.Run`. I reviewed the code in `dotnet run`, and it
doesn't seem correct to try to clear the env vars.

~~ Conclusion ~~

With these changes, everything is working!

    dotnet watch 🔥 C# and Razor changes applied in 23ms.

This will depend on getting changes in dotnet/sdk before we merge.
jonathanpeppers added a commit to dotnet/android that referenced this pull request Feb 6, 2026
Context: dotnet/sdk#52492
Context: dotnet/sdk#52581

`dotnet-watch` now runs Android applications via:

    dotnet watch 🚀 [helloandroid (net10.0-android)] Launched 'D:\src\xamarin-android\bin\Debug\dotnet\dotnet.exe' with arguments 'run --no-build -e DOTNET_WATCH=1 -e DOTNET_WATCH_ITERATION=1 -e DOTNET_MODIFIABLE_ASSEMBLIES=debug -e DOTNET_WATCH_HOTRELOAD_WEBSOCKET_ENDPOINT=ws://localhost:9000 -e DOTNET_STARTUP_HOOKS=D:\src\xamarin-android\bin\Debug\dotnet\sdk\10.0.300-dev\DotnetTools\dotnet-watch\10.0.300-dev\tools\net10.0\any\hotreload\net10.0\Microsoft.Extensions.DotNetDeltaApplier.dll -bl': process id 3356

And so the pieces on Android for this to work are:

~~ Startup Hook Assembly ~~

Parse out the value:

    <_AndroidHotReloadAgentAssemblyPath>@(RuntimeEnvironmentVariable->WithMetadataValue('Identity', 'DOTNET_STARTUP_HOOKS')->'%(Value)'->Exists())</_AndroidHotReloadAgentAssemblyPath>

And verify this assembly is included in the app:

    <ResolvedFileToPublish Include="$(_AndroidHotReloadAgentAssemblyPath)" />

Then, for Android, we need to patch up `$DOTNET_STARTUP_HOOKS` to be
just the assembly name, not the full path:

    <_AndroidHotReloadAgentAssemblyName>$([System.IO.Path]::GetFileNameWithoutExtension('$(_AndroidHotReloadAgentAssemblyPath)'))</_AndroidHotReloadAgentAssemblyName>
    ...
    <RuntimeEnvironmentVariable Include="DOTNET_STARTUP_HOOKS" Value="$(_AndroidHotReloadAgentAssemblyName)" />

~~ Port Forwarding ~~

A new `_AndroidConfigureAdbReverse` target runs after deploying apps,
that does:

    adb reverse tcp:9000 tcp:9000

I parsed the value out of:

    <_AndroidWebSocketEndpoint>@(RuntimeEnvironmentVariable->WithMetadataValue('Identity', 'DOTNET_WATCH_HOTRELOAD_WEBSOCKET_ENDPOINT')->'%(Value)')</_AndroidWebSocketEndpoint>
    <_AndroidWebSocketPort>$([System.Text.RegularExpressions.Regex]::Match('$(_AndroidWebSocketEndpoint)', ':(\d+)').Groups[1].Value)</_AndroidWebSocketPort>

~~ Prevent Startup Hooks in Microsoft.Android.Run ~~

When I was implementing this, I keep seeing *two* clients connect to
`dotnet-watch` and I was pulling my hair to figure out why!

Then I realized that `Microsoft.Android.Run` was also getting
`$DOTNET_STARTUP_HOOKS`, and so we had a desktop process + mobile
process both trying to connect!

Easiest fix, is to disable startup hook support in
`Microsoft.Android.Run`. I reviewed the code in `dotnet run`, and it
doesn't seem correct to try to clear the env vars.

~~ Conclusion ~~

With these changes, everything is working!

    dotnet watch 🔥 C# and Razor changes applied in 23ms.

This will depend on getting changes in dotnet/sdk before we merge.
Copy link
Contributor

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 adds a WebSocket-based hot reload transport to dotnet watch to support mobile scenarios (Android/iOS) where named pipes aren’t viable, selecting the transport via a new HotReloadWebSockets project capability.

Changes:

  • Add WebSocket transport selection for hot reload (capability detection + mobile app model) and plumb a configurable port via environment options.
  • Implement WebSocket server/client plumbing for hot reload (watch side Kestrel WebSocket server + agent-side WebSocket transport) while reusing the existing binary delta protocol.
  • Add a new test project + test coverage validating WebSocket transport selection and hot reload behavior.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/dotnet-watch.Tests/HotReload/MobileHotReloadTests.cs Adds end-to-end test verifying WebSocket hot reload path is selected and works.
test/TestAssets/TestProjects/WatchMobileApp/WatchMobileApp.csproj New test asset project that opts into WebSocket transport via HotReloadWebSockets capability.
test/TestAssets/TestProjects/WatchMobileApp/Program.cs New test app used by dotnet watch tests to validate hot reload output changes.
test/Microsoft.Extensions.DotNetDeltaApplier.Tests/HotReloadClientTests.cs Updates agent/client tests to use the new transport abstraction and listener.
src/BuiltInTools/Watch/UI/IReporter.cs Adds a new debug descriptor to log “Application kind: WebSockets.”
src/BuiltInTools/Watch/Context/EnvironmentVariables.cs Adds env var names + parsing for the hot reload HTTP port override and WebSocket endpoint name.
src/BuiltInTools/Watch/Context/EnvironmentOptions.cs Adds HotReloadHttpPort option and wires it to environment variable reading.
src/BuiltInTools/Watch/Build/ProjectGraphUtilities.cs Adds capability-based detection for WebSocket hot reload projects.
src/BuiltInTools/Watch/Build/BuildNames.cs Introduces ProjectCapability.HotReloadWebSockets constant.
src/BuiltInTools/Watch/AppModels/MobileAppModel.cs New app model that creates a MobileHotReloadClient (WebSocket-based).
src/BuiltInTools/Watch/AppModels/HotReloadAppModel.cs Selects the mobile/WebSocket app model when capability is present.
src/BuiltInTools/HotReloadClient/Web/KestrelWebSocketServer.cs New Kestrel-hosted WebSocket server base used by mobile hot reload.
src/BuiltInTools/HotReloadClient/MobileHotReloadClient.cs Implements watch-side WebSocket hot reload client + server coordination.
src/BuiltInTools/HotReloadAgent.Host/Transport.cs Introduces a transport abstraction for agent communications.
src/BuiltInTools/HotReloadAgent.Host/NamedPipeTransport.cs Moves named-pipe specifics behind the new Transport abstraction.
src/BuiltInTools/HotReloadAgent.Host/WebSocketTransport.cs Adds WebSocket transport implementation for the agent startup hook.
src/BuiltInTools/HotReloadAgent.Host/Listener.cs Refactors the listener to work over the new transport abstraction (pipe or WebSocket).
src/BuiltInTools/HotReloadAgent.Host/StartupHook.cs Switches startup hook connection logic to choose transport from env vars.
src/BuiltInTools/HotReloadAgent.Data/AgentEnvironmentVariables.cs Adds DOTNET_WATCH_HOTRELOAD_WEBSOCKET_ENDPOINT constant.
documentation/specs/dotnet-watch-for-maui.md Adds a spec describing capability detection, env vars, and workload integration points.

jonathanpeppers and others added 3 commits February 13, 2026 07:50
This was using a HTTP listener at first, later switched to WebSockets.
@jonathanpeppers jonathanpeppers force-pushed the dev/peppers/watch-http-transport branch from 9001e8b to 41e4074 Compare February 13, 2026 13:58
* Now uses `dotnet run -e` environment variables for everything

* Now uses web sockets

* Adds tests for mobile hot reload
Introduce RSA-based authentication for mobile hot reload WebSocket connections. Adds DOTNET_WATCH_HOTRELOAD_WEBSOCKET_KEY env var and constant, and propagates the server public key to the client. WebSocketTransport now accepts a server public key, encrypts a random 32-byte secret with RSA-OAEP-SHA256, and sends it as a URL-safe Base64 subprotocol token. HotReloadWebSocketServer uses SharedSecretProvider to expose the public key and to decrypt/validate the incoming secret, rejecting connections with missing/invalid secrets. Also adds a Base64Url helper for URL-safe Base64 encoding/decoding and updates documentation and cleanup to dispose the shared secret provider.
@jonathanpeppers jonathanpeppers force-pushed the dev/peppers/watch-http-transport branch from 41e4074 to 9af2d80 Compare February 13, 2026 13:59
var encrypted = rsa.Encrypt(secret, RSAEncryptionPadding.OaepSHA256);

// Convert to URL-safe Base64 for WebSocket subprotocol header
return Base64Url.EncodeToString(encrypted);
Copy link
Member

Choose a reason for hiding this comment

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

Can we use Convert.ToBase64String?

Copy link
Member Author

Choose a reason for hiding this comment

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

It needs to use System.Buffers.Text.Base64Url.EncodeToString() because of +, /, and trailing =.

I called the BCL for .NET 8+ where they added this API, but I had to write a version for netstandard2.0.

/// Port for HTTP hot reload communication. Used for projects with the HotReloadWebSockets capability.
/// Mobile workloads (Android, iOS) add this capability. Defaults to 0 (auto-assign) if not specified.
/// </summary>
public static int HotReloadHttpPort => ReadInt(Names.DotNetWatchHotReloadHttpPort) ?? 0;
Copy link
Member

Choose a reason for hiding this comment

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

We need two ports - one for HTTP and another one for HTTPs, right? Otherwise, they're gonna collide.

We have similar problem with AutoReloadWebSocketPort: #52959

Copy link
Member

@tmat tmat Feb 13, 2026

Choose a reason for hiding this comment

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

Let's call this variable AgentWebSocketPort (and AgentWebSocketSecurePort for wss).

(A better name for AutoReloadWebSocketPort would be BrowserWebSocketPort. I'll rename it in #52959.).

///
/// Server-side implementation using Kestrel + WebSockets, extends KestrelWebSocketServer.
/// </summary>
internal sealed class MobileHotReloadClient : HotReloadClient
Copy link
Member

@tmat tmat Feb 13, 2026

Choose a reason for hiding this comment

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

Most of the code, other than sending/receiving messages is now the same as DefaultHotReloadClient.

I think it'd make sense to define similar Transport abstraction as we have in the agent and use DefaultHotReloadClient for both cases. It would create named pipe/web socket transport layer depending on given parameters.

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed in 7798648, 🤞 the tests still pass.

It does look a lot cleaner this way.


public async ValueTask StartServerAsync(string hostName, int port, CancellationToken cancellationToken)
{
await base.StartServerAsync(hostName, port, useTls: false, cancellationToken);
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we enable HTTPs?

Copy link
Member

@tmat tmat Feb 13, 2026

Choose a reason for hiding this comment

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

I'd move IsTlsSupportedAsync, GetServerUrls and the body of CreateAndStartHostAsync from BowserRefreshServer to KestrelWebSocketServer, create an instance of KestrelWebSocketServer in BowserRefreshServer and delegate the implementation to it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed this one in: c0f5f7b

{
log($"{AgentEnvironmentVariables.DotNetWatchHotReloadWebSocketEndpoint}={webSocketEndpoint}");
if (!Uri.TryCreate(webSocketEndpoint, UriKind.Absolute, out var uri) ||
(uri.Scheme != "ws" && uri.Scheme != "wss"))
Copy link
Member

Choose a reason for hiding this comment

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

Nit: could be uri.Scheme is not ("ws" or "wss")


public override async Task<string> WaitForConnectionAsync(CancellationToken cancellationToken)
{
#if NET
Copy link
Member

Choose a reason for hiding this comment

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

We can move creation of the pip[e to the constructor and then remove all _pipe != null checks in the type.

await _pipe.WaitForConnectionAsync(cancellationToken);

// When the client connects, the first payload it sends is the initialization payload which includes the apply capabilities.
var capabilities = (await ClientInitializationResponse.ReadAsync(_pipe, cancellationToken)).Capabilities;
Copy link
Member

Choose a reason for hiding this comment

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

I'd return Stream? from this method and moved reading the initialization message to the caller, to avoid leaking the protocol into the transport layer.

Copy link
Member

@tmat tmat Feb 13, 2026

Choose a reason for hiding this comment

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

Actually, can we just create the connection here and then call ReadAsync to read the initial message in the caller instead?


logger.LogDebug("Waiting for application to connect to pipe {NamedPipeName}.", _namedPipeName);

await _pipe.WaitForConnectionAsync(cancellationToken);
Copy link
Member

Choose a reason for hiding this comment

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

I think we need to keep the try-catch around this call. The process may die while we waiting for the connection and the pipe may be disposed.

                catch (Exception e) when (e is not OperationCanceledException)
                {
                    ReportPipeReadException(e, "capabilities", cancellationToken);
                    return null;
                }

applyOperationCancellationToken);
}

private async Task ListenForResponsesAsync(CancellationToken cancellationToken)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Would you mind moving this before GetCapabilitiesTask() method, so that it's easier to see the differences and merge any conflicts?

/// <param name="useTls">Whether to enable HTTPS</param>
/// <param name="cancellationToken">Cancellation token</param>
protected async ValueTask StartServerAsync(string hostName = "localhost", int port = 0, bool useTls = false, CancellationToken cancellationToken = default)
public async ValueTask StartServerAsync(string hostName, int port, bool useTls, CancellationToken cancellationToken)
Copy link
Member

Choose a reason for hiding this comment

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

This needs two ports to avoid collision (ws and wss)

Copy link
Member

Choose a reason for hiding this comment

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

You can replace useTls with int? securePort.

/// <summary>
/// Converts an HTTP(S) URL to a WebSocket URL.
/// </summary>
protected virtual string ConvertToWebSocketUrl(string httpUrl)
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't need to be virtual

/// <summary>
/// Helper to accept a WebSocket connection.
/// </summary>
protected async ValueTask<WebSocket?> AcceptWebSocketAsync(HttpContext context, string? subProtocol = null)
Copy link
Member

Choose a reason for hiding this comment

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

Only called from AgentWebSocketServer.HandleRequestAsync. We can inline it.

/// Handles incoming HTTP requests. Override to implement WebSocket logic.
/// </summary>
protected abstract Task HandleRequestAsync(HttpContext context);
protected virtual Task HandleRequestAsync(HttpContext context)
Copy link
Member

@tmat tmat Feb 13, 2026

Choose a reason for hiding this comment

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

Since this is the only virtual method and it delegates to _requestHandler we can make this class sealed and pass delegate from AgentWebSocketServer (i.e. not inherit AgentWebSocketServer from KestrelWebSocketServer).

Then can potentially also merge AgentWebSocketServer into WebSocketClientTransport

string? decryptedSecret;
try
{
decryptedSecret = _sharedSecretProvider.DecryptSecret(Base64Url.DecodeToStandardBase64(subProtocol));
Copy link
Member

Choose a reason for hiding this comment

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

We're using WebUtility.UrlDecode in AbstractBrowserRefreshServer.OnBrowserConnected to decode the secret

return;
}

if (string.IsNullOrEmpty(decryptedSecret))
Copy link
Member

Choose a reason for hiding this comment

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

We already checked string.IsNullOrEmpty(subProtocol) above, the decrypted secret shouldn't be empty, right?

protected override async Task HandleRequestAsync(HttpContext context)
{
// Validate the shared secret from the subprotocol
if (context.WebSockets.WebSocketRequestedProtocols is not [var subProtocol] || string.IsNullOrEmpty(subProtocol))
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't subProtocol ne null for non-secure connection?

// passed via `dotnet run -e` as @(RuntimeEnvironmentVariable) items.
=> new(new HotReloadClients(new MobileHotReloadClient(clientLogger, agentLogger, context.EnvironmentOptions.HotReloadHttpPort, GetStartupHookPath(project)), browserRefreshServer: null));
=> new(new HotReloadClients(
new DefaultHotReloadClient(clientLogger, agentLogger, GetStartupHookPath(project), enableStaticAssetUpdates: false,
Copy link
Member

@tmat tmat Feb 14, 2026

Choose a reason for hiding this comment

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

enableStaticAssetUpdates should be true, no? Don't we want to send over CSS updates? The same as Windows MAUI app.


App.Start(testAsset, []);

await App.WaitForOutputLineContaining("Started");
Copy link
Member

Choose a reason for hiding this comment

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

We should use App.WaitUntileOutputContains to avoid race conditions between the process output and watch output.

Copy link
Member

Choose a reason for hiding this comment

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

You can use await App.WaitUntileOutputContains instead of App.AssertOutputContains as well, unless you particularly care about the order in which the messages appear.

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.

5 participants