Imported Upstream version 5.10.0.69

Former-commit-id: fc39669a0b707dd3c063977486506b6793da2890
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-01-29 19:03:06 +00:00
parent d8f8abd549
commit e2950ec768
6283 changed files with 453847 additions and 91879 deletions

View File

@@ -5,7 +5,6 @@
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
namespace System.IO
{
public partial class ErrorEventArgs : System.EventArgs
@@ -33,11 +32,16 @@ namespace System.IO
public int InternalBufferSize { get { throw null; } set { } }
public System.IO.NotifyFilters NotifyFilter { get { throw null; } set { } }
public string Path { get { throw null; } set { } }
public override System.ComponentModel.ISite Site { get { throw null; } set { } }
public System.ComponentModel.ISynchronizeInvoke SynchronizingObject { get { throw null; } set { } }
public event System.IO.FileSystemEventHandler Changed { add { } remove { } }
public event System.IO.FileSystemEventHandler Created { add { } remove { } }
public event System.IO.FileSystemEventHandler Deleted { add { } remove { } }
public event System.IO.ErrorEventHandler Error { add { } remove { } }
public event System.IO.RenamedEventHandler Renamed { add { } remove { } }
public void BeginInit() { }
protected override void Dispose(bool disposing) { }
public void EndInit() { }
protected void OnChanged(System.IO.FileSystemEventArgs e) { }
protected void OnCreated(System.IO.FileSystemEventArgs e) { }
protected void OnDeleted(System.IO.FileSystemEventArgs e) { }
@@ -45,19 +49,14 @@ namespace System.IO
protected void OnRenamed(System.IO.RenamedEventArgs e) { }
public System.IO.WaitForChangedResult WaitForChanged(System.IO.WatcherChangeTypes changeType) { throw null; }
public System.IO.WaitForChangedResult WaitForChanged(System.IO.WatcherChangeTypes changeType, int timeout) { throw null; }
public override System.ComponentModel.ISite Site { get { throw null; } set { } }
public System.ComponentModel.ISynchronizeInvoke SynchronizingObject { get { throw null; } set { } }
public void BeginInit() { }
protected override void Dispose(bool disposing) { }
public void EndInit() { }
}
[Serializable]
public partial class InternalBufferOverflowException : System.SystemException
{
public InternalBufferOverflowException() { }
protected InternalBufferOverflowException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public InternalBufferOverflowException(string message) { }
public InternalBufferOverflowException(string message, System.Exception inner) { }
protected InternalBufferOverflowException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
}
[System.FlagsAttribute]
public enum NotifyFilters
@@ -73,13 +72,14 @@ namespace System.IO
}
public partial class RenamedEventArgs : System.IO.FileSystemEventArgs
{
public RenamedEventArgs(System.IO.WatcherChangeTypes changeType, string directory, string name, string oldName) : base(default(System.IO.WatcherChangeTypes), default(string), default(string)) { }
public RenamedEventArgs(System.IO.WatcherChangeTypes changeType, string directory, string name, string oldName) : base (default(System.IO.WatcherChangeTypes), default(string), default(string)) { }
public string OldFullPath { get { throw null; } }
public string OldName { get { throw null; } }
}
public delegate void RenamedEventHandler(object sender, System.IO.RenamedEventArgs e);
public struct WaitForChangedResult
public partial struct WaitForChangedResult
{
private object _dummy;
public System.IO.WatcherChangeTypes ChangeType { get { throw null; } set { } }
public string Name { get { throw null; } set { } }
public string OldName { get { throw null; } set { } }

View File

@@ -1,5 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
@@ -70,6 +129,9 @@
<data name="InvalidDirName" xml:space="preserve">
<value>The directory name {0} is invalid.</value>
</data>
<data name="InvalidDirName_NotExists" xml:space="preserve">
<value>The directory name '{0}' does not exist.</value>
</data>
<data name="InvalidEnumArgument" xml:space="preserve">
<value>The value of argument '{0}' ({1}) is invalid for Enum type '{2}'.</value>
</data>
@@ -110,7 +172,7 @@
<value>Failed to start the EventStream</value>
</data>
<data name="Argument_InvalidPathChars" xml:space="preserve">
<value>Illegal characters in path.</value>
<value>Illegal characters in path '{0}'.</value>
</data>
<data name="IOException_INotifyInstanceSystemLimitExceeded" xml:space="preserve">
<value>The system limit on the number of inotify instances has been reached.</value>
@@ -127,4 +189,7 @@
<data name="IOException_INotifyWatchesUserLimitExceeded" xml:space="preserve">
<value>The configured user limit on the number of inotify watches has been reached.</value>
</data>
</root>
<data name="IO_PathTooLong_Path" xml:space="preserve">
<value>The path '{0}' is too long, or a component of the specified path is too long.</value>
</data>
</root>

View File

@@ -19,7 +19,9 @@
<Compile Include="System\IO\ErrorEventHandler.cs" />
<Compile Include="System\IO\FileSystemEventArgs.cs" />
<Compile Include="System\IO\FileSystemEventHandler.cs" />
<Compile Include="System\IO\FileSystemWatcher.cs" />
<Compile Include="System\IO\FileSystemWatcher.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="System\IO\InternalBufferOverflowException.cs" />
<Compile Include="System\IO\NotifyFilters.cs" />
<Compile Include="System\IO\PatternMatcher.cs" />
@@ -53,13 +55,15 @@
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.ReadDirectoryChangesW.cs">
<Link>Common\Interop\Windows\kernel32\Interop.ReadDirectoryChangesW.cs</Link>
</Compile>
<Compile Include="System\IO\FileSystemWatcher.Win32.cs" />
<Compile Include="System\IO\FileSystemWatcher.Win32.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.CloseHandle.cs">
<Link>Common\Interop\Windows\Interop.CloseHandle.cs</Link>
</Compile>
</ItemGroup>
<!-- Windows : Win32 only -->
<ItemGroup Condition="'$(TargetsWindows)' == 'true' and '$(TargetGroup)' != 'uap'">
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.UnsafeCreateFile.cs">
<Link>Common\Interop\Windows\Interop.UnsafeCreateFile.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.CreateFile.cs">
<Link>Common\Interop\Windows\Interop.CreateFile.cs</Link>
</Compile>
@@ -69,9 +73,6 @@
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.CreateFile2.cs">
<Link>Common\Interop\Windows\Interop.CreateFile2.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.UnsafeCreateFile.uap.cs">
<Link>Common\Interop\Windows\Interop.UnsafeCreateFile.uap.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.COPYFILE2_EXTENDED_PARAMETERS.cs">
<Link>Common\Interop\Windows\Interop.COPYFILE2_EXTENDED_PARAMETERS.cs</Link>
</Compile>
@@ -164,4 +165,4 @@
<Reference Include="System.Collections" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>

View File

@@ -26,15 +26,13 @@ namespace System.IO
return;
// Create handle to directory being monitored
var defaultSecAttrs = default(Interop.Kernel32.SECURITY_ATTRIBUTES);
_directoryHandle = Interop.Kernel32.UnsafeCreateFile(
_directoryHandle = Interop.Kernel32.CreateFile(
lpFileName: _directory,
dwDesiredAccess: Interop.Kernel32.FileOperations.FILE_LIST_DIRECTORY,
dwShareMode: FileShare.Read | FileShare.Delete | FileShare.Write,
securityAttrs: ref defaultSecAttrs,
dwCreationDisposition: FileMode.Open,
dwFlagsAndAttributes: Interop.Kernel32.FileOperations.FILE_FLAG_BACKUP_SEMANTICS | Interop.Kernel32.FileOperations.FILE_FLAG_OVERLAPPED,
hTemplateFile: IntPtr.Zero);
dwFlagsAndAttributes: Interop.Kernel32.FileOperations.FILE_FLAG_BACKUP_SEMANTICS | Interop.Kernel32.FileOperations.FILE_FLAG_OVERLAPPED);
if (IsHandleInvalid(_directoryHandle))
{
_directoryHandle = null;

View File

@@ -105,9 +105,12 @@ namespace System.IO
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 || !Directory.Exists(path))
if (path.Length == 0)
throw new ArgumentException(SR.Format(SR.InvalidDirName, path), nameof(path));
if (!Directory.Exists(path))
throw new ArgumentException(SR.Format(SR.InvalidDirName_NotExists, path), nameof(path));
_directory = path;
_filter = filter;
}
@@ -150,13 +153,13 @@ namespace System.IO
{
return;
}
if (IsSuspended())
{
_enabled = value; // Alert the Component to start watching for events when EndInit is called.
}
else
{
{
if (value)
{
StartRaisingEventsIfNotDisposed(); // will set _enabled to true once successfully started
@@ -256,7 +259,7 @@ namespace System.IO
/// <devdoc>
/// Gets or sets the path of the directory to watch.
/// </devdoc>
/// </devdoc>
public string Path
{
get
@@ -268,11 +271,12 @@ namespace System.IO
value = (value == null) ? string.Empty : value;
if (!string.Equals(_directory, value, PathInternal.StringComparison))
{
if (!Directory.Exists(value))
{
throw new ArgumentException(SR.Format(SR.InvalidDirName, value));
}
if (value.Length == 0)
throw new ArgumentException(SR.Format(SR.InvalidDirName, value), nameof(Path));
if (!Directory.Exists(value))
throw new ArgumentException(SR.Format(SR.InvalidDirName_NotExists, value), nameof(Path));
_directory = value;
Restart();
}
@@ -416,7 +420,7 @@ namespace System.IO
{
// filter if there's no handler or neither new name or old name match a specified pattern
RenamedEventHandler handler = _onRenamedHandler;
if (handler != null &&
if (handler != null &&
(MatchPattern(name) || MatchPattern(oldName)))
{
handler(this, new RenamedEventArgs(action, _directory, name, oldName));
@@ -525,7 +529,7 @@ namespace System.IO
}
}
public WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType) =>
public WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType) =>
WaitForChanged(changeType, Timeout.Infinite);
public WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, int timeout)

View File

@@ -10,6 +10,9 @@ namespace System.IO
/// The exception that is thrown when the internal buffer overflows.
/// </devdoc>
[Serializable]
#if !MONO
[System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
#endif
public class InternalBufferOverflowException : SystemException
{
/// <devdoc>
@@ -40,7 +43,6 @@ namespace System.IO
protected InternalBufferOverflowException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
throw new PlatformNotSupportedException();
}
}
}

View File

@@ -9,6 +9,28 @@ namespace System.IO.Tests
{
public class Directory_Create_Tests : FileSystemWatcherTest
{
[Fact]
public void FileSystemWatcher_Directory_EmptyPath()
{
Assert.Throws<ArgumentException>(() =>
{
using (var watcher = new FileSystemWatcher(""))
{
}
});
}
[Fact]
public void FileSystemWatcher_Directory_PathNotExists()
{
Assert.Throws<ArgumentException>(() =>
{
using (var watcher = new FileSystemWatcher(GetTestFilePath()))
{
}
});
}
[Fact]
public void FileSystemWatcher_Directory_Create()
{
@@ -81,4 +103,4 @@ namespace System.IO.Tests
}
}
}
}
}

View File

@@ -485,9 +485,9 @@ namespace System.IO.Tests
}
}
[Fact]
[Fact]
public void FileSystemWatcher_Path()
{
{
FileSystemWatcher watcher = new FileSystemWatcher();
Assert.Equal(String.Empty, watcher.Path);
@@ -527,14 +527,14 @@ namespace System.IO.Tests
Assert.Equal(currentDirRelative, watcher.Path);
// FSW starts with String.Empty and will ignore setting this if it is already set,
// but if you set it after some other valid string has been set it will throw.
AssertExtensions.Throws<ArgumentException>(null, () => watcher.Path = String.Empty);
// but if you set it after some other valid string has been set it will throw.
Assert.Throws<ArgumentException>(() => watcher.Path = String.Empty);
// Non-existent path
AssertExtensions.Throws<ArgumentException>(null, () => watcher.Path = GetTestFilePath());
Assert.Throws<ArgumentException>(() => watcher.Path = GetTestFilePath());
// Web path
AssertExtensions.Throws<ArgumentException>(null, () => watcher.Path = "http://localhost");
Assert.Throws<ArgumentException>(() => watcher.Path = "http://localhost");
// File protocol
AssertExtensions.Throws<ArgumentException>(null, () => watcher.Path = "file:///" + currentDir.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar));
Assert.Throws<ArgumentException>(() => watcher.Path = "file:///" + currentDir.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar));
}
[Fact]