Imported Upstream version 5.2.0.175

Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-06-07 13:16:24 +00:00
parent 4bdbaf4a88
commit 966bba02bb
8776 changed files with 346420 additions and 149650 deletions

View File

@@ -1,51 +1,50 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Pipes.AccessControl.Tests", "tests\System.IO.Pipes.AccessControl.Tests.csproj", "{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Pipes.AccessControl.Tests", "tests\System.IO.Pipes.AccessControl.Tests.csproj", "{A0356E61-19E1-4722-A53D-5D2616E16312}"
ProjectSection(ProjectDependencies) = postProject
{D77FBA6C-1AA6-45A4-93E2-97A370672C53} = {D77FBA6C-1AA6-45A4-93E2-97A370672C53}
{40059634-BB03-4A6F-8657-CCE2D376BC8B} = {40059634-BB03-4A6F-8657-CCE2D376BC8B}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Pipes.AccessControl", "src\System.IO.Pipes.AccessControl.csproj", "{D77FBA6C-1AA6-45A4-93E2-97A370672C53}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Pipes.AccessControl", "src\System.IO.Pipes.AccessControl.csproj", "{40059634-BB03-4A6F-8657-CCE2D376BC8B}"
ProjectSection(ProjectDependencies) = postProject
{994DCE47-4CF6-479D-AB1D-4EA6A2809C34} = {994DCE47-4CF6-479D-AB1D-4EA6A2809C34}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Pipes.AccessControl", "ref\System.IO.Pipes.AccessControl.csproj", "{994DCE47-4CF6-479D-AB1D-4EA6A2809C34}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{1A2F9F4A-A032-433E-B914-ADD5992BB178}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E107E9C1-E893-4E87-987E-04EF0DCEAEFD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{2E666815-2EDB-464B-9DF6-380BF4789AD4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
DebugNETCoreAppnet46-Windows_NTnetstandard1.3-Windows_NT|AnyCPU = DebugNETCoreAppnet46-Windows_NTnetstandard1.3-Windows_NT|AnyCPU
ReleaseNETCoreAppnet46-Windows_NTnetstandard1.3-Windows_NT|AnyCPU = ReleaseNETCoreAppnet46-Windows_NTnetstandard1.3-Windows_NT|AnyCPU
DebugNETCoreAppnetstandard1.3-Windows_NTnetstandard1.3-Windows_NT|AnyCPU = DebugNETCoreAppnetstandard1.3-Windows_NTnetstandard1.3-Windows_NT|AnyCPU
ReleaseNETCoreAppnetstandard1.3-Windows_NTnetstandard1.3-Windows_NT|AnyCPU = ReleaseNETCoreAppnetstandard1.3-Windows_NTnetstandard1.3-Windows_NT|AnyCPU
DebugNETCoreAppnetstandard1.3-Unixnetstandard1.3-Windows_NT|AnyCPU = DebugNETCoreAppnetstandard1.3-Unixnetstandard1.3-Windows_NT|AnyCPU
ReleaseNETCoreAppnetstandard1.3-Unixnetstandard1.3-Windows_NT|AnyCPU = ReleaseNETCoreAppnetstandard1.3-Unixnetstandard1.3-Windows_NT|AnyCPU
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.DebugNETCoreAppnet46-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = netstandard1.3-Windows_NT-Debug|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.DebugNETCoreAppnet46-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.Build.0 = netstandard1.3-Windows_NT-Debug|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.ReleaseNETCoreAppnet46-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = netstandard1.3-Windows_NT-Release|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.ReleaseNETCoreAppnet46-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.Build.0 = netstandard1.3-Windows_NT-Release|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.DebugNETCoreAppnetstandard1.3-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = netstandard1.3-Windows_NT-Debug|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.DebugNETCoreAppnetstandard1.3-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.Build.0 = netstandard1.3-Windows_NT-Debug|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.ReleaseNETCoreAppnetstandard1.3-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = netstandard1.3-Windows_NT-Release|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.ReleaseNETCoreAppnetstandard1.3-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.Build.0 = netstandard1.3-Windows_NT-Release|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.DebugNETCoreAppnetstandard1.3-Unixnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = netstandard1.3-Windows_NT-Debug|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.DebugNETCoreAppnetstandard1.3-Unixnetstandard1.3-Windows_NT|AnyCPU.Build.0 = netstandard1.3-Windows_NT-Debug|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.ReleaseNETCoreAppnetstandard1.3-Unixnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = netstandard1.3-Windows_NT-Release|Any CPU
{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}.ReleaseNETCoreAppnetstandard1.3-Unixnetstandard1.3-Windows_NT|AnyCPU.Build.0 = netstandard1.3-Windows_NT-Release|Any CPU
{D77FBA6C-1AA6-45A4-93E2-97A370672C53}.DebugNETCoreAppnet46-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = net46-Windows_NT-Debug|Any CPU
{D77FBA6C-1AA6-45A4-93E2-97A370672C53}.DebugNETCoreAppnet46-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.Build.0 = net46-Windows_NT-Debug|Any CPU
{D77FBA6C-1AA6-45A4-93E2-97A370672C53}.ReleaseNETCoreAppnet46-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = net46-Windows_NT-Release|Any CPU
{D77FBA6C-1AA6-45A4-93E2-97A370672C53}.ReleaseNETCoreAppnet46-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.Build.0 = net46-Windows_NT-Release|Any CPU
{D77FBA6C-1AA6-45A4-93E2-97A370672C53}.DebugNETCoreAppnetstandard1.3-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = netstandard1.3-Windows_NT-Debug|Any CPU
{D77FBA6C-1AA6-45A4-93E2-97A370672C53}.DebugNETCoreAppnetstandard1.3-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.Build.0 = netstandard1.3-Windows_NT-Debug|Any CPU
{D77FBA6C-1AA6-45A4-93E2-97A370672C53}.ReleaseNETCoreAppnetstandard1.3-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = netstandard1.3-Windows_NT-Release|Any CPU
{D77FBA6C-1AA6-45A4-93E2-97A370672C53}.ReleaseNETCoreAppnetstandard1.3-Windows_NTnetstandard1.3-Windows_NT|AnyCPU.Build.0 = netstandard1.3-Windows_NT-Release|Any CPU
{D77FBA6C-1AA6-45A4-93E2-97A370672C53}.DebugNETCoreAppnetstandard1.3-Unixnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = netstandard1.3-Unix-Debug|Any CPU
{D77FBA6C-1AA6-45A4-93E2-97A370672C53}.DebugNETCoreAppnetstandard1.3-Unixnetstandard1.3-Windows_NT|AnyCPU.Build.0 = netstandard1.3-Unix-Debug|Any CPU
{D77FBA6C-1AA6-45A4-93E2-97A370672C53}.ReleaseNETCoreAppnetstandard1.3-Unixnetstandard1.3-Windows_NT|AnyCPU.ActiveCfg = netstandard1.3-Unix-Release|Any CPU
{D77FBA6C-1AA6-45A4-93E2-97A370672C53}.ReleaseNETCoreAppnetstandard1.3-Unixnetstandard1.3-Windows_NT|AnyCPU.Build.0 = netstandard1.3-Unix-Release|Any CPU
{A0356E61-19E1-4722-A53D-5D2616E16312}.Debug|Any CPU.ActiveCfg = netstandard-Windows_NT-Debug|Any CPU
{A0356E61-19E1-4722-A53D-5D2616E16312}.Debug|Any CPU.Build.0 = netstandard-Windows_NT-Debug|Any CPU
{A0356E61-19E1-4722-A53D-5D2616E16312}.Release|Any CPU.ActiveCfg = netstandard-Windows_NT-Release|Any CPU
{A0356E61-19E1-4722-A53D-5D2616E16312}.Release|Any CPU.Build.0 = netstandard-Windows_NT-Release|Any CPU
{40059634-BB03-4A6F-8657-CCE2D376BC8B}.Debug|Any CPU.ActiveCfg = netstandard-Windows_NT-Debug|Any CPU
{40059634-BB03-4A6F-8657-CCE2D376BC8B}.Debug|Any CPU.Build.0 = netstandard-Windows_NT-Debug|Any CPU
{40059634-BB03-4A6F-8657-CCE2D376BC8B}.Release|Any CPU.ActiveCfg = netstandard-Windows_NT-Release|Any CPU
{40059634-BB03-4A6F-8657-CCE2D376BC8B}.Release|Any CPU.Build.0 = netstandard-Windows_NT-Release|Any CPU
{994DCE47-4CF6-479D-AB1D-4EA6A2809C34}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
{994DCE47-4CF6-479D-AB1D-4EA6A2809C34}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
{994DCE47-4CF6-479D-AB1D-4EA6A2809C34}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{994DCE47-4CF6-479D-AB1D-4EA6A2809C34}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{A0356E61-19E1-4722-A53D-5D2616E16312} = {1A2F9F4A-A032-433E-B914-ADD5992BB178}
{40059634-BB03-4A6F-8657-CCE2D376BC8B} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD}
{994DCE47-4CF6-479D-AB1D-4EA6A2809C34} = {2E666815-2EDB-464B-9DF6-380BF4789AD4}
EndGlobalSection
EndGlobal

View File

@@ -3,5 +3,6 @@
<Import Project="..\dir.props" />
<PropertyGroup>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<IsDesktopFacade>true</IsDesktopFacade>
</PropertyGroup>
</Project>

View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<ItemGroup>
<Project Include="System.IO.Pipes.AccessControl.pkgproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" />
</Project>

View File

@@ -5,7 +5,7 @@
<ProjectReference Include="..\ref\System.IO.Pipes.AccessControl.csproj">
<SupportedFramework>net46;netcoreapp1.0</SupportedFramework>
</ProjectReference>
<ProjectReference Include="..\src\System.IO.Pipes.AccessControl.builds" />
<ProjectReference Include="..\src\System.IO.Pipes.AccessControl.csproj" />
<NotSupportedOnTargetFramework Include="netcore50">
<PackageTargetRuntime>win</PackageTargetRuntime>
</NotSupportedOnTargetFramework>

View File

@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<ProjectGuid>{994DCE47-4CF6-479D-AB1D-4EA6A2809C34}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
<ItemGroup>

View File

@@ -2,7 +2,7 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
net46-Windows_NT;
netfx-Windows_NT;
netstandard-Windows_NT;
netstandard-Unix;
</BuildConfigurations>

View File

@@ -1,64 +1,5 @@
<?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">
@@ -126,4 +67,7 @@
<data name="InvalidOperation_PipeNotYetConnected" xml:space="preserve">
<value>Pipe is not connected.</value>
</data>
<data name="IO_IO_PipeBroken" xml:space="preserve">
<value>Pipe is broken.</value>
</data>
</root>

View File

@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<AssemblyName>System.IO.Pipes.AccessControl</AssemblyName>
<ProjectGuid>{D77FBA6C-1AA6-45A4-93E2-97A370672C53}</ProjectGuid>
<ProjectGuid>{40059634-BB03-4A6F-8657-CCE2D376BC8B}</ProjectGuid>
<AllowUnsafeBlocks Condition="'$(TargetGroup)'=='netstandard'">true</AllowUnsafeBlocks>
<GeneratePlatformNotSupportedAssembly Condition="'$(TargetsUnix)' == 'true'">true</GeneratePlatformNotSupportedAssembly>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)'=='net46'">true</IsPartialFacadeAssembly>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)'=='netfx'">true</IsPartialFacadeAssembly>
</PropertyGroup>
<!-- Default configurations to help VS understand the options -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='net46-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='net46-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netfx-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netfx-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Unix-Debug|AnyCPU'" />
@@ -22,14 +22,14 @@
<Compile Include="System\IO\PipeAuditRule.cs" />
<Compile Include="System\IO\PipesAclExtensions.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)'=='net46' AND '$(TargetsWindows)'=='true'">
<TargetingPackReference Include="mscorlib" />
<TargetingPackReference Include="System.Core" />
<ItemGroup Condition="'$(TargetGroup)'=='netfx'">
<Reference Include="mscorlib" />
<Reference Include="System.Core" />
<Compile Include="System\IO\PipesAclExtensions.net46.cs" />
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetGroup)'!='netfx'">
<Reference Include="System.Security.AccessControl" />
<Reference Include="System.Security.Principal.Windows" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>

View File

@@ -12,28 +12,31 @@ namespace System.IO.Pipes
[System.Security.SecurityCritical]
public static PipeSecurity GetAccessControl(this PipeStream stream)
{
// PipeState can not be Closed and the Handle can not be null or closed
var handle = stream.SafePipeHandle; // A non-null, open handle implies a non-closed PipeState.
// Checks that State != WaitingToConnect and State != Closed
var handle = stream.SafePipeHandle;
// PipeState must be Disconnected, Connected, or Broken
return new PipeSecurity(handle, AccessControlSections.Access | AccessControlSections.Owner | AccessControlSections.Group);
}
[System.Security.SecurityCritical]
public static void SetAccessControl(this PipeStream stream, PipeSecurity pipeSecurity)
{
// PipeState can not be Closed and the Handle can not be null or closed
if (pipeSecurity == null)
{
throw new ArgumentNullException(nameof(pipeSecurity));
}
var handle = stream.SafePipeHandle; // A non-null, open handle implies a non-closed PipeState.
// Checks that State != WaitingToConnect and State != Closed
var handle = stream.SafePipeHandle;
// NamedPipeClientStream: PipeState can not be WaitingToConnect or Broken. WaitingToConnect is covered by the SafePipeHandle check.
if (stream is NamedPipeClientStream && !stream.IsConnected) // Pipe could also be WaitingToConnect, Broken, Disconnected, or Closed.
// Checks that State != Broken
if (stream is NamedPipeClientStream && !stream.IsConnected)
{
throw new InvalidOperationException(SR.InvalidOperation_PipeNotYetConnected);
throw new IOException(SR.IO_IO_PipeBroken);
}
// PipeState must be either Disconected or Connected
pipeSecurity.Persist(handle);
}
}

View File

@@ -2,7 +2,7 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
netstandard1.3-Windows_NT;
netstandard-Windows_NT;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@@ -28,23 +28,98 @@ namespace System.IO.Pipes.Tests
}
[Fact]
public void GetAccessControl_NamedPipe_BeforeWaitingToConnect()
public void SetAccessControl_NamedPipeStream()
{
string pipeName = GetUniquePipeName();
var server = new NamedPipeServerStream(pipeName, PipeDirection.Out, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
var client = new NamedPipeClientStream(".", pipeName, PipeDirection.In, PipeOptions.Asynchronous);
Task clientConnect = client.ConnectAsync();
server.WaitForConnection();
clientConnect.Wait();
Assert.NotNull(server.GetAccessControl());
server.SetAccessControl(new PipeSecurity());
Assert.NotNull(client.GetAccessControl());
client.SetAccessControl(new PipeSecurity());
}
[Fact]
public void SetAccessControl_NamedPipeStream_BeforeWaitingToConnect()
{
string pipeName = GetUniquePipeName();
var server = new NamedPipeServerStream(pipeName, PipeDirection.Out, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
var client = new NamedPipeClientStream(".", pipeName, PipeDirection.In, PipeOptions.Asynchronous);
// ServerStream.State = WaitingToConnect, ClientStream.State = WaitingToConnect
Assert.NotNull(server.GetAccessControl());
server.SetAccessControl(new PipeSecurity());
Assert.Throws<InvalidOperationException>(() => client.GetAccessControl());
Assert.Throws<InvalidOperationException>(() => client.SetAccessControl(new PipeSecurity()));
}
/// <summary>
/// Tests that SetAccessControl on a Broken NamedPipeClientStream throws an Exception.
/// </summary>
[Fact]
public void GetAccessControl_NamedPipeClientStream_Broken()
public void SetAccessControl_NamedPipeStream_ClientDisposed()
{
string pipeName = GetUniquePipeName();
var server = new NamedPipeServerStream(pipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
var client = new NamedPipeClientStream(".", pipeName, PipeDirection.InOut, PipeOptions.Asynchronous);
Task clientConnect = client.ConnectAsync();
server.WaitForConnection();
clientConnect.Wait();
// ServerStream.State = Broken, ClientStream.State = Closed
client.Dispose();
Assert.Throws<IOException>(() => server.Write(new byte[] { 0 }, 0, 1)); // Sets the servers PipeState to Broken
Assert.NotNull(server.GetAccessControl());
server.SetAccessControl(new PipeSecurity());
Assert.Throws<ObjectDisposedException>(() => client.GetAccessControl());
Assert.Throws<ObjectDisposedException>(() => client.SetAccessControl(new PipeSecurity()));
}
[Fact]
public void SetAccessControl_NamedPipeStream_ClientHandleClosed()
{
string pipeName = GetUniquePipeName();
var server = new NamedPipeServerStream(pipeName, PipeDirection.Out, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
var client = new NamedPipeClientStream(".", pipeName, PipeDirection.In, PipeOptions.Asynchronous);
Task clientConnect = client.ConnectAsync();
server.WaitForConnection();
clientConnect.Wait();
// ServerStream.State = Broken, ClientStream.State = Closed
client.SafePipeHandle.Close();
Assert.Throws<IOException>(() => server.Write(new byte[] { 0 }, 0, 1));
Assert.NotNull(server.GetAccessControl());
server.SetAccessControl(new PipeSecurity());
Assert.Throws<ObjectDisposedException>(() => client.GetAccessControl());
Assert.Throws<ObjectDisposedException>(() => client.SetAccessControl(new PipeSecurity()));
}
[Fact]
public void SetAccessControl_NamedPipeStream_ServerDisconnected()
{
string pipeName = GetUniquePipeName();
var server = new NamedPipeServerStream(pipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
var client = new NamedPipeClientStream(".", pipeName, PipeDirection.InOut, PipeOptions.Asynchronous);
Task clientConnect = client.ConnectAsync();
server.WaitForConnection();
clientConnect.Wait();
// ServerStream.State = Disconnected, ClientStream.State = Broken
server.Disconnect();
Assert.Throws<IOException>(() => client.Write(new byte[] { 0 }, 0, 1));
Assert.NotNull(server.GetAccessControl());
server.SetAccessControl(new PipeSecurity());
Assert.Throws<InvalidOperationException>(() => client.GetAccessControl());
Assert.Throws<IOException>(() => client.SetAccessControl(new PipeSecurity()));
}
[Fact]
public void SetAccessControl_NamedPipeStream_ServerDisposed()
{
string pipeName = GetUniquePipeName();
var server = new NamedPipeServerStream(pipeName, PipeDirection.In, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
@@ -54,38 +129,33 @@ namespace System.IO.Pipes.Tests
server.WaitForConnection();
clientConnect.Wait();
Assert.NotNull(server.GetAccessControl());
server.SetAccessControl(new PipeSecurity());
Assert.NotNull(client.GetAccessControl());
client.SetAccessControl(new PipeSecurity());
// ServerStream.State = Closed, ClientStream.State = Broken
server.Dispose();
Assert.Throws<IOException>(() => client.Write(new byte[] { 0 }, 0, 1)); // Sets the clients PipeState to Broken
Assert.Throws<InvalidOperationException>(() => client.SetAccessControl(new PipeSecurity()));
Assert.Throws<IOException>(() => client.Write(new byte[] { 0 }, 0, 1));
Assert.Throws<ObjectDisposedException>(() => server.GetAccessControl());
Assert.Throws<ObjectDisposedException>(() => server.SetAccessControl(new PipeSecurity()));
Assert.NotNull(client.GetAccessControl());
Assert.Throws<IOException>(() => client.SetAccessControl(new PipeSecurity()));
}
/// <summary>
/// Tests that SetAccessControl on a Broken NamedPipeServerStream succeeds
/// </summary>
[Fact]
public void GetAccessControl_NamedPipeServerStream_Broken()
public void SetAccessControl_NamedPipeStream_ServerHandleClosed()
{
string pipeName = GetUniquePipeName();
var server = new NamedPipeServerStream(pipeName, PipeDirection.Out, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
var client = new NamedPipeClientStream(".", pipeName, PipeDirection.In, PipeOptions.Asynchronous);
var server = new NamedPipeServerStream(pipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
var client = new NamedPipeClientStream(".", pipeName, PipeDirection.InOut, PipeOptions.Asynchronous);
Task clientConnect = client.ConnectAsync();
server.WaitForConnection();
clientConnect.Wait();
Assert.NotNull(server.GetAccessControl());
server.SetAccessControl(new PipeSecurity());
// ServerStream.State = Closed, ClientStream.State = Broken
server.SafePipeHandle.Close();
Assert.Throws<IOException>(() => client.Write(new byte[] { 0 }, 0, 1));
Assert.Throws<ObjectDisposedException>(() => server.GetAccessControl());
Assert.Throws<ObjectDisposedException>(() => server.SetAccessControl(new PipeSecurity()));
Assert.NotNull(client.GetAccessControl());
client.SetAccessControl(new PipeSecurity());
client.Dispose();
Assert.Throws<IOException>(() => server.Write(new byte[] { 0 }, 0, 1)); // Sets the servers PipeState to Broken
server.SetAccessControl(new PipeSecurity());
Assert.Throws<IOException>(() => client.SetAccessControl(new PipeSecurity()));
}
}
}

View File

@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<ItemGroup>
<Project Include="System.IO.Pipes.AccessControl.Tests.csproj">
<OSGroup>Windows_NT</OSGroup>
<TestTFMs>netcoreapp;netcoreapp1.0;net46</TestTFMs>
</Project>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" />
</Project>

View File

@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<ProjectGuid>{57E8F8D4-0766-4CC7-B3F9-B243B81DB6A5}</ProjectGuid>
<ProjectGuid>{A0356E61-19E1-4722-A53D-5D2616E16312}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard1.3-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard1.3-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="AnonymousPipeTests\AnonymousPipeTest.AclExtensions.cs" />
<Compile Include="NamedPipeTests\NamedPipeTest.AclExtensions.cs" />
@@ -19,4 +19,4 @@
</Compile>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>