Skip to content

Commit

Permalink
feat: add IFileSystemWatcher.Filters (#680)
Browse files Browse the repository at this point in the history
  • Loading branch information
fgreinacher committed Nov 26, 2020
1 parent e15174b commit 65de5f1
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 1 deletion.
1 change: 1 addition & 0 deletions Directory.Build.props
Expand Up @@ -14,6 +14,7 @@
<DefineConstants Condition="'$(TargetFramework)' == 'net5.0' OR '$(TargetFramework)' == 'netcoreapp3.1' OR '$(TargetFramework)' == 'netstandard2.1'">$(DefineConstants);FEATURE_ASYNC_FILE;FEATURE_ENUMERATION_OPTIONS;FEATURE_ADVANCED_PATH_OPERATIONSFEATURE_PATH_JOIN_WITH_SPAN</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)' == 'net5.0'">$(DefineConstants);FEATURE_FILE_MOVE_WITH_OVERWRITE</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)' == 'net5.0'">$(DefineConstants);FEATURE_SUPPORTED_OS_ATTRIBUTE</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)' == 'net5.0'">$(DefineConstants);FEATURE_FILE_SYSTEM_WATCHER_FILTERS</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.3.37">
Expand Down
5 changes: 5 additions & 0 deletions src/System.IO.Abstractions/FileSystemWatcherBase.cs
Expand Up @@ -15,6 +15,11 @@ public abstract class FileSystemWatcherBase : IFileSystemWatcher
/// <inheritdoc cref="FileSystemWatcher.Filter"/>
public abstract string Filter { get; set; }

#if FEATURE_FILE_SYSTEM_WATCHER_FILTERS
/// <inheritdoc cref="FileSystemWatcher.Filters"/>
public abstract System.Collections.ObjectModel.Collection<string> Filters { get; }
#endif

/// <inheritdoc cref="FileSystemWatcher.InternalBufferSize"/>
public abstract int InternalBufferSize { get; set; }

Expand Down
7 changes: 7 additions & 0 deletions src/System.IO.Abstractions/FileSystemWatcherWrapper.cs
Expand Up @@ -54,6 +54,13 @@ public override string Filter
set { watcher.Filter = value; }
}

#if FEATURE_FILE_SYSTEM_WATCHER_FILTERS
public override System.Collections.ObjectModel.Collection<string> Filters
{
get { return watcher.Filters; }
}
#endif

public override int InternalBufferSize
{
get { return watcher.InternalBufferSize; }
Expand Down
4 changes: 4 additions & 0 deletions src/System.IO.Abstractions/IFileSystemWatcher.cs
Expand Up @@ -10,6 +10,10 @@ public interface IFileSystemWatcher : IDisposable
bool EnableRaisingEvents { get; set; }
/// <inheritdoc cref="FileSystemWatcher.Filter"/>
string Filter { get; set; }
#if FEATURE_FILE_SYSTEM_WATCHER_FILTERS
/// <inheritdoc cref="FileSystemWatcher.Filters"/>
System.Collections.ObjectModel.Collection<string> Filters { get; }
#endif
/// <inheritdoc cref="FileSystemWatcher.InternalBufferSize"/>
int InternalBufferSize { get; set; }
/// <inheritdoc cref="FileSystemWatcher.NotifyFilter"/>
Expand Down
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -408,6 +409,9 @@ public TestFileSystemWatcher(string path, string filter)
public override NotifyFilters NotifyFilter { get; set; }
public override ISite Site { get; set; }
public override ISynchronizeInvoke SynchronizingObject { get; set; }
#if FEATURE_FILE_SYSTEM_WATCHER_FILTERS
public override Collection<string> Filters { get; }
#endif
public override void BeginInit() { }
public override void EndInit() { }
public override WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType) => default(WaitForChangedResult);
Expand Down
7 changes: 7 additions & 0 deletions tests/System.IO.Abstractions.Tests/ApiParityTests.cs
Expand Up @@ -52,6 +52,13 @@ public class ApiParityTests
typeof(System.IO.Abstractions.PathBase)
);

[Test]
public void FileSystemWatcher() =>
AssertParity(
typeof(System.IO.FileSystemWatcher),
typeof(System.IO.Abstractions.FileSystemWatcherBase)
);

private void AssertParity(Type referenceType, Type abstractionType)
{
static IEnumerable<string> GetMembers(Type type) => type
Expand Down
@@ -0,0 +1,17 @@
{
"ExtraMembers": [
"Void Dispose(Boolean)"
],
"MissingMembers": [
"System.ComponentModel.IContainer Container",
"System.ComponentModel.IContainer get_Container()",
"System.EventHandler Disposed",
"System.Object GetLifetimeService()",
"System.Object InitializeLifetimeService()",
"Void .ctor()",
"Void .ctor(System.String)",
"Void .ctor(System.String, System.String)",
"Void add_Disposed(System.EventHandler)",
"Void remove_Disposed(System.EventHandler)"
]
}
@@ -0,0 +1,17 @@
{
"ExtraMembers": [
"Void Dispose(Boolean)"
],
"MissingMembers": [
"System.ComponentModel.IContainer Container",
"System.ComponentModel.IContainer get_Container()",
"System.EventHandler Disposed",
"System.Object GetLifetimeService()",
"System.Object InitializeLifetimeService()",
"Void .ctor()",
"Void .ctor(System.String)",
"Void .ctor(System.String, System.String)",
"Void add_Disposed(System.EventHandler)",
"Void remove_Disposed(System.EventHandler)"
]
}
@@ -0,0 +1,19 @@
{
"ExtraMembers": [
"Void Dispose(Boolean)"
],
"MissingMembers": [
"System.Collections.ObjectModel.Collection`1[System.String] Filters",
"System.Collections.ObjectModel.Collection`1[System.String] get_Filters()",
"System.ComponentModel.IContainer Container",
"System.ComponentModel.IContainer get_Container()",
"System.EventHandler Disposed",
"System.Object GetLifetimeService()",
"System.Object InitializeLifetimeService()",
"Void .ctor()",
"Void .ctor(System.String)",
"Void .ctor(System.String, System.String)",
"Void add_Disposed(System.EventHandler)",
"Void remove_Disposed(System.EventHandler)"
]
}
@@ -0,0 +1,18 @@
{
"ExtraMembers": [
"Void Dispose(Boolean)"
],
"MissingMembers": [
"System.ComponentModel.IContainer Container",
"System.ComponentModel.IContainer get_Container()",
"System.EventHandler Disposed",
"System.Object GetLifetimeService()",
"System.Object InitializeLifetimeService()",
"System.Runtime.Remoting.ObjRef CreateObjRef(System.Type)",
"Void .ctor()",
"Void .ctor(System.String)",
"Void .ctor(System.String, System.String)",
"Void add_Disposed(System.EventHandler)",
"Void remove_Disposed(System.EventHandler)"
]
}
2 changes: 1 addition & 1 deletion version.json
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "13.1",
"version": "13.2",
"assemblyVersion": {
"precision": "major"
},
Expand Down

0 comments on commit 65de5f1

Please sign in to comment.