dotnet / dotnet/sdk

[dotnet-watch] Do not watch content of directories that match file exclusions

Open
#52,682 0 comments 0 reactions 1 assignee Assigned to @tmat View on GitHub
Area-Watch untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

Exclusion globs are listed in `EvaluationResult.ItemExclusions`. If it excludes an entire subdirectory, e.g. ends with `/**` , `/**/*.*` etc. we can avoid watching that subdirectory for changes. This will mitigate issues that occur when watching large directories recursively and receiving a lot of file system events.

Observations so far:
- Typical exclusions: `bin\Debug\**;obj\Debug\**;bin\**;obj\**;bin\Debug\net10.0\publish\**`
- We want to watch specific files in excluded directories, e.g. `obj\Debug\GlobalUsings.g.cs`.
- Currently we watch all directories that contain any evaluated items and their subdirectories.
- Instead, watch directories and files based on inclusion globs. Create non-recursive watchers for dirs containing explicitly listed files. Recursive watchers based on `**` glob patterns. If we have `**/*.cs` inclusion and `obj/Debug/**` exclusion and wanted to avoid recursive watcher for the entire project dir, we would need to create non-recursive watcher for project dir and whenever a new directory is added create a recursive watcher watching that dir (unless it contains excluded dir).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.