You've already forked linux-packaging-mono
Imported Upstream version 5.10.0.69
Former-commit-id: fc39669a0b707dd3c063977486506b6793da2890
This commit is contained in:
parent
d8f8abd549
commit
e2950ec768
8
external/corefx/src/System.Threading.Thread/tests/MTAMain/Configurations.props
vendored
Normal file
8
external/corefx/src/System.Threading.Thread/tests/MTAMain/Configurations.props
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<BuildConfigurations>
|
||||
netstandard;
|
||||
</BuildConfigurations>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
54
external/corefx/src/System.Threading.Thread/tests/MTAMain/MTAMain.cs
vendored
Normal file
54
external/corefx/src/System.Threading.Thread/tests/MTAMain/MTAMain.cs
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
// 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;
|
||||
using System.Threading;
|
||||
|
||||
namespace MTAMain
|
||||
{
|
||||
internal static class MTAMain
|
||||
{
|
||||
[MTAThread]
|
||||
static int Main(string[] args)
|
||||
{
|
||||
const int Success = 0;
|
||||
const int SuccessOnUnix = 2;
|
||||
const int Failure = 1;
|
||||
|
||||
string mode = args[0];
|
||||
int retValue = Failure;
|
||||
Thread curThread = Thread.CurrentThread;
|
||||
|
||||
if (mode == "GetApartmentState")
|
||||
{
|
||||
if (curThread.GetApartmentState() == ApartmentState.MTA)
|
||||
{
|
||||
curThread.SetApartmentState(ApartmentState.MTA);
|
||||
retValue = Success;
|
||||
}
|
||||
else
|
||||
{
|
||||
retValue = SuccessOnUnix;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
curThread.SetApartmentState(ApartmentState.STA);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
retValue = Success;
|
||||
}
|
||||
catch (PlatformNotSupportedException)
|
||||
{
|
||||
retValue = SuccessOnUnix;
|
||||
}
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
23
external/corefx/src/System.Threading.Thread/tests/MTAMain/MTAMain.csproj
vendored
Normal file
23
external/corefx/src/System.Threading.Thread/tests/MTAMain/MTAMain.csproj
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?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>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<ProjectGuid>{06B19C7D-9EBE-420F-BD33-137DB18A1FEB}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
|
||||
<ItemGroup>
|
||||
<Compile Include="MTAMain.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="MTAMain.runtimeconfig.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="MTAMain.exe.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
6
external/corefx/src/System.Threading.Thread/tests/MTAMain/MTAMain.exe.config
vendored
Normal file
6
external/corefx/src/System.Threading.Thread/tests/MTAMain/MTAMain.exe.config
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<developmentMode developerInstallation="true" />
|
||||
</runtime>
|
||||
</configuration>
|
||||
8
external/corefx/src/System.Threading.Thread/tests/MTAMain/MTAMain.runtimeconfig.json
vendored
Normal file
8
external/corefx/src/System.Threading.Thread/tests/MTAMain/MTAMain.runtimeconfig.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"framework": {
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "9.9.9"
|
||||
}
|
||||
}
|
||||
}
|
||||
8
external/corefx/src/System.Threading.Thread/tests/STAMain/Configurations.props
vendored
Normal file
8
external/corefx/src/System.Threading.Thread/tests/STAMain/Configurations.props
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<BuildConfigurations>
|
||||
netstandard;
|
||||
</BuildConfigurations>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
54
external/corefx/src/System.Threading.Thread/tests/STAMain/STAMain.cs
vendored
Normal file
54
external/corefx/src/System.Threading.Thread/tests/STAMain/STAMain.cs
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
// 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;
|
||||
using System.Threading;
|
||||
|
||||
namespace STAMain
|
||||
{
|
||||
internal static class STAMain
|
||||
{
|
||||
[STAThread]
|
||||
static int Main(string[] args)
|
||||
{
|
||||
const int Success = 0;
|
||||
const int SuccessOnUnix = 2;
|
||||
const int Failure = 1;
|
||||
|
||||
string mode = args[0];
|
||||
int retValue = Failure;
|
||||
Thread curThread = Thread.CurrentThread;
|
||||
|
||||
if (mode == "GetApartmentState")
|
||||
{
|
||||
if (curThread.GetApartmentState() == ApartmentState.STA)
|
||||
{
|
||||
curThread.SetApartmentState(ApartmentState.STA);
|
||||
retValue = Success;
|
||||
}
|
||||
else
|
||||
{
|
||||
retValue = SuccessOnUnix;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
curThread.SetApartmentState(ApartmentState.MTA);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
retValue = Success;
|
||||
}
|
||||
catch (PlatformNotSupportedException)
|
||||
{
|
||||
retValue = SuccessOnUnix;
|
||||
}
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
external/corefx/src/System.Threading.Thread/tests/STAMain/STAMain.csproj
vendored
Normal file
21
external/corefx/src/System.Threading.Thread/tests/STAMain/STAMain.csproj
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?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>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<ProjectGuid>{8045E634-C181-4C6C-AE48-71AC18D1C637}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
|
||||
<ItemGroup>
|
||||
<Compile Include="STAMain.cs" />
|
||||
<Content Include="STAMain.runtimeconfig.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="STAMain.exe.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
6
external/corefx/src/System.Threading.Thread/tests/STAMain/STAMain.exe.config
vendored
Normal file
6
external/corefx/src/System.Threading.Thread/tests/STAMain/STAMain.exe.config
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<developmentMode developerInstallation="true" />
|
||||
</runtime>
|
||||
</configuration>
|
||||
8
external/corefx/src/System.Threading.Thread/tests/STAMain/STAMain.runtimeconfig.json
vendored
Normal file
8
external/corefx/src/System.Threading.Thread/tests/STAMain/STAMain.runtimeconfig.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"framework": {
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "9.9.9"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
<?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>{33F5A50E-B823-4FDD-8571-365C909ACEAE}</ProjectGuid>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<!-- Default configurations to help VS understand the configurations -->
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Release|AnyCPU'" />
|
||||
<ItemGroup>
|
||||
@@ -18,6 +17,16 @@
|
||||
<Compile Include="$(CommonTestPath)\System\Threading\ThreadTestHelpers.cs">
|
||||
<Link>CommonTest\System\Threading\ThreadPoolHelpers.cs</Link>
|
||||
</Compile>
|
||||
<ProjectReference Include="$(CommonTestPath)\System\Diagnostics\RemoteExecutorConsoleApp\RemoteExecutorConsoleApp.csproj">
|
||||
<Project>{69e46a6f-9966-45a5-8945-2559fe337827}</Project>
|
||||
<Name>RemoteExecutorConsoleApp</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="STAMain\STAMain.csproj">
|
||||
<Name>STAMain</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="MTAMain\MTAMain.csproj">
|
||||
<Name>MTAMain</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -13,7 +13,12 @@ using Xunit;
|
||||
|
||||
namespace System.Threading.Threads.Tests
|
||||
{
|
||||
public static class ThreadTests
|
||||
public class DummyClass : RemoteExecutorTestBase
|
||||
{
|
||||
public static string HostRunnerTest = HostRunner;
|
||||
}
|
||||
|
||||
public static class ThreadTests
|
||||
{
|
||||
private const int UnexpectedTimeoutMilliseconds = ThreadTestHelpers.UnexpectedTimeoutMilliseconds;
|
||||
private const int ExpectedTimeoutMilliseconds = ThreadTestHelpers.ExpectedTimeoutMilliseconds;
|
||||
@@ -139,6 +144,105 @@ namespace System.Threading.Threads.Tests
|
||||
};
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))]
|
||||
[InlineData("STAMain.exe", "GetApartmentState")]
|
||||
[InlineData("STAMain.exe", "SetApartmentState")]
|
||||
[InlineData("MTAMain.exe", "GetApartmentState")]
|
||||
[InlineData("MTAMain.exe", "SetApartmentState")]
|
||||
[ActiveIssue(20766, TargetFrameworkMonikers.Uap)]
|
||||
public static void ApartmentState_AttributePresent(string AppName, string mode)
|
||||
{
|
||||
var psi = new ProcessStartInfo();
|
||||
if (PlatformDetection.IsFullFramework || PlatformDetection.IsNetNative)
|
||||
{
|
||||
psi.FileName = AppName;
|
||||
psi.Arguments = $"{mode}";
|
||||
}
|
||||
else
|
||||
{
|
||||
psi.FileName = DummyClass.HostRunnerTest;
|
||||
psi.Arguments = $"{AppName} {mode}";
|
||||
}
|
||||
using (Process p = Process.Start(psi))
|
||||
{
|
||||
p.WaitForExit();
|
||||
Assert.Equal(PlatformDetection.IsWindows ? 0 : 2, p.ExitCode);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20766,TargetFrameworkMonikers.UapAot)]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public static void ApartmentState_NoAttributePresent_DefaultState_Windows()
|
||||
{
|
||||
DummyClass.RemoteInvoke(() =>
|
||||
{
|
||||
Assert.Equal(ApartmentState.MTA, Thread.CurrentThread.GetApartmentState());
|
||||
Assert.Throws<InvalidOperationException>(() => Thread.CurrentThread.SetApartmentState(ApartmentState.STA));
|
||||
Thread.CurrentThread.SetApartmentState(ApartmentState.MTA);
|
||||
}).Dispose();
|
||||
}
|
||||
|
||||
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))]
|
||||
[ActiveIssue(20766,TargetFrameworkMonikers.UapAot)]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
|
||||
public static void ApartmentState_NoAttributePresent_STA_Windows_Core()
|
||||
{
|
||||
DummyClass.RemoteInvoke(() =>
|
||||
{
|
||||
Thread.CurrentThread.SetApartmentState(ApartmentState.STA);
|
||||
Assert.Equal(ApartmentState.STA, Thread.CurrentThread.GetApartmentState());
|
||||
Assert.Throws<InvalidOperationException>(() => Thread.CurrentThread.SetApartmentState(ApartmentState.MTA));
|
||||
}).Dispose();
|
||||
}
|
||||
|
||||
// The Thread Apartment State is set to MTA if attribute is not specified on main function
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
|
||||
public static void ApartmentState_NoAttributePresent_STA_Windows_Desktop()
|
||||
{
|
||||
DummyClass.RemoteInvoke(() =>
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => Thread.CurrentThread.SetApartmentState(ApartmentState.STA));
|
||||
Thread.CurrentThread.SetApartmentState(ApartmentState.MTA);
|
||||
Assert.Equal(ApartmentState.MTA, Thread.CurrentThread.GetApartmentState());
|
||||
}).Dispose();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.AnyUnix)]
|
||||
public static void ApartmentState_NoAttributePresent_DefaultState_Unix()
|
||||
{
|
||||
DummyClass.RemoteInvoke(() =>
|
||||
{
|
||||
Assert.Equal(ApartmentState.Unknown, Thread.CurrentThread.GetApartmentState());
|
||||
Assert.Throws<PlatformNotSupportedException>(() => Thread.CurrentThread.SetApartmentState(ApartmentState.MTA));
|
||||
}).Dispose();
|
||||
}
|
||||
|
||||
// Thread is always initialized as MTA irrespective of the attribute present.
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsWindowsNanoServer))]
|
||||
public static void ApartmentState_NoAttributePresent_DefaultState_Nano()
|
||||
{
|
||||
DummyClass.RemoteInvoke(() =>
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => Thread.CurrentThread.SetApartmentState(ApartmentState.STA));
|
||||
Assert.Equal(ApartmentState.MTA, Thread.CurrentThread.GetApartmentState());
|
||||
}).Dispose();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[PlatformSpecific(TestPlatforms.AnyUnix)]
|
||||
public static void ApartmentState_NoAttributePresent_STA_Unix()
|
||||
{
|
||||
DummyClass.RemoteInvoke(() =>
|
||||
{
|
||||
Assert.Throws<PlatformNotSupportedException>(() => Thread.CurrentThread.SetApartmentState(ApartmentState.STA));
|
||||
}).Dispose();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(ApartmentStateTest_MemberData))]
|
||||
[PlatformSpecific(TestPlatforms.Windows)] // Expected behavior differs on Unix and Windows
|
||||
@@ -225,6 +329,7 @@ namespace System.Threading.Threads.Tests
|
||||
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Mono)]
|
||||
public static void CurrentCultureTest_SkipOnDesktopFramework()
|
||||
{
|
||||
// Cannot access culture properties on a thread object from a different thread
|
||||
@@ -277,6 +382,7 @@ namespace System.Threading.Threads.Tests
|
||||
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Mono)]
|
||||
public static void CurrentPrincipalTest_SkipOnDesktopFramework()
|
||||
{
|
||||
ThreadTestHelpers.RunTestInBackgroundThread(() => Assert.Null(Thread.CurrentPrincipal));
|
||||
@@ -317,6 +423,7 @@ namespace System.Threading.Threads.Tests
|
||||
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Mono)]
|
||||
public static void ExecutionContextTest()
|
||||
{
|
||||
ThreadTestHelpers.RunTestInBackgroundThread(
|
||||
@@ -465,6 +572,7 @@ namespace System.Threading.Threads.Tests
|
||||
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Mono)]
|
||||
public static void AbortSuspendTest()
|
||||
{
|
||||
var e = new ManualResetEvent(false);
|
||||
@@ -825,6 +933,7 @@ namespace System.Threading.Threads.Tests
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20766,TargetFrameworkMonikers.UapAot)]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Mono)]
|
||||
public static void MiscellaneousTest()
|
||||
{
|
||||
Thread.BeginCriticalRegion();
|
||||
|
||||
Reference in New Issue
Block a user