Registry Mirror
Skip to content

Conversation

@vbreuss

@vbreuss vbreuss commented Nov 28, 2026

Copy link
Copy Markdown
Member

The FileSystemWatcherMock wrote every change into its bounded channel (sized from InternalBufferSize) and applied NotifyFilter only at delivery, so changes the NotifyFilter excludes still filled the buffer and raised InternalBufferOverflowException errors while a handler was slow. The real Windows watcher passes NotifyFilter to ReadDirectoryChangesW, so excluded changes never reach its buffer: with a blocked handler, NotifyFilter = DirectoryName and 100 file writes, the real watcher reports no error while the mock reported 268.

The watcher now registers its Notify.OnEvent callback with a predicate that drops changes not matching NotifyFilter before they are written to the channel. The predicate runs on the thread performing the file operation, so it reads a volatile backing field instead of the NotifyFilter property, which avoids a statistics entry per file operation and is safe against concurrent changes. The existing check at delivery stays, so buffered changes are still re-checked when NotifyFilter changes afterwards. Filter/Filters name patterns still count against the buffer, as on the real watchers, which apply them in managed code.

As a side effect, WaitForChanged no longer completes on changes excluded by NotifyFilter, which matches the real watcher, whose WaitForChanged listens to the public events.

The FileSystemWatcherMock wrote every change into its bounded channel (sized from InternalBufferSize) and applied NotifyFilter only at delivery, so changes the NotifyFilter excludes still filled the buffer and raised InternalBufferOverflowException errors while a handler was slow. The real Windows watcher passes NotifyFilter to ReadDirectoryChangesW, so excluded changes never reach its buffer: with a blocked handler, NotifyFilter = DirectoryName and 100 file writes, the real watcher reports no error while the mock reported 268.

The watcher now registers its Notify.OnEvent callback with a predicate that drops changes not matching NotifyFilter before they are written to the channel. The predicate runs on the thread performing the file operation, so it reads a volatile backing field instead of the NotifyFilter property, which avoids a statistics entry per file operation and is safe against concurrent changes. The existing check at delivery stays, so buffered changes are still re-checked when NotifyFilter changes afterwards. Filter/Filters name patterns still count against the buffer, as on the real watchers, which apply them in managed code.

As a side effect, WaitForChanged no longer completes on changes excluded by NotifyFilter, which matches the real watcher, whose WaitForChanged listens to the public events.
@vbreuss vbreuss self-assigned this Nov 28, 2026
@vbreuss vbreuss added the bug Something isn't working label Nov 28, 2026
@mergify

mergify Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

This pull request is merged.

@greptile-apps

greptile-apps Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge; no new blocking issues were found.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issues were found.

Summary

FileSystemWatcherMock now drops changes excluded by NotifyFilter before they enter its bounded buffer.

  • Mock watchers skip excluded changes before they enter the buffer.

Reviews (2) · Last reviewed commit: "test: compare event names with string.Eq..." · Reviewed by Greptile

@github-actions

Copy link
Copy Markdown

Test Results

     80 files  ± 0       80 suites  ±0   1h 37m 3s ⏱️ + 1m 6s
 88 374 tests + 5   83 684 ✅ + 5   4 690 💤 ±0  0 ❌ ±0 
204 532 runs  +62  184 810 ✅ +62  19 722 💤 ±0  0 ❌ ±0 

Results for commit 7cbc870. ± Comparison against base commit 28e715b.

This pull request removes 85010 and adds 85014 tests. Note that renamed tests count towards both.
  )
)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(04671d63-8dfd-4e4b-9b27-152ed86bb7c8)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(0a0f8d07-0421-465d-9f68-4f2e89fb7a4a)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(113a7738-93c8-43be-bd37-5499628a86a1)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(1876f60f-ee5d-4efe-b907-5465e20772b1)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(1dcea029-27ef-416f-a197-f7172fa860fd)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(1f6d9dd3-b301-44b7-a76d-1237dbd1891c)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(2ddc5f1f-ad5d-4bac-a197-626a66a8027d)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(55f452bf-77ff-4b74-92ed-f0ec03a5d45e)
…
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(1791a410-9c23-4c8b-8805-d9ea361fde8a)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(1820ef06-71f0-413f-aba6-6db437aaf868)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(1f4f96d3-3b48-4f56-bae1-7d03118d9a4d)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(2493525f-1bc3-4322-8e30-c178046d2461)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(2ba63ce2-5f23-4e25-9553-ecf1d89c5397)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(34f9675b-f8a8-4b03-98e9-0b45cea58753)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(39fe34f2-2fe2-460a-b4d6-fd870fe9d601)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(3f2c150a-afc7-4497-b3d2-d7951eba7ca2)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(433408d7-2c57-4795-bfe4-14c6881b2601)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(48131a65-c935-4988-9267-e687275d08d8)
…
This pull request removes 4662 skipped tests and adds 4662 skipped tests. Note that renamed tests count towards both.
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(00f5f45f-b8d4-42c1-bab6-4331c069bb2b)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(0c5e7d15-1057-4ddd-b903-4d361f26a948)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(20c51972-1886-4f61-b1b4-c3b8c01a5a71)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(5b3d3fff-08c1-40e5-bea8-e87c264a80c1)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(6eb77bc8-690d-4f10-acba-899817a4d1a0)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(700f1daf-fc1e-4667-8ce4-b6561d906933)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(a030cb01-3e2e-41c0-bb8d-24edfbfd9215)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(f68bcee3-7687-4578-9516-cf18760dedd8)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ SetUnixFileMode_SafeFileHandle_ShouldUpdateValue(47377c32-bd09-4d7a-8e2b-4972f95a6f76, None)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ SetUnixFileMode_SafeFileHandle_ShouldUpdateValue(72c7703d-eec7-4fdd-bb92-b1280144acb1, None)
…
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(054b90b3-ed44-4f69-a17a-748d67bd1f84)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(0e3b1f6f-fa35-40d8-9d14-0183aa7f56c7)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(1d5cedee-583d-4ae7-be26-4e972ec942b6)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(42838ba2-aa83-4da1-a82e-ee8105f8fe79)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(4ae0a49b-d3c4-4c49-b739-6cd583b4e956)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(ac7b8b43-a6bf-45ce-9f3b-1d2d689ef56e)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(ceecc14c-7671-4c32-a9ab-171b79590331)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(ef2fdb32-b93f-4596-b3f9-89dbd9a43f3b)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ SetUnixFileMode_SafeFileHandle_ShouldUpdateValue(4295d4c7-e1b9-43c9-b244-d773bb3fef26, None)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ SetUnixFileMode_SafeFileHandle_ShouldUpdateValue(49ad02ee-ed10-4060-9104-5a8731030791, None)
…

@sonarqubecloud

Copy link
Copy Markdown

@vbreuss
vbreuss merged commit 5a44d41 into main Nov 28, 2026
16 checks passed
@vbreuss
vbreuss deleted the fix/watcher-notifyfilter-buffer branch November 28, 2026 10:48
@github-actions

Copy link
Copy Markdown

This is addressed in release v8.1.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working state: released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant