-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for hot reload to hosted BlazorWasm apps
* Fix a bug where deltas where being sent in the wrong format to BlazorWASM * Allow recovering from compilation errors in a BlazorWASM app. Fixes dotnet/aspnetcore#30815
- Loading branch information
Showing
5 changed files
with
84 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/BuiltInTools/dotnet-watch/HotReload/BlazorWebAssemblyHostedDeltaApplier.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis.ExternalAccess.Watch.Api; | ||
using Microsoft.Extensions.Tools.Internal; | ||
|
||
namespace Microsoft.DotNet.Watcher.Tools | ||
{ | ||
internal class BlazorWebAssemblyHostedDeltaApplier : IDeltaApplier | ||
{ | ||
private readonly BlazorWebAssemblyDeltaApplier _wasmApplier; | ||
private readonly AspNetCoreDeltaApplier _hostApplier; | ||
|
||
public BlazorWebAssemblyHostedDeltaApplier(IReporter reporter) | ||
{ | ||
_wasmApplier = new BlazorWebAssemblyDeltaApplier(reporter); | ||
_hostApplier = new AspNetCoreDeltaApplier(reporter) | ||
{ | ||
SuppressBrowserRefreshAfterApply = true, | ||
}; | ||
} | ||
|
||
public async ValueTask InitializeAsync(DotNetWatchContext context, CancellationToken cancellationToken) | ||
{ | ||
await _wasmApplier.InitializeAsync(context, cancellationToken); | ||
await _hostApplier.InitializeAsync(context, cancellationToken); | ||
} | ||
|
||
public async ValueTask<bool> Apply(DotNetWatchContext context, string changedFile, ImmutableArray<WatchHotReloadService.Update> solutionUpdate, CancellationToken cancellationToken) | ||
{ | ||
return await _hostApplier.Apply(context, changedFile, solutionUpdate, cancellationToken) && | ||
await _wasmApplier.Apply(context, changedFile, solutionUpdate, cancellationToken); | ||
} | ||
|
||
public async ValueTask ReportDiagnosticsAsync(DotNetWatchContext context, IEnumerable<string> diagnostics, CancellationToken cancellationToken) | ||
{ | ||
// Both WASM and Host have similar implementations for diagnostics. We could pick either to report diagnostics. | ||
await _hostApplier.ReportDiagnosticsAsync(context, diagnostics, cancellationToken); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_hostApplier.Dispose(); | ||
_wasmApplier.Dispose(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters