feat: add OnTriggeredOrReplay method to replay watcher-triggered notifications#1014
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds watcher-specific change descriptions and replay support for watcher-triggered notifications in the mock file system notification pipeline.
Changes:
- Introduces
WatcherChangeDescriptionwith the emitting watcher instance. - Adds watcher-triggered replay/history handling in
ChangeHandler. - Updates tests and API baselines for the new watcher notification API.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
Source/Testably.Abstractions.Testing/FileSystem/WatcherChangeDescription.cs |
Adds watcher-aware change description type. |
Source/Testably.Abstractions.Testing/FileSystem/IWatcherTriggeredHandler.cs |
Updates watcher notification API and adds replay method. |
Source/Testably.Abstractions.Testing/FileSystem/ChangeHandler.cs |
Implements watcher-triggered history and replay. |
Source/Testably.Abstractions.Testing/FileSystem/FileSystemWatcherMock.cs |
Passes emitting watcher into watcher-triggered notifications. |
Source/Testably.Abstractions.Testing/FileSystem/ChangeDescription.cs |
Adds copy constructor for watcher descriptions. |
Source/Testably.Abstractions.Testing/MockFileSystem.cs |
Updates option documentation for watcher history. |
Tests/Testably.Abstractions.Testing.Tests/FileSystem/ChangeHandlerTests.cs |
Adds watcher replay tests and updates callback types. |
Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Testing_netstandard2.0.txt |
Updates API baseline. |
Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Testing_netstandard2.1.txt |
Updates API baseline. |
Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Testing_net6.0.txt |
Updates API baseline. |
Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Testing_net8.0.txt |
Updates API baseline. |
Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Testing_net9.0.txt |
Updates API baseline. |
Tests/Api/Testably.Abstractions.Api.Tests/Expected/Testably.Abstractions.Testing_net10.0.txt |
Updates API baseline. |
Comments suppressed due to low confidence (1)
Source/Testably.Abstractions.Testing/FileSystem/IWatcherTriggeredHandler.cs:45
- Adding
OnTriggeredOrReplaydirectly to the public interface is also a breaking change for any external implementations ofIWatcherTriggeredHandler, because they must now implement the new member. Consider adding this as an extension method backed by an internal capability, or introducing a separate derived interface, so existing implementers remain compatible.
IAwaitableCallback<WatcherChangeDescription> OnTriggeredOrReplay(
Action<WatcherChangeDescription>? triggerCallback = null,
Func<WatcherChangeDescription, bool>? predicate = null);
|
|
This is addressed in release v6.4.0. |
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.



This pull request introduces a new
WatcherChangeDescriptionclass to provide richer context for watcher-triggered file system notifications, and updates the watcher notification APIs to use this new type. It also adds support for replaying watcher-triggered notifications to newly registered callbacks, similar to the existing notification replay mechanism. The changes ensure that consumers can filter or replay notifications by watcher instance and that notification history can be enabled or disabled for both standard and watcher-triggered events.Watcher notification enhancements:
WatcherChangeDescriptionclass, which extendsChangeDescriptionand includes a reference to the emittingIFileSystemWatcher, allowing consumers to filter notifications by watcher instance.IWatcherTriggeredHandlerinterface and related APIs to useWatcherChangeDescriptioninstead ofChangeDescription, and added a newOnTriggeredOrReplaymethod to allow callbacks to receive both past and future watcher-triggered notifications.ChangeHandler, including thread-safety improvements and opt-out support.Notification history configuration:
MockFileSystemOptionsand related documentation to clarify that notification history now applies to both standard and watcher-triggered streams, and that disabling history affects both.Internal improvements:
ChangeDescriptionto support the newWatcherChangeDescriptiontype.FileSystemWatcherMockto use the new watcher-triggered notification API.