Imported Upstream version 5.8.0.22

Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-10-19 20:04:20 +00:00
parent 5f4a27cc8a
commit 7d05485754
5020 changed files with 114082 additions and 186061 deletions

View File

@ -4,6 +4,7 @@
<BuildConfigurations>
netcoreapp;
netfx;
net47;
uap;
</BuildConfigurations>
</PropertyGroup>

View File

@ -3,8 +3,10 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<ProjectGuid>{102247C1-3DB9-4DB5-80B3-EE9F80DD4E8F}</ProjectGuid>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx'">true</IsPartialFacadeAssembly>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx' or '$(TargetGroup)' == 'net47'">true</IsPartialFacadeAssembly>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net47-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net47-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Debug|AnyCPU'" />
@ -14,14 +16,14 @@
<ItemGroup>
<Compile Include="System.Security.Cryptography.Algorithms.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' != 'netfx'">
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true'">
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
<ProjectReference Include="..\..\System.Runtime.Extensions\ref\System.Runtime.Extensions.csproj" />
<ProjectReference Include="..\..\System.IO\ref\System.IO.csproj" />
<ProjectReference Include="..\..\System.Security.Cryptography.Encoding\ref\System.Security.Cryptography.Encoding.csproj" />
<ProjectReference Include="..\..\System.Security.Cryptography.Primitives\ref\System.Security.Cryptography.Primitives.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netfx'">
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' == 'true'">
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />

View File

@ -6,6 +6,7 @@
netcoreapp-OSX;
netcoreapp-Windows_NT;
netfx-Windows_NT;
net47-Windows_NT;
uap-Windows_NT;
</BuildConfigurations>
</PropertyGroup>

View File

@ -9,9 +9,11 @@
<DefineConstants>INTERNAL_ASYMMETRIC_IMPLEMENTATIONS</DefineConstants>
<NoWarn>CA5351;$(NoWarn)</NoWarn>
<DefineConstants Condition="'$(TargetGroup)' == 'uap'">$(DefineConstants);uap</DefineConstants>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx'">true</IsPartialFacadeAssembly>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx' or '$(TargetGroup)' == 'net47'">true</IsPartialFacadeAssembly>
<GenFacadesIgnoreMissingTypes Condition="'$(TargetGroup)' == 'netfx'">true</GenFacadesIgnoreMissingTypes>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net47-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net47-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-OSX-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-OSX-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Debug|AnyCPU'" />
@ -22,7 +24,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Release|AnyCPU'" />
<ItemGroup Condition="'$(TargetGroup)' != 'netfx'">
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true'">
<Compile Include="Internal\Cryptography\AesImplementation.cs" />
<Compile Include="Internal\Cryptography\DesImplementation.cs" />
<Compile Include="Internal\Cryptography\Helpers.cs" />
@ -107,7 +109,7 @@
<Link>Internal\Cryptography\UniversalCryptoDecryptor.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup Condition=" '$(TargetsWindows)' == 'true' AND '$(TargetGroup)' != 'netfx'">
<ItemGroup Condition=" '$(TargetsWindows)' == 'true' and '$(IsPartialFacadeAssembly)' != 'true'">
<Compile Include="System\Security\Cryptography\CngKeyLite.cs" />
<Compile Include="System\Security\Cryptography\DSACng.cs" />
<Compile Include="System\Security\Cryptography\ECDsaCng.cs" />
@ -477,7 +479,7 @@
<Link>Common\System\Security\Cryptography\DerSequenceReader.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' != 'netfx'">
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true'">
<Reference Include="System.Collections" />
<Reference Include="System.Diagnostics.Contracts" />
<Reference Include="System.Diagnostics.Debug" />
@ -494,11 +496,11 @@
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
<Reference Include="System.Runtime.Numerics" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netfx'">
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' == 'true'">
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Compile Include="System\Security\Cryptography\IncrementalHash.net46.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>

View File

@ -29,7 +29,7 @@ namespace System.Security.Cryptography.CryptoConfigTests
[Fact]
public static void AddOID_EmptyString_Throws()
{
Assert.Throws<ArgumentException>(null, () => CryptoConfig.AddOID(string.Empty, string.Empty));
AssertExtensions.Throws<ArgumentException>(null, () => CryptoConfig.AddOID(string.Empty, string.Empty));
}
[Fact]
@ -42,13 +42,13 @@ namespace System.Security.Cryptography.CryptoConfigTests
[Fact]
public static void AddOID_NullOid_Throws()
{
Assert.Throws<ArgumentNullException>("oid", () => CryptoConfig.AddOID(null, string.Empty));
AssertExtensions.Throws<ArgumentNullException>("oid", () => CryptoConfig.AddOID(null, string.Empty));
}
[Fact]
public static void AddOID_NullNames_Throws()
{
Assert.Throws<ArgumentNullException>("names", () => CryptoConfig.AddOID(string.Empty, null));
AssertExtensions.Throws<ArgumentNullException>("names", () => CryptoConfig.AddOID(string.Empty, null));
}
[Fact]
@ -61,7 +61,7 @@ namespace System.Security.Cryptography.CryptoConfigTests
[Fact]
public static void AddAlgorithm_NonVisibleType()
{
Assert.Throws<ArgumentException>("algorithm", () => CryptoConfig.AddAlgorithm(typeof(AESFancy), "AESFancy"));
AssertExtensions.Throws<ArgumentException>("algorithm", () => CryptoConfig.AddAlgorithm(typeof(AESFancy), "AESFancy"));
}
private class AESFancy
@ -71,7 +71,7 @@ namespace System.Security.Cryptography.CryptoConfigTests
[Fact]
public static void AddAlgorithm_EmptyString_Throws()
{
Assert.Throws<ArgumentException>(null, () => CryptoConfig.AddAlgorithm(typeof(CryptoConfigTests), string.Empty));
AssertExtensions.Throws<ArgumentException>(null, () => CryptoConfig.AddAlgorithm(typeof(CryptoConfigTests), string.Empty));
}
[Fact]
@ -84,13 +84,13 @@ namespace System.Security.Cryptography.CryptoConfigTests
[Fact]
public static void AddAlgorithm_NullAlgorithm_Throws()
{
Assert.Throws<ArgumentNullException>("algorithm", () => CryptoConfig.AddAlgorithm(null, string.Empty));
AssertExtensions.Throws<ArgumentNullException>("algorithm", () => CryptoConfig.AddAlgorithm(null, string.Empty));
}
[Fact]
public static void AddAlgorithm_NullNames_Throws()
{
Assert.Throws<ArgumentNullException>("names", () => CryptoConfig.AddAlgorithm(typeof(CryptoConfigTests), null));
AssertExtensions.Throws<ArgumentNullException>("names", () => CryptoConfig.AddAlgorithm(typeof(CryptoConfigTests), null));
}
[Fact]

View File

@ -88,7 +88,7 @@ namespace System.Security.Cryptography.Algorithms.Tests
parameters.X = null;
parameters.Y = null;
Assert.Throws<ArgumentException>(() => DSA.Create(parameters));
AssertExtensions.Throws<ArgumentException>(null, () => DSA.Create(parameters));
}
}
}

View File

@ -188,8 +188,8 @@ namespace System.Security.Cryptography.Hashing.Algorithms.Tests
{
AssertExtensions.Throws<ArgumentNullException>("inputBuffer", () => hash.TransformBlock(null, 0, 0, null, 0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("inputOffset", () => hash.TransformBlock(Array.Empty<byte>(), -1, 0, null, 0));
Assert.Throws<ArgumentException>(null, () => hash.TransformBlock(Array.Empty<byte>(), 0, 1, null, 0));
Assert.Throws<ArgumentException>(null, () => hash.TransformBlock(Array.Empty<byte>(), 1, 0, null, 0));
AssertExtensions.Throws<ArgumentException>(null, () => hash.TransformBlock(Array.Empty<byte>(), 0, 1, null, 0));
AssertExtensions.Throws<ArgumentException>(null, () => hash.TransformBlock(Array.Empty<byte>(), 1, 0, null, 0));
}
}
@ -200,9 +200,9 @@ namespace System.Security.Cryptography.Hashing.Algorithms.Tests
{
AssertExtensions.Throws<ArgumentNullException>("inputBuffer", () => hash.TransformFinalBlock(null, 0, 0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("inputOffset", () => hash.TransformFinalBlock(Array.Empty<byte>(), -1, 0));
Assert.Throws<ArgumentException>(null, () => hash.TransformFinalBlock(Array.Empty<byte>(), 1, 0));
Assert.Throws<ArgumentException>(null, () => hash.TransformFinalBlock(Array.Empty<byte>(), 0, -1));
Assert.Throws<ArgumentException>(null, () => hash.TransformFinalBlock(Array.Empty<byte>(), 0, 1));
AssertExtensions.Throws<ArgumentException>(null, () => hash.TransformFinalBlock(Array.Empty<byte>(), 1, 0));
AssertExtensions.Throws<ArgumentException>(null, () => hash.TransformFinalBlock(Array.Empty<byte>(), 0, -1));
AssertExtensions.Throws<ArgumentException>(null, () => hash.TransformFinalBlock(Array.Empty<byte>(), 0, 1));
}
}
@ -261,7 +261,7 @@ namespace System.Security.Cryptography.Hashing.Algorithms.Tests
{
using (HashAlgorithm hash = Create())
{
Assert.Throws<ArgumentException>(null, () => hash.ComputeHash(Array.Empty<byte>(), 0, -1));
AssertExtensions.Throws<ArgumentException>(null, () => hash.ComputeHash(Array.Empty<byte>(), 0, -1));
}
}
@ -270,7 +270,7 @@ namespace System.Security.Cryptography.Hashing.Algorithms.Tests
{
using (HashAlgorithm hash = Create())
{
Assert.Throws<ArgumentException>(null, () => hash.ComputeHash(Array.Empty<byte>(), 1, 0));
AssertExtensions.Throws<ArgumentException>(null, () => hash.ComputeHash(Array.Empty<byte>(), 1, 0));
}
}
@ -281,10 +281,10 @@ namespace System.Security.Cryptography.Hashing.Algorithms.Tests
using (HashAlgorithm hash = Create())
{
Assert.Throws<ArgumentException>(null, () => hash.ComputeHash(nonEmpty, 0, nonEmpty.Length + 1));
Assert.Throws<ArgumentException>(null, () => hash.ComputeHash(nonEmpty, 1, nonEmpty.Length));
Assert.Throws<ArgumentException>(null, () => hash.ComputeHash(nonEmpty, 2, nonEmpty.Length - 1));
Assert.Throws<ArgumentException>(null, () => hash.ComputeHash(Array.Empty<byte>(), 0, 1));
AssertExtensions.Throws<ArgumentException>(null, () => hash.ComputeHash(nonEmpty, 0, nonEmpty.Length + 1));
AssertExtensions.Throws<ArgumentException>(null, () => hash.ComputeHash(nonEmpty, 1, nonEmpty.Length));
AssertExtensions.Throws<ArgumentException>(null, () => hash.ComputeHash(nonEmpty, 2, nonEmpty.Length - 1));
AssertExtensions.Throws<ArgumentException>(null, () => hash.ComputeHash(Array.Empty<byte>(), 0, 1));
}
}

View File

@ -132,7 +132,7 @@ namespace System.Security.Cryptography.Hashing.Algorithms.Tests
{
using (HMAC hash = Create())
{
Assert.Throws<ArgumentException>(null, () => hash.ComputeHash(Array.Empty<byte>(), 0, -1));
AssertExtensions.Throws<ArgumentException>(null, () => hash.ComputeHash(Array.Empty<byte>(), 0, -1));
}
}
@ -141,7 +141,7 @@ namespace System.Security.Cryptography.Hashing.Algorithms.Tests
{
using (HMAC hash = Create())
{
Assert.Throws<ArgumentException>(null, () => hash.ComputeHash(Array.Empty<byte>(), 1, 0));
AssertExtensions.Throws<ArgumentException>(null, () => hash.ComputeHash(Array.Empty<byte>(), 1, 0));
}
}
@ -152,10 +152,10 @@ namespace System.Security.Cryptography.Hashing.Algorithms.Tests
using (HMAC hash = Create())
{
Assert.Throws<ArgumentException>(null, () => hash.ComputeHash(nonEmpty, 0, nonEmpty.Length + 1));
Assert.Throws<ArgumentException>(null, () => hash.ComputeHash(nonEmpty, 1, nonEmpty.Length));
Assert.Throws<ArgumentException>(null, () => hash.ComputeHash(nonEmpty, 2, nonEmpty.Length - 1));
Assert.Throws<ArgumentException>(null, () => hash.ComputeHash(Array.Empty<byte>(), 0, 1));
AssertExtensions.Throws<ArgumentException>(null, () => hash.ComputeHash(nonEmpty, 0, nonEmpty.Length + 1));
AssertExtensions.Throws<ArgumentException>(null, () => hash.ComputeHash(nonEmpty, 1, nonEmpty.Length));
AssertExtensions.Throws<ArgumentException>(null, () => hash.ComputeHash(nonEmpty, 2, nonEmpty.Length - 1));
AssertExtensions.Throws<ArgumentException>(null, () => hash.ComputeHash(Array.Empty<byte>(), 0, 1));
}
}

View File

@ -17,9 +17,9 @@ namespace System.Security.Cryptography.Hashing.Algorithms.Tests
Assert.Throws<ArgumentNullException>(() => hmac.ExposedHashCore(null, 0, 0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("offset", "inputOffset", () => hmac.ExposedHashCore(new byte[1], -1, 1));
AssertExtensions.Throws<ArgumentOutOfRangeException, ArgumentException>("count", null, () => hmac.ExposedHashCore(new byte[1], 0, -1));
Assert.Throws<ArgumentException>(() => hmac.ExposedHashCore(new byte[1], 0, 2));
Assert.Throws<ArgumentException>(() => hmac.ExposedHashCore(new byte[2], 1, 2));
Assert.Throws<ArgumentException>(() => hmac.ExposedHashCore(new byte[1], Int32.MaxValue, Int32.MaxValue));
AssertExtensions.Throws<ArgumentException>(null, () => hmac.ExposedHashCore(new byte[1], 0, 2));
AssertExtensions.Throws<ArgumentException>(null, () => hmac.ExposedHashCore(new byte[2], 1, 2));
AssertExtensions.Throws<ArgumentException>(null, () => hmac.ExposedHashCore(new byte[1], Int32.MaxValue, Int32.MaxValue));
}
}
@ -29,8 +29,7 @@ namespace System.Security.Cryptography.Hashing.Algorithms.Tests
{
using (SHA1 sha1 = SHA1.Create())
{
Assert.Throws<ArgumentException>(
() => sha1.ComputeHash(new BadReadStream(BadReadStream.ErrorCondition.TooLargeValueFromRead)));
AssertExtensions.Throws<ArgumentException>(null, () => sha1.ComputeHash(new BadReadStream(BadReadStream.ErrorCondition.TooLargeValueFromRead)));
sha1.ComputeHash(new BadReadStream(BadReadStream.ErrorCondition.NegativeValueFromRead));
}
}

View File

@ -76,7 +76,7 @@ namespace System.Security.Cryptography.Algorithms.Tests
parameters.Exponent = null;
if (RSA.Create() is RSACng && PlatformDetection.IsFullFramework)
Assert.Throws<ArgumentException>(() => RSA.Create(parameters));
AssertExtensions.Throws<ArgumentException>(null, () => RSA.Create(parameters));
else
Assert.Throws<CryptographicException>(() => RSA.Create(parameters));
}

View File

@ -262,7 +262,7 @@ namespace System.Security.Cryptography.RNG.Tests
AssertExtensions.Throws<ArgumentNullException>("data", () => rng.GetBytes(null, 0, 0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("offset", () => rng.GetBytes(Array.Empty<byte>(), -1, 0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => rng.GetBytes(Array.Empty<byte>(), 0, -1));
Assert.Throws<ArgumentException>(() => rng.GetBytes(Array.Empty<byte>(), 0, 1));
AssertExtensions.Throws<ArgumentException>(null, () => rng.GetBytes(Array.Empty<byte>(), 0, 1));
// GetBytes(null) covered in test NullInput()
}

View File

@ -39,19 +39,19 @@ namespace System.Security.Cryptography.DeriveBytesTests
[Fact]
public static void Ctor_EmptySalt()
{
Assert.Throws<ArgumentException>(() => new Rfc2898DeriveBytes(TestPassword, Array.Empty<byte>(), DefaultIterationCount));
AssertExtensions.Throws<ArgumentException>("salt", null, () => new Rfc2898DeriveBytes(TestPassword, Array.Empty<byte>(), DefaultIterationCount));
}
[Fact]
public static void Ctor_DiminishedSalt()
{
Assert.Throws<ArgumentException>(() => new Rfc2898DeriveBytes(TestPassword, new byte[7], DefaultIterationCount));
AssertExtensions.Throws<ArgumentException>("salt", null, () => new Rfc2898DeriveBytes(TestPassword, new byte[7], DefaultIterationCount));
}
[Fact]
public static void Ctor_GenerateZeroSalt()
{
Assert.Throws<ArgumentException>(() => new Rfc2898DeriveBytes(TestPassword, 0));
AssertExtensions.Throws<ArgumentException>("saltSize", null, () => new Rfc2898DeriveBytes(TestPassword, 0));
}
[Fact]
@ -65,7 +65,7 @@ namespace System.Security.Cryptography.DeriveBytesTests
[Fact]
public static void Ctor_GenerateDiminishedSalt()
{
Assert.Throws<ArgumentException>(() => new Rfc2898DeriveBytes(TestPassword, 7));
AssertExtensions.Throws<ArgumentException>("saltSize", null, () => new Rfc2898DeriveBytes(TestPassword, 7));
}
[Fact]

View File

@ -16,9 +16,6 @@
<DefineConstants>$(DefineConstants);netcoreapp</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(CommonTestPath)\System\AssertExtensions.cs">
<Link>Common\System\AssertExtensions.cs</Link>
</Compile>
<Compile Include="$(CommonTestPath)\System\PlatformDetection.cs">
<Link>CommonTest\System\PlatformDetection.cs</Link>
</Compile>