@@ -74,7 +74,7 @@ public async ValueTask TerminateNonRootProcessesAndDispose(CancellationToken can
7474 Dispose ( ) ;
7575 }
7676
77- public ValueTask RestartSessionAsync ( ImmutableDictionary < ProjectId , string > projectsToBeRebuilt , CancellationToken cancellationToken )
77+ public void UpdateProjectBaselines ( ImmutableDictionary < ProjectId , string > projectsToBeRebuilt , CancellationToken cancellationToken )
7878 {
7979 // Remove previous updates to all modules that were affected by rude edits.
8080 // All running projects that statically reference these modules have been terminated.
@@ -87,9 +87,8 @@ public ValueTask RestartSessionAsync(ImmutableDictionary<ProjectId, string> proj
8787 _previousUpdates = _previousUpdates . RemoveAll ( update => projectsToBeRebuilt . ContainsKey ( update . ProjectId ) ) ;
8888 }
8989
90- _hotReloadService . EndSession ( ) ;
91- _reporter . Report ( MessageDescriptor . HotReloadSessionEnded ) ;
92- return StartSessionAsync ( cancellationToken ) ;
90+ _hotReloadService . UpdateBaselines ( Workspace . CurrentSolution , projectsToBeRebuilt . Keys . ToImmutableArray ( ) ) ;
91+ _reporter . Report ( MessageDescriptor . ProjectBaselinesUpdates ) ;
9392 }
9493
9594 public async ValueTask StartSessionAsync ( CancellationToken cancellationToken )
@@ -277,14 +276,19 @@ private static void PrepareCompilations(Solution solution, string projectPath, C
277276 }
278277
279278 public async ValueTask < ( ImmutableDictionary < ProjectId , string > projectsToRebuild , ImmutableArray < RunningProject > terminatedProjects ) > HandleFileChangesAsync (
280- Func < IEnumerable < Project > , CancellationToken , Task > restartPrompt ,
279+ Func < IEnumerable < string > , CancellationToken , Task > restartPrompt ,
281280 CancellationToken cancellationToken )
282281 {
283282 var currentSolution = Workspace . CurrentSolution ;
284283 var runningProjects = _runningProjects ;
285284
286- var updates = await _hotReloadService . GetUpdatesAsync ( currentSolution , isRunningProject : p => runningProjects . ContainsKey ( p . FilePath ! ) , cancellationToken ) ;
287- var anyProcessNeedsRestart = updates . ProjectsToRestart . Count > 0 ;
285+ var runningProjectIds = currentSolution . Projects
286+ . Where ( project => project . FilePath != null && runningProjects . ContainsKey ( project . FilePath ) )
287+ . Select ( project => project . Id )
288+ . ToImmutableHashSet ( ) ;
289+
290+ var updates = await _hotReloadService . GetUpdatesAsync ( currentSolution , runningProjectIds , cancellationToken ) ;
291+ var anyProcessNeedsRestart = ! updates . ProjectIdsToRestart . IsEmpty ;
288292
289293 await DisplayResultsAsync ( updates , cancellationToken ) ;
290294
@@ -302,13 +306,13 @@ private static void PrepareCompilations(Solution solution, string projectPath, C
302306 return ( ImmutableDictionary < ProjectId , string > . Empty , [ ] ) ;
303307 }
304308
305- await restartPrompt . Invoke ( updates . ProjectsToRestart , cancellationToken ) ;
309+ await restartPrompt . Invoke ( updates . ProjectIdsToRestart . Select ( id => currentSolution . GetProject ( id ) ! . Name ) , cancellationToken ) ;
306310
307311 // Terminate all tracked processes that need to be restarted,
308312 // except for the root process, which will terminate later on.
309- var terminatedProjects = await TerminateNonRootProcessesAsync ( updates . ProjectsToRestart . Select ( p => p . FilePath ! ) , cancellationToken ) ;
313+ var terminatedProjects = await TerminateNonRootProcessesAsync ( updates . ProjectIdsToRestart . Select ( id => currentSolution . GetProject ( id ) ! . FilePath ! ) , cancellationToken ) ;
310314
311- return ( updates . ProjectsToRebuild . ToImmutableDictionary ( keySelector : p => p . Id , elementSelector : p => p . FilePath ! ) , terminatedProjects ) ;
315+ return ( updates . ProjectIdsToRebuild . ToImmutableDictionary ( keySelector : id => id , elementSelector : id => currentSolution . GetProject ( id ) ! . FilePath ! ) , terminatedProjects ) ;
312316 }
313317
314318 Debug . Assert ( updates . Status == ModuleUpdateStatus . Ready ) ;
@@ -353,7 +357,7 @@ await ForEachProjectAsync(projectsToUpdate, async (runningProject, cancellationT
353357
354358 private async ValueTask DisplayResultsAsync ( WatchHotReloadService . Updates updates , CancellationToken cancellationToken )
355359 {
356- var anyProcessNeedsRestart = updates . ProjectsToRestart . Count > 0 ;
360+ var anyProcessNeedsRestart = ! updates . ProjectIdsToRestart . IsEmpty ;
357361
358362 switch ( updates . Status )
359363 {
0 commit comments