From 91901cdff21cccea20fb8f73d0bac49845f10d7c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 21:30:41 +0000 Subject: [PATCH 1/4] Initial plan From ba745c2bd1fbed9da791004a5e5d54af06dcfa5b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 22:01:46 +0000 Subject: [PATCH 2/4] Fix flaky FileSystemWatcher_SymbolicLink_TargetsDirectory_Create_IncludeSubdirectories test Add expectedPath filter to ExpectNoEvent call so spurious Create events from setup (e.g. subDir created just before the FSEvents stream started) do not cause false test failures on macOS. Change [ActiveIssue] to be OSX-specific since the root cause is macOS FSEvents delivering late events near the kFSEventStreamEventIdSinceNow boundary, and the test now runs cleanly on Linux/Windows. Co-authored-by: danmoseley <6385855+danmoseley@users.noreply.github.com> --- .../tests/FileSystemWatcher.SymbolicLink.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.SymbolicLink.cs b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.SymbolicLink.cs index 9e7055aba1856f..8f5e05790cc852 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.SymbolicLink.cs +++ b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.SymbolicLink.cs @@ -79,7 +79,7 @@ public void FileSystemWatcher_SymbolicLink_TargetsDirectory_Create() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/124847")] + [ActiveIssue("https://github.com/dotnet/runtime/issues/124847", TestPlatforms.OSX)] public void FileSystemWatcher_SymbolicLink_TargetsDirectory_Create_IncludeSubdirectories() { FileSystemWatcherTest.Execute(() => @@ -97,9 +97,12 @@ public void FileSystemWatcher_SymbolicLink_TargetsDirectory_Create_IncludeSubdir string subDirLv2Path = Path.Combine(tempSubDir, subDirLv2); // Act - Assert + // Only check for events at the specific nested path; spurious events at other paths (e.g. from + // directory setup) should not cause the test to fail. ExpectNoEvent(watcher, WatcherChangeTypes.Created, action: () => Directory.CreateDirectory(subDirLv2Path), - cleanup: () => Directory.Delete(subDirLv2Path)); + cleanup: () => Directory.Delete(subDirLv2Path), + expectedPath: Path.Combine(linkPath, subDir, subDirLv2)); // Turn include subdirectories on. watcher.IncludeSubdirectories = true; From c62ed9bc264f0f206d92bc4140c785ab5c396268 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Mar 2026 01:09:22 +0000 Subject: [PATCH 3/4] Remove [ActiveIssue] attribute from SymbolicLink_TargetsDirectory_Create_IncludeSubdirectories test The expectedPath fix makes the test robust enough to run on all platforms. Co-authored-by: danmoseley <6385855+danmoseley@users.noreply.github.com> --- .../tests/FileSystemWatcher.SymbolicLink.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.SymbolicLink.cs b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.SymbolicLink.cs index 8f5e05790cc852..ae62b75253d97a 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.SymbolicLink.cs +++ b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.SymbolicLink.cs @@ -79,7 +79,6 @@ public void FileSystemWatcher_SymbolicLink_TargetsDirectory_Create() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/124847", TestPlatforms.OSX)] public void FileSystemWatcher_SymbolicLink_TargetsDirectory_Create_IncludeSubdirectories() { FileSystemWatcherTest.Execute(() => From 483c78c1960bf6a1351c492df482ad91c3643ac6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Mar 2026 01:14:18 +0000 Subject: [PATCH 4/4] Add inline comments explaining path variables in SymbolicLink test Co-authored-by: danmoseley <6385855+danmoseley@users.noreply.github.com> --- .../tests/FileSystemWatcher.SymbolicLink.cs | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.SymbolicLink.cs b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.SymbolicLink.cs index ae62b75253d97a..a0874f6b3afdb7 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.SymbolicLink.cs +++ b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.SymbolicLink.cs @@ -84,24 +84,32 @@ public void FileSystemWatcher_SymbolicLink_TargetsDirectory_Create_IncludeSubdir FileSystemWatcherTest.Execute(() => { // Arrange + // Layout on disk: + // tempDir/ <- real directory + // tempDir/subDir/ <- tempSubDir (real path) + // linkPath -> tempDir <- symbolic link watched by FileSystemWatcher + // + // Paths used in assertions are expressed via the link so that they match + // the paths the watcher reports (e.g. linkPath/subDir/subDirLv2). const string subDir = "subDir"; const string subDirLv2 = "subDirLv2"; string tempDir = GetTestFilePath(); - string tempSubDir = CreateTestDirectory(tempDir, subDir); + string tempSubDir = CreateTestDirectory(tempDir, subDir); // tempDir/subDir/ - string linkPath = CreateSymbolicLinkToTarget(tempDir, isDirectory: true); + string linkPath = CreateSymbolicLinkToTarget(tempDir, isDirectory: true); // linkPath -> tempDir using var watcher = new FileSystemWatcher(linkPath); watcher.NotifyFilter = NotifyFilters.DirectoryName; - string subDirLv2Path = Path.Combine(tempSubDir, subDirLv2); + string subDirLv2Path = Path.Combine(tempSubDir, subDirLv2); // tempDir/subDir/subDirLv2 (real path for I/O) // Act - Assert - // Only check for events at the specific nested path; spurious events at other paths (e.g. from - // directory setup) should not cause the test to fail. + // Only check for events at the specific nested path (linkPath/subDir/subDirLv2); + // spurious events at other paths (e.g. linkPath/subDir from directory setup) should + // not cause the test to fail. ExpectNoEvent(watcher, WatcherChangeTypes.Created, action: () => Directory.CreateDirectory(subDirLv2Path), cleanup: () => Directory.Delete(subDirLv2Path), - expectedPath: Path.Combine(linkPath, subDir, subDirLv2)); + expectedPath: Path.Combine(linkPath, subDir, subDirLv2)); // linkPath/subDir/subDirLv2 // Turn include subdirectories on. watcher.IncludeSubdirectories = true; @@ -109,7 +117,7 @@ public void FileSystemWatcher_SymbolicLink_TargetsDirectory_Create_IncludeSubdir ExpectEvent(watcher, WatcherChangeTypes.Created, action: () => Directory.CreateDirectory(subDirLv2Path), cleanup: () => Directory.Delete(subDirLv2Path), - expectedPath: Path.Combine(linkPath, subDir, subDirLv2)); + expectedPath: Path.Combine(linkPath, subDir, subDirLv2)); // linkPath/subDir/subDirLv2 }, maxAttempts: DefaultAttemptsForExpectedEvent, backoffFunc: (iteration) => RetryDelayMilliseconds, retryWhen: e => e is XunitException); }