Skip to content

Commit

Permalink
Merge pull request #19528 from unoplatform/dev/dr/hrBinObj
Browse files Browse the repository at this point in the history
fix(hr): Ignore bin and obj folders
  • Loading branch information
dr1rrb authored Feb 19, 2025
2 parents 2bdff12 + 2ac2b11 commit 7f303c1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public class RemoteControlGenerator : ISourceGenerator
"MSBuildVersion",
"UnoHotReloadDiagnosticsLogPath",
"AppendRuntimeIdentifierToOutputPath",
"OutputPath"
"OutputPath",
"IntermediateOutputPath"
};

public void Initialize(GeneratorInitializationContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ namespace Uno.UI.RemoteControl.Host.HotReload
{
partial class ServerHotReloadProcessor : IServerProcessor, IDisposable
{
private static readonly StringComparer _pathsComparer = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal;
private static readonly StringComparer _pathsComparer = OperatingSystem.IsWindows() ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal;
private static readonly StringComparison _pathsComparison = OperatingSystem.IsWindows() ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;

private FileSystemWatcher[]? _solutionWatchers;
private IDisposable? _solutionWatcherEventsDisposable;
Expand Down Expand Up @@ -96,6 +97,7 @@ private void InitializeInner(ConfigureServer configureServer)
&& bool.TryParse(appendStr, out var append)
&& append;
var hasOutputPath = properties.Remove("OutputPath", out var outputPath);
properties.Remove("IntermediateOutputPath", out var intermediateOutputPath);

if (properties.Remove("RuntimeIdentifier", out var runtimeIdentifier))
{
Expand All @@ -116,7 +118,7 @@ private void InitializeInner(ConfigureServer configureServer)
properties,
CancellationToken.None);

ObserveSolutionPaths(result.Item1);
ObserveSolutionPaths(result.Item1, intermediateOutputPath, outputPath);

await _remoteControlServer.SendFrame(new HotReloadWorkspaceLoadResult { WorkspaceInitialized = true });
await Notify(HotReloadEvent.Ready);
Expand All @@ -136,16 +138,26 @@ private void InitializeInner(ConfigureServer configureServer)
CancellationToken.None);
}

private void ObserveSolutionPaths(Solution solution)
private void ObserveSolutionPaths(Solution solution, params string?[] excludedDir)
{
var observedPaths =
solution.Projects
.SelectMany(p => p
.Documents
.Select(d => d.FilePath)
.Concat(p.AdditionalDocuments
.Select(d => d.FilePath)))
.Select(Path.GetDirectoryName)
.SelectMany(project =>
{
var projectDir = Path.GetDirectoryName(project.FilePath);
ImmutableArray<string> excludedProjectDir = [.. from dir in excludedDir where dir is not null select Path.Combine(projectDir!, dir).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)];

var paths = project
.Documents
.Select(d => d.FilePath)
.Concat(project.AdditionalDocuments.Select(d => d.FilePath))
.Select(Path.GetDirectoryName)
.Where(path => path is not null && !excludedProjectDir.Any(dir => path.StartsWith(dir, _pathsComparison)))
.Distinct()
.ToArray();

return paths;
})
.Distinct()
.ToArray();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private string[] GetCuratedTypes()
{
return Types
.Select(GetFriendlyName)
.Where(name => name is { Length: > 0 })
.Where(name => name is { Length: > 0 } and not "HotReloadException")
.Distinct()
.ToArray()!;

Expand Down

0 comments on commit 7f303c1

Please sign in to comment.