[API Proposal]: Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher should expose modified files (Alternative where standalone FilesystemWatcher won't work) #110969
Labels
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
area-System.IO
untriaged
New issue has not been triaged by the area owner
Background and motivation
Currently, PhysicalFileProvider provides a configurable file modification detector via PhysicalFilesWatcher wrapped by FilesystemWatcher and offers a polling feature on request (either by API or via environment variables).
Unfortunately, IChangeToken hides file path information of the actual file changes to API user/client code. While information hiding is a quite common design technique, file path information may become quite useful for API users, especially when polling is the only option available to achieve modification tracking/observation and a fallback to a custom implementation based on (good-old) FilesystemWatcher is not an option.
Please consider to either enhance IPollingChangeToken to expose (physical) FileInfo or provide an extra IChangeToken which exposes file paths for all behaviors implemented in PhysicalFilesWatcher.
API Proposal
API Usage
Drawback: This approch might not be perfomant. Neither it provides an elegant solution.
Alternative Designs
Alternativly please consider to extract polling feature as an independent (refactored/extracted)
PollingFilesystemWatcher
which offfers either customizedIChangeToken
or Rx.NET support if changing information hiding policy here violatesIChangeToken
concept or any SOLID principle , I might have missed in my orginal propoals (due to lack of insight and/or overview of your orginal design consideration and usage).Or
Picks up some ideas already discussed in #17111 maybe
Risks
IFileInfo
when extraction and adding another level of abstraction might offer a more plausbile and solid conceptThe text was updated successfully, but these errors were encountered: