Skip to content

Default excludes #49454

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Default excludes #49454

wants to merge 2 commits into from

Conversation

tmat
Copy link
Member

@tmat tmat commented Jun 17, 2025

Adds capability to watch individual files to FileWatcher.

If enabled, uses the SDK's DefaultItemExcludes globs to exclude files from being watched.
Otherwise, excludes out and bin directories as previously implemented.

Implement support for project file changes (proj, props, targets).

@github-actions github-actions bot added the Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch label Jun 17, 2025
Copy link
Contributor

Thanks for your PR, @@tmat.
To learn about the PR process and branching schedule of this repo, please take a look at the SDK PR Guide.

Implement watching project, props and targets files.
@tmat tmat force-pushed the DefaultExcludes branch from ea02449 to 5c72022 Compare June 21, 2025 19:22
@tmat tmat marked this pull request as ready for review June 21, 2025 19:22
@Copilot Copilot AI review requested due to automatic review settings June 21, 2025 19:22
@tmat tmat requested review from arunchndr and a team as code owners June 21, 2025 19:22
@tmat
Copy link
Member Author

tmat commented Jun 21, 2025

@DustinCampbell ptal

Copy link
Contributor

@Copilot 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

This PR enhances the FileWatcher in dotnet-watch to support per-file watching and SDK DefaultItemExcludes globs, while continuing to ignore bin/obj by default. It also adds re-evaluation support for project file changes and refactors watcher APIs to use a new DirectoryWatcher base class.

  • Introduce FilePathExclusions and wire up DefaultItemExcludes globs in HotReloadDotNetWatcher.
  • Refactor file-watching APIs: remove IDirectoryWatcher/FileWatcherFactory, add DirectoryWatcher with WatchFiles/WatchContainingDirectories.
  • Update tests and project evaluation to cover individual-file watch and project file changes.

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/.../FilePathExclusions.cs Implement exclusion logic for DefaultItemExcludes globs and output dirs
src/.../FileWatcher/DirectoryWatcher.cs New base watcher, handles per-file and directory-tree watching
src/.../HotReloadDotNetWatcher.cs Integrate exclusions and project-file change re-evaluation
src/.../MsBuildFileSetFactory.cs Propagate CancellationToken when loading the project graph
src/.../ProjectGraphNodeExtensions.cs Expose EnableDefaultItems and DefaultItemExcludes
test/.../FileWatcherTests.cs Update tests to validate per-file watch logic
test/.../ApplyDeltaTests.cs Add tests for project file change scenarios
test/.../HotReload/CompilationHandlerTests.cs Pass CancellationToken when loading project graph
test/.../HotReload/RuntimeProcessLauncherTests.cs Rename test semaphore to ignoringChangeInExcludedFile
test/TestAssets/TestProjects/.../*.csproj and props files Add or update DefineConstants and project properties for tests
Comments suppressed due to low confidence (2)

test/dotnet-watch.Tests/FileWatcherTests.cs:25

  • The fallback [] array literal does not match the expected ImmutableHashSet<string> parameter. Replace watchedFileNames ?? [] with watchedFileNames ?? ImmutableHashSet<string>.Empty.
            using var watcher = DirectoryWatcher.Create(dir, watchedFileNames ?? [], usePolling, includeSubdirectories: watchSubdirectories);

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

Successfully merging this pull request may close these issues.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy