@@ -149,7 +149,7 @@ private async ValueTask Notify(HotReloadEvent evt, HotReloadEventSource source =
149149 {
150150 measurements = new Dictionary < string , double >
151151 {
152- [ "FileCount" ] = _current . FilePaths . Count
152+ [ "FileCount" ] = _current . ConsideredFilePaths . Count
153153 } ;
154154 if ( _current . CompletionTime != null )
155155 {
@@ -256,9 +256,10 @@ void LoadInfos(HotReloadServerOperation? operation)
256256 ? . Where ( d => d . Severity >= DiagnosticSeverity . Warning )
257257 . Select ( d => CSharpDiagnosticFormatter . Instance . Format ( d , CultureInfo . InvariantCulture ) )
258258 . ToImmutableList ( ) ?? ImmutableList < string > . Empty ;
259+ var files = operation . ConsideredFilePaths . Except ( operation . IgnoredFilePaths ) ;
259260
260261 foundCompleting |= operation == completing ;
261- infos . Add ( new ( operation . Id , operation . StartTime , operation . FilePaths , operation . CompletionTime , operation . Result , diagnosticsResult ) ) ;
262+ infos . Add ( new ( operation . Id , operation . StartTime , files , operation . IgnoredFilePaths , operation . CompletionTime , operation . Result , diagnosticsResult ) ) ;
262263 operation = operation . Previous ! ;
263264 }
264265 }
@@ -286,7 +287,8 @@ private class HotReloadServerOperation
286287 private readonly HotReloadServerOperation ? _previous ;
287288 private readonly Timer _timeout ;
288289
289- private ImmutableHashSet < string > _filePaths ;
290+ private ImmutableHashSet < string > _consideredFilePaths ; // All files that have been considered for this operation.
291+ private ImmutableHashSet < string > _ignoredFilePaths = _empty ; // The files that have been ignored by the compilator for this operation (basically because they are not part of the solution).
290292 private int /* HotReloadResult */ _result = - 1 ;
291293 private CancellationTokenSource ? _deferredCompletion ;
292294 private ImmutableArray < Diagnostic > ? _diagnostics ;
@@ -304,7 +306,19 @@ private class HotReloadServerOperation
304306
305307 public HotReloadServerOperation ? Previous => _previous ;
306308
307- public ImmutableHashSet < string > FilePaths => _filePaths ;
309+ /// <summary>
310+ /// List of all file paths that have been considered for this hot-reload operation.
311+ /// </summary>
312+ /// <remarks>This **includes** the <see cref="IgnoredFilePaths"/>.</remarks>
313+ public ImmutableHashSet < string > ConsideredFilePaths => _consideredFilePaths ;
314+
315+ /// <summary>
316+ /// Gets the collection of file paths that are excluded from processing.
317+ /// </summary>
318+ /// <remarks>
319+ /// Files are typically ignored when they do not yet exist in the current solution.
320+ /// </remarks>
321+ public ImmutableHashSet < string > IgnoredFilePaths => _ignoredFilePaths ;
308322
309323 public ImmutableArray < Diagnostic > ? Diagnostics => _diagnostics ;
310324
@@ -315,7 +329,7 @@ public HotReloadServerOperation(ServerHotReloadProcessor owner, HotReloadServerO
315329 {
316330 _owner = owner ;
317331 _previous = previous ;
318- _filePaths = filePaths ?? _empty ;
332+ _consideredFilePaths = filePaths ?? _empty ;
319333
320334 _timeout = new Timer (
321335 static that => _ = ( ( HotReloadServerOperation ) that ! ) . Complete ( HotReloadServerResult . Aborted ) ,
@@ -325,7 +339,7 @@ public HotReloadServerOperation(ServerHotReloadProcessor owner, HotReloadServerO
325339 }
326340
327341 /// <summary>
328- /// Attempts to update the <see cref="FilePaths "/> if we determine that the provided paths are corresponding to this operation.
342+ /// Attempts to update the <see cref="ConsideredFilePaths "/> if we determine that the provided paths are corresponding to this operation.
329343 /// </summary>
330344 /// <returns>
331345 /// True if this operation should be considered as valid for the given file paths (and has been merged with original paths),
@@ -338,7 +352,7 @@ public bool TryMerge(ImmutableHashSet<string> filePaths)
338352 return false ;
339353 }
340354
341- var original = _filePaths ;
355+ var original = _consideredFilePaths ;
342356 while ( true )
343357 {
344358 ImmutableHashSet < string > updated ;
@@ -355,7 +369,7 @@ public bool TryMerge(ImmutableHashSet<string> filePaths)
355369 return false ;
356370 }
357371
358- var current = Interlocked . CompareExchange ( ref _filePaths , updated , original ) ;
372+ var current = Interlocked . CompareExchange ( ref _consideredFilePaths , updated , original ) ;
359373 if ( current == original )
360374 {
361375 _timeout . Change ( _timeoutDelay , Timeout . InfiniteTimeSpan ) ;
@@ -377,6 +391,13 @@ public void EnableAutoRetryIfNoChanges(int? attempts, TimeSpan? delay)
377391 _noChangesRetryDelay = delay ?? DefaultAutoRetryIfNoChangesDelay ;
378392 }
379393
394+ /// <summary>
395+ /// Notifies a file has been ignored for this hot-reload operation.
396+ /// </summary>
397+ /// <param name="file"></param>
398+ public void NotifyIgnored ( string file )
399+ => ImmutableInterlocked . Update ( ref _ignoredFilePaths , static ( files , file ) => files . Add ( file ) , file ) ;
400+
380401 /// <summary>
381402 /// As errors might get a bit after the complete from the IDE, we can defer the completion of the operation.
382403 /// </summary>
0 commit comments