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
Add FileSystem.Watcher.FilterList Property #25967
Comments
What is the advantage of |
@danmosemsft I am overriding |
Ah...I missed that on my small screen. |
|
I will update the proposal soon |
It just sets the first element
we can not set it
We never have a
We can optimise by not going further through the collection of the list if we encounter
It will be breaking change as I will add the usage code soon |
I meant: namespace System.IO
{
public class FileSystemWatcher
{
public Collection<string> FilterList { get; }
}
}
Why not add one that takes Please add the other details you've given above under "Implementation Details". |
@JeremyKuhne Done and added some some examples too |
We can discuss in review, but it seems least confusing to me for setting filter to be equivalent to setting a one item filter list, and for getting filter to throw if there is more than one entry in filterlist. |
Looks a good. A few points:
|
Rationale
Currently there is no support for using multiple regex filters to monitor the file system using FileSystemWatcher Class. eg. If we want to monitor files with two extensions (.dll and .pdb), we wont be able to directly to due it.
There are 2 ways to work around this issue but non of them is optimal.
"*"
filter and then prune the files manually in the event handler.This approach is highly inefficient because first of all we are listening to all files and then user have to manually filter the files which defeats the purpose of having the
Filter
in the first place. Here are some links where people asked for this new functionality but has to settle down for this approachhttps://stackoverflow.com/questions/6965184/how-to-set-filter-for-filesystemwatcher-for-multiple-file-types
https://social.msdn.microsoft.com/Forums/vstudio/en-US/91ebc868-2661-4477-b825-5b796d020ab1/how-do-i-setup-filewatcher-filter-for-multiple-document-types?forum=csharpgeneral
https://stackoverflow.com/questions/38467389/filter-to-not-include-multiple-extensions
Proposed API
Currently we use
string _filter
as a backing field forFilter
property. I suggest usingCollection<string> _filterList
as a backing field for both theFilter and FilterList Property
.Filter property will always return the first element of the list (In Case of multiple Filters too)
Implementation Branch
https://github.com/Anipik/corefx/tree/Filter
This is the rough implementation of the api and how it will modify the
constructor and Filter property
.It just sets the first element and does not reduce the size of collection.
In all the above cases, we change it to the collection with just only one element i.e
*
We never have a
null or empty element
in the collection. We always replace it with*
while adding to the collectionWe can optimise by not going further through the collection of the list if we encounter
*
.we can use Initializer to initialize the FilterList
It will be breaking change as
FileSystemWatcher("path", null)
will be ambiguous call forFileSystemWater(string path, IEnumnerable<string> FilterList)
Usage
cc @danmosemsft @JeremyKuhne
The text was updated successfully, but these errors were encountered: