Skip to content

Commit d031a8f

Browse files
authored
[dotnet-watch] Remove excess logging that slows down Hot Reload (#51220)
1 parent 4b0a7a1 commit d031a8f

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,23 @@ public async ValueTask StartSessionAsync(CancellationToken cancellationToken)
7777
{
7878
_logger.Log(MessageDescriptor.HotReloadSessionStarting);
7979

80-
await _hotReloadService.StartSessionAsync(Workspace.CurrentSolution, cancellationToken);
80+
var solution = Workspace.CurrentSolution;
81+
82+
await _hotReloadService.StartSessionAsync(solution, cancellationToken);
83+
84+
// TODO: StartSessionAsync should do this: https://github.com/dotnet/roslyn/issues/80687
85+
foreach (var project in solution.Projects)
86+
{
87+
foreach (var document in project.AdditionalDocuments)
88+
{
89+
await document.GetTextAsync(cancellationToken);
90+
}
91+
92+
foreach (var document in project.AnalyzerConfigDocuments)
93+
{
94+
await document.GetTextAsync(cancellationToken);
95+
}
96+
}
8197

8298
_logger.Log(MessageDescriptor.HotReloadSessionStarted);
8399
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ private static async ValueTask<SourceText> GetSourceTextAsync(string filePath, E
219219

220220
public async Task ReportSolutionFilesAsync(Solution solution, CancellationToken cancellationToken)
221221
{
222+
#if DEBUG
222223
_logger.LogDebug("Solution: {Path}", solution.FilePath);
223224
foreach (var project in solution.Projects)
224225
{
@@ -245,5 +246,8 @@ async ValueTask InspectDocumentAsync(TextDocument document, string kind)
245246
var text = await document.GetTextAsync(cancellationToken);
246247
_logger.LogDebug(" {Kind}: {FilePath} [{Checksum}]", kind, document.FilePath, Convert.ToBase64String(text.GetChecksum().ToArray()));
247248
}
249+
#else
250+
await Task.CompletedTask;
251+
#endif
248252
}
249253
}

0 commit comments

Comments
 (0)