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

@@ -2,7 +2,8 @@
<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>
<IsUAP>true</IsUAP>
</PropertyGroup>

View File

@@ -76,4 +76,13 @@
<data name="Thread_GetSetCompressedStack_NotSupported" xml:space="preserve">
<value>Use CompressedStack.(Capture/Run) instead.</value>
</data>
<data name="PlatformNotSupported_COMInterop" xml:space="preserve">
<value>COM interop is not supported on this platform.</value>
</data>
<data name="PlatformNotSupported_ThreadAbort" xml:space="preserve">
<value>Thread abort is not supported on this platform.</value>
</data>
<data name="PlatformNotSupported_ThreadSuspend" xml:space="preserve">
<value>Thread suspend is not supported on this platform.</value>
</data>
</root>

View File

@@ -7,7 +7,6 @@
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<ProjectGuid>{06197EED-FF48-43F3-976D-463839D43E8C}</ProjectGuid>
</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'" />
@@ -22,7 +21,6 @@
<Compile Include="System\Threading\Thread.cs" />
<Compile Include="System\Threading\Thread.Unix.cs" Condition="'$(TargetsUnix)' == 'true'" />
<Compile Include="System\Threading\Thread.Windows.cs" Condition="'$(TargetsWindows)' == 'true'" />
<Compile Include="System\Threading\ThreadAbortException.cs" />
<Compile Include="System\Threading\ThreadExceptionEventArgs.cs" />
</ItemGroup>
<ItemGroup>

View File

@@ -13,16 +13,9 @@ namespace System.Threading
{
}
private CompressedStack(SerializationInfo info, StreamingContext context)
{
}
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)
{
throw new ArgumentNullException(nameof(info));
}
throw new PlatformNotSupportedException();
}
public static CompressedStack Capture()

View File

@@ -9,7 +9,7 @@ namespace System.Threading
public sealed partial class Thread
{
public ApartmentState GetApartmentState() => ApartmentState.Unknown;
private static Exception GetApartmentStateChangeFailedException() => new PlatformNotSupportedException();
private static Exception GetApartmentStateChangeFailedException() => new PlatformNotSupportedException(SR.PlatformNotSupported_COMInterop);
private bool TrySetApartmentStateUnchecked(ApartmentState state) => state == GetApartmentState();
public void DisableComObjectEagerCleanup() { }

View File

@@ -174,29 +174,29 @@ namespace System.Threading
public void Abort()
{
throw new PlatformNotSupportedException();
throw new PlatformNotSupportedException(SR.PlatformNotSupported_ThreadAbort);
}
public void Abort(object stateInfo)
{
throw new PlatformNotSupportedException();
throw new PlatformNotSupportedException(SR.PlatformNotSupported_ThreadAbort);
}
public static void ResetAbort()
{
throw new PlatformNotSupportedException();
throw new PlatformNotSupportedException(SR.PlatformNotSupported_ThreadAbort);
}
[ObsoleteAttribute("Thread.Suspend has been deprecated. Please use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources. http://go.microsoft.com/fwlink/?linkid=14202", false)]
public void Suspend()
{
throw new PlatformNotSupportedException();
throw new PlatformNotSupportedException(SR.PlatformNotSupported_ThreadSuspend);
}
[ObsoleteAttribute("Thread.Resume has been deprecated. Please use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources. http://go.microsoft.com/fwlink/?linkid=14202", false)]
public void Resume()
{
throw new PlatformNotSupportedException();
throw new PlatformNotSupportedException(SR.PlatformNotSupported_ThreadSuspend);
}
// Currently, no special handling is done for critical regions, and no special handling is necessary to ensure thread

View File

@@ -1,23 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Runtime.Serialization;
namespace System.Threading
{
// Thread.Abort() is not supported in .NET Core, so this is currently just a stub to make the type available at compile time
[Serializable]
public sealed class ThreadAbortException : SystemException
{
private ThreadAbortException()
{
}
private ThreadAbortException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
public object ExceptionState => null;
}
}

View File

@@ -12,9 +12,12 @@
<Compile Include="CompressedStackTests.cs" />
<Compile Include="ExceptionTests.cs" />
<Compile Include="ThreadExceptionEventArgsTests.cs" />
<Compile Include="ThreadTests.netstandard.cs" />
<Compile Include="ThreadTests.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(CommonTestPath)\System\PlatformDetection.cs">
<Link>Common\System\PlatformDetection.cs</Link>
</Compile>
<Compile Include="$(CommonTestPath)\System\Threading\ThreadTestHelpers.cs">
<Link>CommonTest\System\Threading\ThreadPoolHelpers.cs</Link>
</Compile>

View File

@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
@@ -141,6 +142,7 @@ namespace System.Threading.Threads.Tests
[Theory]
[MemberData(nameof(ApartmentStateTest_MemberData))]
[PlatformSpecific(TestPlatforms.Windows)] // Expected behavior differs on Unix and Windows
[ActiveIssue(20766,TargetFrameworkMonikers.UapAot)]
public static void GetSetApartmentStateTest_ChangeAfterThreadStarted_Windows(
Func<Thread, ApartmentState> getApartmentState,
Func<Thread, ApartmentState, int> setApartmentState,
@@ -163,6 +165,7 @@ namespace System.Threading.Threads.Tests
[Theory]
[MemberData(nameof(ApartmentStateTest_MemberData))]
[PlatformSpecific(TestPlatforms.Windows)] // Expected behavior differs on Unix and Windows
[ActiveIssue(20766,TargetFrameworkMonikers.UapAot)]
public static void ApartmentStateTest_ChangeBeforeThreadStarted_Windows(
Func<Thread, ApartmentState> getApartmentState,
Func<Thread, ApartmentState, int> setApartmentState,
@@ -178,7 +181,17 @@ namespace System.Threading.Threads.Tests
Assert.Equal(ApartmentState.STA, getApartmentState(t));
t.Start();
Assert.True(t.Join(UnexpectedTimeoutMilliseconds));
Assert.Equal(ApartmentState.STA, apartmentStateInThread);
if (PlatformDetection.IsWindowsNanoServer)
{
// Nano server threads are always MTA. If you set the thread to STA
// it will read back as STA but when the thread starts it will read back as MTA.
Assert.Equal(ApartmentState.MTA, apartmentStateInThread);
}
else
{
Assert.Equal(ApartmentState.STA, apartmentStateInThread);
}
}
[Theory]
@@ -413,6 +426,7 @@ namespace System.Threading.Threads.Tests
}
[Fact]
[ActiveIssue(20766, TargetFrameworkMonikers.UapAot)]
public static void ThreadStateTest()
{
var e0 = new ManualResetEvent(false);
@@ -641,6 +655,7 @@ namespace System.Threading.Threads.Tests
}
[Fact]
[ActiveIssue(20766, TargetFrameworkMonikers.UapAot)]
public static void InterruptTest()
{
// Interrupting a thread that is not blocked does not do anything, but once the thread starts blocking, it gets
@@ -691,6 +706,7 @@ namespace System.Threading.Threads.Tests
[Fact]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
[ActiveIssue(20766,TargetFrameworkMonikers.UapAot)]
public static void InterruptInFinallyBlockTest_SkipOnDesktopFramework()
{
// A wait in a finally block can be interrupted. The desktop framework applies the same rules as thread abort, and
@@ -757,9 +773,11 @@ namespace System.Threading.Threads.Tests
Assert.Throws<ArgumentOutOfRangeException>(() => Thread.Sleep(TimeSpan.FromMilliseconds((double)int.MaxValue + 1)));
Thread.Sleep(0);
var startTime = DateTime.Now;
var stopwatch = Stopwatch.StartNew();
Thread.Sleep(500);
Assert.True((DateTime.Now - startTime).TotalMilliseconds >= 100);
stopwatch.Stop();
Assert.InRange((int)stopwatch.ElapsedMilliseconds, 100, int.MaxValue);
}
[Fact]
@@ -806,6 +824,7 @@ namespace System.Threading.Threads.Tests
}
[Fact]
[ActiveIssue(20766,TargetFrameworkMonikers.UapAot)]
public static void MiscellaneousTest()
{
Thread.BeginCriticalRegion();