Imported Upstream version 6.0.0.172

Former-commit-id: f3cc9b82f3e5bd8f0fd3ebc098f789556b44e9cd
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-04-12 14:10:50 +00:00
parent 8016999e4d
commit 64ac736ec5
32155 changed files with 3981439 additions and 75368 deletions

View 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>

View File

@@ -0,0 +1,61 @@
// 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 DefaultApartmentStateMain
{
internal static class DefaultApartmentStateMain
{
private const int Success = 0;
private const int SuccessOnUnix = 2;
private const int Failure = 1;
private static Thread s_mainThread;
static int Main(string[] args)
{
string testName = args[0];
s_mainThread = Thread.CurrentThread;
switch (testName)
{
case "GetApartmentStateTest":
return GetApartmentStateTest();
case "SetApartmentStateTest":
return SetApartmentStateTest();
default:
return Failure;
}
}
private static int GetApartmentStateTest()
{
if (s_mainThread.GetApartmentState() == ApartmentState.MTA)
{
s_mainThread.SetApartmentState(ApartmentState.MTA);
return Success;
}
return SuccessOnUnix;
}
private static int SetApartmentStateTest()
{
try
{
s_mainThread.SetApartmentState(ApartmentState.STA);
}
catch (InvalidOperationException)
{
return Success;
}
catch (PlatformNotSupportedException)
{
return SuccessOnUnix;
}
return Failure;
}
}
}

View 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>{32432E07-5CA4-41F3-9855-22AB1F1E69B3}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="DefaultApartmentStateMain.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="DefaultApartmentStateMain.runtimeconfig.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="DefaultApartmentStateMain.exe.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<developmentMode developerInstallation="true" />
</runtime>
</configuration>

View File

@@ -0,0 +1,8 @@
{
"runtimeOptions": {
"framework": {
"name": "Microsoft.NETCore.App",
"version": "9.9.9"
}
}
}

View File

@@ -9,46 +9,54 @@ namespace MTAMain
{
internal static class MTAMain
{
private const int Success = 0;
private const int SuccessOnUnix = 2;
private const int Failure = 1;
private static Thread s_mainThread;
[MTAThread]
static int Main(string[] args)
{
const int Success = 0;
const int SuccessOnUnix = 2;
const int Failure = 1;
string testName = args[0];
s_mainThread = Thread.CurrentThread;
string mode = args[0];
int retValue = Failure;
Thread curThread = Thread.CurrentThread;
if (mode == "GetApartmentState")
switch (testName)
{
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;
}
case "GetApartmentStateTest":
return GetApartmentStateTest();
case "SetApartmentStateTest":
return SetApartmentStateTest();
default:
return Failure;
}
}
return retValue;
private static int GetApartmentStateTest()
{
if (s_mainThread.GetApartmentState() == ApartmentState.MTA)
{
s_mainThread.SetApartmentState(ApartmentState.MTA);
return Success;
}
return SuccessOnUnix;
}
private static int SetApartmentStateTest()
{
try
{
s_mainThread.SetApartmentState(ApartmentState.STA);
}
catch (InvalidOperationException)
{
return Success;
}
catch (PlatformNotSupportedException)
{
return SuccessOnUnix;
}
return Failure;
}
}
}

View File

@@ -9,46 +9,54 @@ namespace STAMain
{
internal static class STAMain
{
private const int Success = 0;
private const int SuccessOnUnix = 2;
private const int Failure = 1;
private static Thread s_mainThread;
[STAThread]
static int Main(string[] args)
{
const int Success = 0;
const int SuccessOnUnix = 2;
const int Failure = 1;
string testName = args[0];
s_mainThread = Thread.CurrentThread;
string mode = args[0];
int retValue = Failure;
Thread curThread = Thread.CurrentThread;
if (mode == "GetApartmentState")
switch (testName)
{
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;
}
case "GetApartmentStateTest":
return GetApartmentStateTest();
case "SetApartmentStateTest":
return SetApartmentStateTest();
default:
return Failure;
}
}
return retValue;
private static int GetApartmentStateTest()
{
if (s_mainThread.GetApartmentState() == ApartmentState.STA)
{
s_mainThread.SetApartmentState(ApartmentState.STA);
return Success;
}
return SuccessOnUnix;
}
private static int SetApartmentStateTest()
{
try
{
s_mainThread.SetApartmentState(ApartmentState.MTA);
}
catch (InvalidOperationException)
{
return Success;
}
catch (PlatformNotSupportedException)
{
return SuccessOnUnix;
}
return Failure;
}
}
}

View File

@@ -34,6 +34,9 @@
<ProjectReference Include="MTAMain\MTAMain.csproj">
<Name>MTAMain</Name>
</ProjectReference>
<ProjectReference Include="DefaultApartmentStateMain\DefaultApartmentStateMain.csproj">
<Name>DefaultApartmentStateMain</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -153,23 +153,25 @@ 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")]
[InlineData("STAMain.exe", "GetApartmentStateTest")]
[InlineData("STAMain.exe", "SetApartmentStateTest")]
[InlineData("MTAMain.exe", "GetApartmentStateTest")]
[InlineData("MTAMain.exe", "SetApartmentStateTest")]
[InlineData("DefaultApartmentStateMain.exe", "GetApartmentStateTest")]
[InlineData("DefaultApartmentStateMain.exe", "SetApartmentStateTest")]
[ActiveIssue(20766, TargetFrameworkMonikers.Uap)]
public static void ApartmentState_AttributePresent(string AppName, string mode)
public static void ApartmentState_AttributePresent(string appName, string testName)
{
var psi = new ProcessStartInfo();
if (PlatformDetection.IsFullFramework || PlatformDetection.IsNetNative)
{
psi.FileName = AppName;
psi.Arguments = $"{mode}";
psi.FileName = appName;
psi.Arguments = $"{testName}";
}
else
{
psi.FileName = DummyClass.HostRunnerTest;
psi.Arguments = $"{AppName} {mode}";
psi.Arguments = $"{appName} {testName}";
}
using (Process p = Process.Start(psi))
{
@@ -191,20 +193,6 @@ namespace System.Threading.Threads.Tests
}).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)]