Skip to content

feat: add OnTriggeredOrReplay method to replay watcher-triggered notifications#1014

Merged
vbreuss merged 1 commit into
mainfrom
feat/notification-history-replay
May 17, 2026
Merged

feat: add OnTriggeredOrReplay method to replay watcher-triggered notifications#1014
vbreuss merged 1 commit into
mainfrom
feat/notification-history-replay

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented May 17, 2026

This pull request introduces a new WatcherChangeDescription class 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:

  • Introduced the WatcherChangeDescription class, which extends ChangeDescription and includes a reference to the emitting IFileSystemWatcher, allowing consumers to filter notifications by watcher instance.
  • Updated the IWatcherTriggeredHandler interface and related APIs to use WatcherChangeDescription instead of ChangeDescription, and added a new OnTriggeredOrReplay method to allow callbacks to receive both past and future watcher-triggered notifications.
  • Implemented notification history and replay support for watcher-triggered notifications in ChangeHandler, including thread-safety improvements and opt-out support.

Notification history configuration:

  • Updated MockFileSystemOptions and related documentation to clarify that notification history now applies to both standard and watcher-triggered streams, and that disabling history affects both.

Internal improvements:

  • Added a copy constructor to ChangeDescription to support the new WatcherChangeDescription type.
  • Updated FileSystemWatcherMock to use the new watcher-triggered notification API.

@vbreuss vbreuss self-assigned this May 17, 2026
Copilot AI review requested due to automatic review settings May 17, 2026 12:41
@vbreuss vbreuss added the enhancement New feature or request label May 17, 2026
@vbreuss vbreuss enabled auto-merge (squash) May 17, 2026 12:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds watcher-specific change descriptions and replay support for watcher-triggered notifications in the mock file system notification pipeline.

Changes:

  • Introduces WatcherChangeDescription with 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 OnTriggeredOrReplay directly to the public interface is also a breaking change for any external implementations of IWatcherTriggeredHandler, 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);

@sonarqubecloud
Copy link
Copy Markdown

@vbreuss vbreuss disabled auto-merge May 17, 2026 13:08
@vbreuss vbreuss merged commit e71c9bb into main May 17, 2026
16 checks passed
@vbreuss vbreuss deleted the feat/notification-history-replay branch May 17, 2026 13:08
@github-actions
Copy link
Copy Markdown

This is addressed in release v6.4.0.

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

Labels

enhancement New feature or request state: released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants