Imported Upstream version 5.16.0.100

Former-commit-id: 38faa55fb9669e35e7d8448b15c25dc447f25767
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-08-07 15:19:03 +00:00
parent 0a9828183b
commit 7d7f676260
4419 changed files with 170950 additions and 90273 deletions

View File

@@ -24,14 +24,10 @@
</Compile>
<Compile Include="System\IO\InternalBufferOverflowException.cs" />
<Compile Include="System\IO\NotifyFilters.cs" />
<Compile Include="System\IO\PatternMatcher.cs" />
<Compile Include="System\IO\RenamedEventArgs.cs" />
<Compile Include="System\IO\RenamedEventHandler.cs" />
<Compile Include="System\IO\WatcherChangeTypes.cs" />
<Compile Include="System\IO\WaitForChangedResult.cs" />
<Compile Include="$(CommonPath)\System\IO\PathInternal.cs">
<Link>Common\System\IO\PathInternal.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\IO\PathInternal.CaseSensitivity.cs">
<Link>Common\System\IO\PathInternal.CaseSensitivity.cs</Link>
</Compile>
@@ -150,6 +146,7 @@
<Reference Include="System.Diagnostics.Debug" />
<Reference Include="System.Diagnostics.Tools" />
<Reference Include="System.IO.FileSystem" />
<Reference Include="System.Memory" />
<Reference Include="System.Resources.ResourceManager" />
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Extensions" />
@@ -165,4 +162,4 @@
<Reference Include="System.Collections" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>

View File

@@ -5,6 +5,7 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO.Enumeration;
using System.Threading;
using System.Threading.Tasks;
@@ -22,7 +23,6 @@ namespace System.IO
/// Listens to the system directory change notifications and
/// raises events when a directory or file within a directory changes.
/// </devdoc>
public partial class FileSystemWatcher : Component, ISupportInitialize
{
/// <devdoc>
@@ -89,14 +89,14 @@ namespace System.IO
public FileSystemWatcher()
{
_directory = string.Empty;
_filter = "*.*";
_filter = "*";
}
/// <devdoc>
/// Initializes a new instance of the <see cref='System.IO.FileSystemWatcher'/> class,
/// given the specified directory to monitor.
/// </devdoc>
public FileSystemWatcher(string path) : this(path, "*.*")
public FileSystemWatcher(string path) : this(path, "*")
{
}
@@ -109,9 +109,6 @@ namespace System.IO
if (path == null)
throw new ArgumentNullException(nameof(path));
if (filter == null)
throw new ArgumentNullException(nameof(filter));
// Early check for directory parameter so that an exception can be thrown as early as possible.
if (path.Length == 0)
throw new ArgumentException(SR.Format(SR.InvalidDirName, path), nameof(path));
@@ -120,7 +117,10 @@ namespace System.IO
throw new ArgumentException(SR.Format(SR.InvalidDirName_NotExists, path), nameof(path));
_directory = path;
_filter = filter;
_filter = filter ?? throw new ArgumentNullException(nameof(filter));
if (_filter == "*.*")
_filter = "*";
}
/// <devdoc>
@@ -193,13 +193,13 @@ namespace System.IO
{
if (string.IsNullOrEmpty(value))
{
// Skip the string compare for "*.*" since it has no case-insensitive representation that differs from
// Skip the string compare for "*" since it has no case-insensitive representation that differs from
// the case-sensitive representation.
_filter = "*.*";
_filter = "*";
}
else if (!string.Equals(_filter, value, PathInternal.StringComparison))
{
_filter = value;
_filter = value == "*.*" ? "*" : value;
}
}
}
@@ -267,7 +267,7 @@ namespace System.IO
/// <devdoc>
/// Gets or sets the path of the directory to watch.
/// </devdoc>
/// </devdoc>
public string Path
{
get
@@ -404,10 +404,10 @@ namespace System.IO
/// <internalonly/>
private bool MatchPattern(string relativePath)
{
string name = System.IO.Path.GetFileName(relativePath);
return name != null ?
PatternMatcher.StrictMatchPattern(_filter, name) :
false;
ReadOnlySpan<char> name = IO.Path.GetFileName(relativePath.AsSpan());
return name.Length > 0
? FileSystemName.MatchesSimpleExpression(_filter, name, ignoreCase: !PathInternal.IsCaseSensitive)
: false;
}
/// <devdoc>
@@ -662,7 +662,6 @@ namespace System.IO
{
return _synchronizingObject;
}
set
{
_synchronizingObject = value;

View File

@@ -25,7 +25,6 @@ namespace System.IO.Tests
}
[Fact]
[SkipOnTargetFramework(TargetFrameworkMonikers.Mono, "Not working")]
public void FileSystemWatcher_NewFileInfoAction_TriggersNothing()
{
using (var testDirectory = new TempDirectory(GetTestFilePath()))
@@ -70,8 +69,8 @@ namespace System.IO.Tests
[Fact]
public void FileSystemWatcher_ctor()
{
string path = String.Empty;
string pattern = "*.*";
string path = string.Empty;
string pattern = PlatformDetection.IsFullFramework ? "*.*" : "*";
using (FileSystemWatcher watcher = new FileSystemWatcher())
ValidateDefaults(watcher, path, pattern);
}
@@ -80,7 +79,7 @@ namespace System.IO.Tests
public void FileSystemWatcher_ctor_path()
{
string path = @".";
string pattern = "*.*";
string pattern = PlatformDetection.IsFullFramework ? "*.*" : "*";
using (FileSystemWatcher watcher = new FileSystemWatcher(path))
ValidateDefaults(watcher, path, pattern);
}
@@ -183,7 +182,6 @@ namespace System.IO.Tests
}
[Fact]
[SkipOnTargetFramework(TargetFrameworkMonikers.Mono, "Not working")]
public void FileSystemWatcher_EnableRaisingEvents()
{
using (var testDirectory = new TempDirectory(GetTestFilePath()))
@@ -220,14 +218,14 @@ namespace System.IO.Tests
{
FileSystemWatcher watcher = new FileSystemWatcher();
Assert.Equal("*.*", watcher.Filter);
Assert.Equal(PlatformDetection.IsFullFramework ? "*.*" : "*", watcher.Filter);
// Null and empty should be mapped to "*.*"
// Null and empty should be mapped to "*"
watcher.Filter = null;
Assert.Equal("*.*", watcher.Filter);
Assert.Equal(PlatformDetection.IsFullFramework ? "*.*" : "*", watcher.Filter);
watcher.Filter = String.Empty;
Assert.Equal("*.*", watcher.Filter);
watcher.Filter = string.Empty;
Assert.Equal(PlatformDetection.IsFullFramework ? "*.*" : "*", watcher.Filter);
watcher.Filter = " ";
Assert.Equal(" ", watcher.Filter);
@@ -245,7 +243,7 @@ namespace System.IO.Tests
RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
// expect no change for OrdinalIgnoreCase-equal strings
// it's unclear why desktop does this but preserve it for compat
// it's unclear why desktop does this but preserve it for compat
watcher.Filter = "ABC.DLL";
Assert.Equal("abc.dll", watcher.Filter);
}
@@ -596,7 +594,6 @@ namespace System.IO.Tests
}
[Fact]
[SkipOnTargetFramework(TargetFrameworkMonikers.Mono, "Not working")]
public void FileSystemWatcher_StopCalledOnBackgroundThreadDoesNotDeadlock()
{
// Check the case where Stop or Dispose (they do the same thing) is called from

View File

@@ -36,11 +36,5 @@ namespace System.IO.Tests
Assert.Equal(message, ide.Message);
Assert.Same(innerException, ide.InnerException);
}
[Fact]
public static void ExceptionRoundtrips()
{
BinaryFormatterHelpers.AssertRoundtrips(new InternalBufferOverflowException());
}
}
}