Imported Upstream version 5.4.0.167

Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-08-21 15:34:15 +00:00
parent e49d6f06c0
commit 536cd135cc
12856 changed files with 563812 additions and 223249 deletions

View File

@@ -26,10 +26,10 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{861A3318-35AD-46ac-8257-8D5D2479BAD9}.Debug|Any CPU.ActiveCfg = netstandard-Windows_NT-Debug|Any CPU
{861A3318-35AD-46ac-8257-8D5D2479BAD9}.Debug|Any CPU.Build.0 = netstandard-Windows_NT-Debug|Any CPU
{861A3318-35AD-46ac-8257-8D5D2479BAD9}.Release|Any CPU.ActiveCfg = netstandard-Windows_NT-Release|Any CPU
{861A3318-35AD-46ac-8257-8D5D2479BAD9}.Release|Any CPU.Build.0 = netstandard-Windows_NT-Release|Any CPU
{861A3318-35AD-46ac-8257-8D5D2479BAD9}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
{861A3318-35AD-46ac-8257-8D5D2479BAD9}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
{861A3318-35AD-46ac-8257-8D5D2479BAD9}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{861A3318-35AD-46ac-8257-8D5D2479BAD9}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU
{6A07CCB8-3E59-47e7-B3DD-DB1F6FC501D5}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{6A07CCB8-3E59-47e7-B3DD-DB1F6FC501D5}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{6A07CCB8-3E59-47e7-B3DD-DB1F6FC501D5}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU

View File

@@ -2,9 +2,10 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\dir.props" />
<PropertyGroup>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyKey>MSFT</AssemblyKey>
<IsNETCoreApp>true</IsNETCoreApp>
<IsDesktopFacade>true</IsDesktopFacade>
<IsUAP>true</IsUAP>
<IsNetFxNETStandard>true</IsNetFxNETStandard>
</PropertyGroup>
</Project>

View File

@@ -3,8 +3,8 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoWarn Condition="'$(TargetGroup)' == 'netfx'">$(NoWarn);0436</NoWarn>
<ProjectGuid>{F71467DF-30C1-44A0-A15A-163CB5DB4E6E}</ProjectGuid>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx'">true</IsPartialFacadeAssembly>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Release|AnyCPU'" />

View File

@@ -5,11 +5,9 @@
<AssemblyName>System.Threading.Overlapped</AssemblyName>
<ProjectGuid>{6A07CCB8-3E59-47e7-B3DD-DB1F6FC501D5}</ProjectGuid>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPartialFacadeAssembly Condition="'$(TargetsWindows)' == 'true'">true</IsPartialFacadeAssembly>
<GeneratePlatformNotSupportedAssembly Condition="'$(TargetsWindows)' != 'true'">true</GeneratePlatformNotSupportedAssembly>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<GenFacadesIgnoreMissingTypes Condition="'$(TargetGroup)'=='uapaot'">true</GenFacadesIgnoreMissingTypes>
</PropertyGroup>
<!-- Help VS understand available configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Debug|AnyCPU'" />
@@ -31,13 +29,8 @@
<Reference Include="mscorlib" />
<Reference Include="System" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' != 'netfx' and '$(TargetsWindows)' == 'true'">
<ItemGroup Condition="'$(TargetGroup)' != 'netfx'">
<ReferenceFromRuntime Include="System.Private.CoreLib" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsWindows)' != 'true'">
<Reference Include="System.Resources.ResourceManager" />
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Handles" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

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

View File

@@ -8,11 +8,29 @@ using System.Threading;
internal static class DllImport
{
#if !uap
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)]
internal static extern Win32Handle CreateFile(String lpFileName,
FileAccess dwDesiredAccess, FileShare dwShareMode,
IntPtr securityAttrs, CreationDisposition dwCreationDisposition,
FileAttributes dwFlagsAndAttributes, IntPtr hTemplateFile);
#else
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)]
internal static unsafe extern Win32Handle CreateFile2(string lpFileName,
FileAccess dwDesiredAccess, FileShare dwShareMode,
CreationDisposition dwCreationDisposition, CREATEFILE2_EXTENDED_PARAMETERS* pCreateExParams);
[StructLayout(LayoutKind.Sequential)]
internal struct CREATEFILE2_EXTENDED_PARAMETERS
{
internal uint dwSize;
internal FileAttributes dwFileAttributes;
internal FileAttributes dwFileFlags;
internal uint dwSecurityQosFlags;
internal IntPtr lpSecurityAttributes;
internal IntPtr hTemplateFile;
}
#endif
[DllImport("kernel32.dll", SetLastError = true)]
internal static extern unsafe int WriteFile(SafeHandle handle, byte* bytes, int numBytesToWrite, IntPtr numBytesWritten_mustBeZero, NativeOverlapped* lpOverlapped);

View File

@@ -22,9 +22,25 @@ internal static partial class HandleFactory
return CreateHandle(async:true, fileName:fileName);
}
private static Win32Handle CreateHandle(bool async, string fileName = null)
private static unsafe Win32Handle CreateHandle(bool async, string fileName = null)
{
#if !uap
// Assume the current directory is writable
return DllImport.CreateFile(fileName ?? @"Overlapped.tmp", DllImport.FileAccess.GenericWrite, DllImport.FileShare.Write, IntPtr.Zero, DllImport.CreationDisposition.CreateAlways, async ? DllImport.FileAttributes.Overlapped : DllImport.FileAttributes.Normal, IntPtr.Zero);
#else
var p = new DllImport.CREATEFILE2_EXTENDED_PARAMETERS();
p.dwSize = (uint)sizeof(DllImport.CREATEFILE2_EXTENDED_PARAMETERS);
p.dwFileAttributes = DllImport.FileAttributes.Normal;
p.dwFileFlags = async ? DllImport.FileAttributes.Overlapped : DllImport.FileAttributes.Normal;
p.dwSecurityQosFlags = (uint)0;
p.lpSecurityAttributes = IntPtr.Zero;
p.hTemplateFile = IntPtr.Zero;
return DllImport.CreateFile2(
fileName ?? @"Overlapped.tmp",
DllImport.FileAccess.GenericWrite,
DllImport.FileShare.Write,
DllImport.CreationDisposition.CreateAlways,
&p);
#endif
}
}

View File

@@ -145,6 +145,8 @@ public static partial class OverlappedTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPool.UnsafeQueueNativeOverlapped is not supported on Unix
[ActiveIssue("https://github.com/dotnet/corefx/issues/20365", TargetFrameworkMonikers.UapAot)]
public static unsafe void PackPosTest()
{
#pragma warning disable 618
@@ -167,7 +169,10 @@ public static partial class OverlappedTests
}
#pragma warning restore 618
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPool.UnsafeQueueNativeOverlapped is not supported on Unix
[ActiveIssue("https://github.com/dotnet/corefx/issues/20365", TargetFrameworkMonikers.UapAot)]
public static unsafe void PackPosTest1()
{
Overlapped ov = new Overlapped();

View File

@@ -4,10 +4,13 @@
<PropertyGroup>
<ProjectGuid>{861A3318-35AD-46ac-8257-8D5D2479BAD9}</ProjectGuid>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants Condition="'$(TargetGroup)' == 'uap'">$(DefineConstants);uap</DefineConstants>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="DllImport.cs" />
<Compile Include="ThreadPoolBoundHandle_PreAllocatedOverlappedTests.cs" />
@@ -23,6 +26,9 @@
<Compile Include="ThreadPoolBoundHandle_DisposeTests.cs" />
<Compile Include="ThreadPoolBoundHandle_BindHandleTests.cs" />
<Compile Include="OverlappedTests.cs" />
<Compile Include="$(CommonTestPath)\System\AssertExtensions.cs">
<Link>Common\System\AssertExtensions.cs</Link>
</Compile>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>

View File

@@ -10,11 +10,12 @@ using Xunit;
public partial class ThreadPoolBoundHandleTests
{
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void AllocateNativeOverlapped_NullAsCallback_ThrowsArgumentNullException()
{
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
{
Assert.Throws<ArgumentNullException>("callback", () =>
AssertExtensions.Throws<ArgumentNullException>("callback", () =>
{
handle.AllocateNativeOverlapped(null, new object(), new byte[256]);
});
@@ -22,11 +23,12 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void AllocateNativeOverlapped_PreAllocated_ThrowsArgumentNullException()
{
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
{
Assert.Throws<ArgumentNullException>("preAllocated", () =>
AssertExtensions.Throws<ArgumentNullException>("preAllocated", () =>
{
handle.AllocateNativeOverlapped((PreAllocatedOverlapped)null);
});
@@ -34,6 +36,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void AllocateNativeOverlapped_NullAsContext_DoesNotThrow()
{
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
@@ -47,6 +50,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void AllocateNativeOverlapped_NullAsPinData_DoesNotThrow()
{
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
@@ -60,6 +64,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void AllocateNativeOverlapped_EmptyArrayAsPinData_DoesNotThrow()
{
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
@@ -73,6 +78,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void AllocateNativeOverlapped_NonBlittableTypeAsPinData_Throws()
{
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
@@ -82,6 +88,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void AllocateNativeOverlapped_BlittableTypeAsPinData_DoesNotThrow()
{
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
@@ -95,6 +102,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void AllocateNativeOverlapped_ObjectArrayAsPinData_DoesNotThrow()
{
object[] array = new object[]
@@ -113,6 +121,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void AllocateNativeOverlapped_ObjectArrayWithNonBlittableTypeAsPinData_Throws()
{
object[] array = new object[]
@@ -127,6 +136,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void AllocateNativeOverlapped_ReturnedNativeOverlapped_AllFieldsZero()
{
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
@@ -144,6 +154,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void AllocateNativeOverlapped_PreAllocated_ReturnedNativeOverlapped_AllFieldsZero()
{
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
@@ -164,6 +175,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void AllocateNativeOverlapped_PossibleReusedReturnedNativeOverlapped_OffsetLowAndOffsetHighSetToZero()
{ // The CLR reuses NativeOverlapped underneath, check to make sure that they reset fields back to zero
@@ -187,6 +199,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void AllocateNativeOverlapped_PreAllocated_ReusedReturnedNativeOverlapped_OffsetLowAndOffsetHighSetToZero()
{ // The CLR reuses NativeOverlapped underneath, check to make sure that they reset fields back to zero
@@ -211,6 +224,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void AllocateNativeOverlapped_WhenDisposed_ThrowsObjectDisposedException()
{
ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle();
@@ -223,6 +237,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void AllocateNativeOverlapped_PreAllocated_WhenDisposed_ThrowsObjectDisposedException()
{
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
@@ -238,6 +253,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void AllocateNativeOverlapped_PreAllocated_WhenHandleDisposed_ThrowsObjectDisposedException()
{
ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle();
@@ -252,6 +268,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void AllocateNativeOverlapped_PreAllocated_WhenAlreadyAllocated_ThrowsArgumentException()
{
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())

View File

@@ -12,7 +12,7 @@ public partial class ThreadPoolBoundHandleTests
[Fact]
public void BindHandle_NullAsHandle_ThrowsArgumentNullException()
{
Assert.Throws<ArgumentNullException>("handle", () =>
AssertExtensions.Throws<ArgumentNullException>("handle", () =>
{
ThreadPoolBoundHandle.BindHandle((SafeHandle)null);
});
@@ -23,7 +23,7 @@ public partial class ThreadPoolBoundHandleTests
{
using(SafeHandle handle = HandleFactory.CreateHandle(IntPtr.Zero))
{
Assert.Throws<ArgumentException>("handle", () =>
AssertExtensions.Throws<ArgumentException>("handle", () =>
{
ThreadPoolBoundHandle.BindHandle(handle);
});
@@ -35,7 +35,7 @@ public partial class ThreadPoolBoundHandleTests
{
using(SafeHandle handle = HandleFactory.CreateHandle(new IntPtr(-1)))
{
Assert.Throws<ArgumentException>("handle", () =>
AssertExtensions.Throws<ArgumentException>("handle", () =>
{
ThreadPoolBoundHandle.BindHandle(handle);
});
@@ -43,12 +43,20 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.AnyUnix)]
public void BindHandle_ValidHandle_ThrowsPlatformNotSupportedException()
{
Assert.Throws<PlatformNotSupportedException>(() => ThreadPoolBoundHandle.BindHandle(new Win32Handle(new IntPtr(1))));
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public void BindHandle_SyncHandleAsHandle_ThrowsArgumentException()
{ // Can't bind a handle that was not opened for overlapped I/O
using(SafeHandle handle = HandleFactory.CreateSyncFileHandleFoWrite())
{
Assert.Throws<ArgumentException>("handle", () =>
AssertExtensions.Throws<ArgumentException>("handle", () =>
{
ThreadPoolBoundHandle.BindHandle(handle);
});
@@ -56,13 +64,14 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public void BindHandle_ClosedSyncHandleAsHandle_ThrowsArgumentException()
{
using(Win32Handle handle = HandleFactory.CreateSyncFileHandleFoWrite())
{
handle.CloseWithoutDisposing();
Assert.Throws<ArgumentException>("handle", () =>
AssertExtensions.Throws<ArgumentException>("handle", () =>
{
ThreadPoolBoundHandle.BindHandle(handle);
});
@@ -70,13 +79,14 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public void BindHandle_ClosedAsyncHandleAsHandle_ThrowsArgumentException()
{
using(Win32Handle handle = HandleFactory.CreateAsyncFileHandleForWrite())
{
handle.CloseWithoutDisposing();
Assert.Throws<ArgumentException>("handle", () =>
AssertExtensions.Throws<ArgumentException>("handle", () =>
{
ThreadPoolBoundHandle.BindHandle(handle);
});
@@ -84,12 +94,13 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public void BindHandle_DisposedSyncHandleAsHandle_ThrowsArgumentException()
{
Win32Handle handle = HandleFactory.CreateSyncFileHandleFoWrite();
handle.Dispose();
Assert.Throws<ArgumentException>("handle", () =>
AssertExtensions.Throws<ArgumentException>("handle", () =>
{
ThreadPoolBoundHandle.BindHandle(handle);
});
@@ -97,18 +108,20 @@ public partial class ThreadPoolBoundHandleTests
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public void BindHandle_DisposedAsyncHandleAsHandle_ThrowsArgumentException()
{
Win32Handle handle = HandleFactory.CreateAsyncFileHandleForWrite();
handle.Dispose();
Assert.Throws<ArgumentException>("handle", () =>
AssertExtensions.Throws<ArgumentException>("handle", () =>
{
ThreadPoolBoundHandle.BindHandle(handle);
});
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public void BindHandle_AlreadyBoundHandleAsHandle_ThrowsArgumentException()
{
using(SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite())
@@ -116,7 +129,7 @@ public partial class ThreadPoolBoundHandleTests
// Once
ThreadPoolBoundHandle.BindHandle(handle);
Assert.Throws<ArgumentException>("handle", () =>
AssertExtensions.Throws<ArgumentException>("handle", () =>
{
// Twice
ThreadPoolBoundHandle.BindHandle(handle);

View File

@@ -8,6 +8,7 @@ using Xunit;
public partial class ThreadPoolBoundHandleTests
{
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public void Dispose_CalledMultipleTimes_DoesNotThrow()
{
ThreadPoolBoundHandle boundHandle = CreateThreadPoolBoundHandle();
@@ -17,6 +18,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public void Dispose_DoesNotDisposeHandle()
{
ThreadPoolBoundHandle boundHandle = CreateThreadPoolBoundHandle();
@@ -29,6 +31,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void Dispose_WithoutFreeingNativeOverlapped_DoesNotThrow()
{
ThreadPoolBoundHandle boundHandle = CreateThreadPoolBoundHandle();

View File

@@ -9,11 +9,12 @@ using Xunit;
public partial class ThreadPoolBoundHandleTests
{
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void FreeNativeOverlapped_NullAsNativeOverlapped_ThrowsArgumentNullException()
{
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
{
Assert.Throws<ArgumentNullException>("overlapped", () =>
AssertExtensions.Throws<ArgumentNullException>("overlapped", () =>
{
handle.FreeNativeOverlapped((NativeOverlapped*)null);
});
@@ -21,6 +22,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void FreeNativeOverlapped_WhenDisposed_DoesNotThrow()
{
ThreadPoolBoundHandle boundHandle = CreateThreadPoolBoundHandle();
@@ -30,6 +32,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void FreeNativeOverlapped_WithWrongHandle_ThrowsArgumentException()
{
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())

View File

@@ -12,13 +12,14 @@ public partial class ThreadPoolBoundHandleTests
[Fact]
public unsafe void GetNativeOverlappedState_NullAsNativeOverlapped_ThrowsArgumentNullException()
{
Assert.Throws<ArgumentNullException>("overlapped", () =>
AssertExtensions.Throws<ArgumentNullException>("overlapped", () =>
{
ThreadPoolBoundHandle.GetNativeOverlappedState((NativeOverlapped*)null);
});
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void GetNativeOverlappedState_WhenUnderlyingStateIsNull_ReturnsNull()
{
using(SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite())
@@ -37,6 +38,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void GetNativeOverlappedState_WhenUnderlyingStateIsObject_ReturnsObject()
{
object context = new object();
@@ -57,6 +59,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void GetNativeOverlappedState_WhenUnderlyingStateIsIAsyncResult_ReturnsIAsyncResult()
{ // CoreCLR/Desktop CLR version of overlapped sits on top of Overlapped class
// and treats IAsyncResult specially, which is why we special case this case.

View File

@@ -9,6 +9,7 @@ using Xunit;
public partial class ThreadPoolBoundHandleTests
{
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public void Handle_ReturnsHandle()
{
using(SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite())
@@ -21,6 +22,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public void Handle_AfterDisposed_DoesNotThrow()
{
using(SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite())

View File

@@ -10,6 +10,7 @@ using Xunit;
public partial class ThreadPoolBoundHandleTests
{
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void SingleOperationOverSingleHandle()
{
const int DATA_SIZE = 2;
@@ -47,6 +48,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void MultipleOperationsOverSingleHandle()
{
const int DATA_SIZE = 2;
@@ -104,6 +106,7 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void MultipleOperationsOverMultipleHandles()
{
const int DATA_SIZE = 2;
@@ -175,6 +178,8 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Active Issue dotnet/corefx#13343")]
public unsafe void FlowsAsyncLocalsToCallback()
{ // Makes sure that we flow async locals to callback

View File

@@ -12,7 +12,7 @@ public partial class ThreadPoolBoundHandleTests
[Fact]
public unsafe void PreAllocatedOverlapped_NullAsCallback_ThrowsArgumentNullException()
{
Assert.Throws<ArgumentNullException>("callback", () =>
AssertExtensions.Throws<ArgumentNullException>("callback", () =>
{
new PreAllocatedOverlapped(null, new object(), new byte[256]);
});