Skip to content

Commit 0406cf9

Browse files
committed
Fix reporting rude edits
1 parent 2614f5b commit 0406cf9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/BuiltInTools/dotnet-watch/HotReload/CompilationHandler.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,13 @@ void ReportRudeEdits()
416416
// Rude edits in projects that caused restart of a project that can be restarted automatically
417417
// will be reported only as verbose output.
418418
var projectsRestartedDueToRudeEdits = updates.ProjectsToRestart
419-
.Where(e => runningProjectInfos.TryGetValue(e.Key, out var info) && info.RestartWhenChangesHaveNoEffect)
419+
.Where(e => IsAutoRestartEnabled(e.Key))
420420
.SelectMany(e => e.Value)
421421
.ToHashSet();
422422

423-
var projectsRebuiltDueToRudeEdits = updates.ProjectsToRebuild.ToHashSet();
423+
var projectsRebuiltDueToRudeEdits = updates.ProjectsToRebuild
424+
.Where(IsAutoRestartEnabled)
425+
.ToHashSet();
424426

425427
foreach (var (projectId, diagnostics) in updates.RudeEdits)
426428
{
@@ -437,6 +439,9 @@ void ReportRudeEdits()
437439
}
438440
}
439441

442+
bool IsAutoRestartEnabled(ProjectId id)
443+
=> runningProjectInfos.TryGetValue(id, out var info) && info.RestartWhenChangesHaveNoEffect;
444+
440445
void ReportDiagnostic(Diagnostic diagnostic, MessageDescriptor descriptor, string prefix = "")
441446
{
442447
var display = CSharpDiagnosticFormatter.Instance.Format(diagnostic);

test/dotnet-watch.Tests/HotReload/ApplyDeltaTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ public async Task Aspire()
760760
await App.AssertOutputLineStartsWith(" ❔ Do you want to restart these projects? Yes (y) / No (n) / Always (a) / Never (v)");
761761

762762
App.AssertOutputContains("dotnet watch ⌚ Restart is needed to apply the changes.");
763-
App.AssertOutputContains("error ENC0020: Renaming record 'WeatherForecast' requires restarting the application.");
763+
App.AssertOutputContains($"dotnet watch ❌ {serviceSourcePath}(36,1): error ENC0020: Renaming record 'WeatherForecast' requires restarting the application.");
764764
App.AssertOutputContains("dotnet watch ⌚ Affected projects:");
765765
App.AssertOutputContains("dotnet watch ⌚ WatchAspire.ApiService");
766766
App.Process.ClearOutput();

0 commit comments

Comments
 (0)