-
Notifications
You must be signed in to change notification settings - Fork 1.1k
File watcher: ignore directories, allow watching non-recursively #49150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for your PR, @@tmat. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR extends the file-watching subsystem to distinguish between recursive and non-recursive watching and to ignore directory events, while centralizing path adjustments in PathUtilities
and updating corresponding tests.
- Add an
includeSubdirectories
flag throughout the watcher factory, polling and event-based watchers. - Filter out directory change events in both polling and file‐system–based implementations.
- Introduce
PathUtilities.EnsureTrailingSlash
andNormalizeDirectorySeparators
. - Update tests to drive the new behavior and adjust assertion ordering.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
test/dotnet-watch.Tests/FileWatcherTests.cs | Pass watchSubdirectories to tests and simplify assertion sorting |
src/BuiltInTools/dotnet-watch/Utilities/PathUtilities.cs | Add trailing-slash and separator-normalization helpers |
src/BuiltInTools/dotnet-watch/Internal/FileWatcher/PollingDirectoryWatcher.cs | Add _includeSubdirectories , rename and scope file dictionaries |
src/BuiltInTools/dotnet-watch/Internal/FileWatcher/EventBasedDirectoryWatcher.cs | Honor IncludeSubdirectories and ignore directory events |
src/BuiltInTools/dotnet-watch/Internal/FileWatcher/IDirectoryWatcher.cs | Switch to file-scoped namespace and add summary doc |
src/BuiltInTools/dotnet-watch/Internal/FileWatcher/FileWatcherFactory.cs | Overload CreateWatcher to accept includeSubdirectories |
src/BuiltInTools/dotnet-watch/Internal/FileWatcher/FileWatcher.cs | Split recursive vs. non-recursive watchers and update disposal |
src/BuiltInTools/dotnet-watch/HotReloadDotNetWatcher.cs | Propagate includeSubdirectories when watching containing dirs |
src/BuiltInTools/dotnet-watch/DotNetWatcher.cs | Propagate includeSubdirectories for root project directory watch |
Comments suppressed due to low confidence (2)
src/BuiltInTools/dotnet-watch/Internal/FileWatcher/FileWatcher.cs:30
Dispose
only iterates_directoryTreeWatchers
; non-recursive watchers in_directoryWatchers
remain undisposed and can leak events—include both collections in disposal.
foreach (var (_, watcher) in _directoryTreeWatchers)
src/BuiltInTools/dotnet-watch/Internal/FileWatcher/FileWatcher.cs:78
- When registering a recursive watcher, you remove redundant recursive watchers but leave non-recursive watchers intact; also clear entries in
_directoryWatchers
under the new root to avoid duplicate event streams.
var watchersToRemove = _directoryTreeWatchers
src/BuiltInTools/dotnet-watch/Internal/FileWatcher/PollingDirectoryWatcher.cs
Outdated
Show resolved
Hide resolved
src/BuiltInTools/dotnet-watch/Internal/FileWatcher/EventBasedDirectoryWatcher.cs
Show resolved
Hide resolved
3a6f7b1
to
4d1fb20
Compare
Preparing directory watcher for watching individual files in some cases when we don't want to watch the entire directory tree (e.g. targets and props files outside of the project dir).
Fixes #49307