Conversation
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.
|
This pull request is merged. |
[Medium impact] The PR appears safe to merge; no new blocking issues were found.
|
Test Results 80 files ± 0 80 suites ±0 1h 37m 3s ⏱️ + 1m 6s 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.This pull request removes 4662 skipped tests and adds 4662 skipped tests. Note that renamed tests count towards both. |
|
|
This is addressed in release v8.1.2. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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.