Skip to content

Commit b2ba6b6

Browse files
authored
Merge pull request #21853 from unoplatform/mergify/bp/release/stable/6.4/pr-21829
fix: Make sure to not show temp files in HRI when doing HR with agent (backport #21829)
2 parents ed0cb71 + 0027bd2 commit b2ba6b6

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

src/Uno.UI.RemoteControl.Server.Processors/HotReload/ServerHotReloadProcessor.MetadataUpdate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ private async ValueTask ProcessSolutionChanged(HotReloadServerOperation hotReloa
246246
else
247247
{
248248
_reporter.Verbose($"Could not find document with path {file} in the workspace.");
249+
hotReload.NotifyIgnored(file);
249250
}
250251
}
251252

@@ -270,7 +271,6 @@ private async ValueTask ProcessSolutionChanged(HotReloadServerOperation hotReloa
270271
_reporter.Output($"Found {updates.Length} metadata updates after {sw.Elapsed}");
271272
sw.Stop();
272273

273-
274274
if (rudeEdits.IsEmpty && updates.IsEmpty)
275275
{
276276
var compilationErrors = GetCompilationErrors(solution, ct);

src/Uno.UI.RemoteControl.Server.Processors/HotReload/ServerHotReloadProcessor.cs

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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>

src/Uno.UI.RemoteControl/HotReload/Messages/HotReloadStatusMessage.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public record HotReloadServerOperationData(
3535
long Id,
3636
DateTimeOffset StartTime,
3737
ImmutableHashSet<string> FilePaths,
38+
ImmutableHashSet<string>? IgnoredFilePaths,
3839
DateTimeOffset? EndTime,
3940
HotReloadServerResult? Result,
4041
IImmutableList<string>? Diagnostics);

0 commit comments

Comments
 (0)