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

@@ -16,7 +16,7 @@
</ItemGroup>
<ItemGroup>
<InboxOnTargetFramework Include="netcoreapp2.0" />
<InboxOnTargetFramework Include="uap10.1" />
<InboxOnTargetFramework Include="$(UAPvNextTFM)" />
<InboxOnTargetFramework Include="MonoAndroid10" />
<InboxOnTargetFramework Include="MonoTouch10" />
<InboxOnTargetFramework Include="xamarinios10" />

View File

@@ -9,16 +9,6 @@
<IsPartialFacadeAssembly Condition="'$(TargetGroup)'=='netfx' OR '$(TargetGroup)'=='net46'">true</IsPartialFacadeAssembly>
<PackageTargetFramework Condition="'$(TargetGroup)' == 'netstandard1.0'">netstandard1.0;portable-net45+win8+wp8+wpa81</PackageTargetFramework>
</PropertyGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netstandard1.0'">
<!-- Use the documentation file generated by this project for the reference assembly.
This needs to be kept in sync with all of the PackageTargetFrameworks used by
the reference assembly projects. -->
<FilesToPackage Include="$(DocumentationFile)">
<TargetPath>ref/netstandard1.0</TargetPath>
<IsReferenceAsset>true</IsReferenceAsset>
</FilesToPackage>
</ItemGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net46-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net46-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
@@ -56,7 +46,9 @@
</ItemGroup>
<!-- Carry a copy of MathF where not available -->
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' == 'true' OR $(TargetGroup.StartsWith('netstandard'))">
<Compile Include="System\MathF.cs" />
<Compile Include="..\..\Common\src\System\MathF.netstandard.cs">
<Link>System\MathF.netstandard.cs</Link>
</Compile>
</ItemGroup>
<!-- Portable version only -->
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true'">

View File

@@ -1,55 +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.CompilerServices;
namespace System
{
internal static class MathF
{
public const float PI = (float)Math.PI;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Abs(float x)
{
return Math.Abs(x);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Acos(float x)
{
return (float)Math.Acos(x);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Cos(float x)
{
return (float)Math.Cos(x);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float IEEERemainder(float x, float y)
{
return (float)Math.IEEERemainder(x, y);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Sin(float x)
{
return (float)Math.Sin(x);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Sqrt(float x)
{
return (float)Math.Sqrt(x);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Tan(float x)
{
return (float)Math.Tan(x);
}
}
}

View File

@@ -1 +1 @@
237b963749824233099ea81480d1ee87e2859f47
e03022a21608be4ac2d624b1a15c3b2cf7fb9182

View File

@@ -12,6 +12,7 @@ using System.Globalization;
using System.Linq;
using System.Reflection;
using Xunit;
using Xunit.Sdk;
namespace System.Numerics.Tests
{
@@ -216,7 +217,7 @@ namespace System.Numerics.Tests
Assert.Throws<NullReferenceException>(() => vector.CopyTo(null, 0));
Assert.Throws<ArgumentOutOfRangeException>(() => vector.CopyTo(array, -1));
Assert.Throws<ArgumentOutOfRangeException>(() => vector.CopyTo(array, array.Length));
Assert.Throws<ArgumentException>(() => vector.CopyTo(array, array.Length - 1));
AssertExtensions.Throws<ArgumentException>(null, () => vector.CopyTo(array, array.Length - 1));
vector.CopyTo(array);
for (int g = 0; g < array.Length; g++)
@@ -1383,13 +1384,14 @@ namespace System.Numerics.Tests
<#
foreach (var type in supportedTypes)
{
int precision = type == typeof(float) ? 6 : type == typeof(double) ? 15 : -1;
#>
[Fact]
public void SquareRoot<#=type.Name#>() { TestSquareRoot<<#=type.Name#>>(); }
public void SquareRoot<#=type.Name#>() { TestSquareRoot<<#=type.Name#>>(<#=precision#>); }
<#
}
#>
private void TestSquareRoot<T>() where T : struct
private void TestSquareRoot<T>(int precision = -1) where T : struct, IEquatable<T>
{
T[] values = GenerateRandomValuesForVector<T>();
Vector<T> vector = new Vector<T>(values);
@@ -1399,7 +1401,7 @@ namespace System.Numerics.Tests
(index, val) =>
{
T expected = Util.Sqrt(values[index]);
Assert.Equal(expected, val);
AssertEqual(expected, val, $"SquareRoot( {FullString(values[index])} )", precision);
});
}
@@ -1702,6 +1704,86 @@ namespace System.Numerics.Tests
#endregion Narrow / Widen
#region Helper Methods
private static void AssertEqual<T>(T expected, T actual, string operation, int precision = -1) where T : IEquatable<T>
{
if (typeof(T) == typeof(float))
{
if (!IsDiffTolerable((float)(object)expected, (float)(object)actual, precision))
{
throw new XunitException($"AssertEqual failed for operation {operation}. Expected: {expected,10:G9}, Actual: {actual,10:G9}.");
}
}
else if (typeof(T) == typeof(double))
{
if (!IsDiffTolerable((double)(object)expected, (double)(object)actual, precision))
{
throw new XunitException($"AssertEqual failed for operation {operation}. Expected: {expected,20:G17}, Actual: {actual,20:G17}.");
}
}
else
{
if (!expected.Equals(actual))
{
throw new XunitException($"AssertEqual failed for operation {operation}. Expected: {expected}, Actual: {actual}.");
}
}
}
private static bool IsDiffTolerable(double d1, double d2, int precision)
{
if (double.IsNaN(d1))
{
return double.IsNaN(d2);
}
if (double.IsInfinity(d1) || double.IsInfinity(d2))
{
return AreSameInfinity(d1, d2);
}
double diffRatio = (d1 - d2) / d1;
diffRatio *= Math.Pow(10, precision);
return Math.Abs(diffRatio) < 1;
}
private static bool IsDiffTolerable(float f1, float f2, int precision)
{
if (float.IsNaN(f1))
{
return float.IsNaN(f2);
}
if (float.IsInfinity(f1) || float.IsInfinity(f2))
{
return AreSameInfinity(f1, f2);
}
float diffRatio = (f1 - f2) / f1;
diffRatio *= MathF.Pow(10, precision);
return Math.Abs(diffRatio) < 1;
}
private static string FullString<T>(T value)
{
if (typeof(T) == typeof(float))
{
return ((float)(object)value).ToString("G9");
}
else if (typeof(T) == typeof(double))
{
return ((double)(object)value).ToString("G17");
}
else
{
return value.ToString();
}
}
private static bool AreSameInfinity(double d1, double d2)
{
return
double.IsNegativeInfinity(d1) == double.IsNegativeInfinity(d2) &&
double.IsPositiveInfinity(d1) == double.IsPositiveInfinity(d2);
}
private static void ValidateVector<T>(Vector<T> vector, Action<int, T> indexValidationFunc) where T : struct
{
for (int g = 0; g < Vector<T>.Count; g++)

View File

@@ -6,11 +6,12 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IncludePerformanceTests>true</IncludePerformanceTests>
<ProjectGuid>{D9906F1A-A41A-43CD-81D2-BA94CF0001C9}</ProjectGuid>
<DisableTests Condition="'$(TargetGroup)' == 'uap' AND ('$(ArchGroup)' == 'arm' OR '$(ArchGroup)' == 'arm64')">true</DisableTests>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
<ItemGroup>
<ItemGroup Condition="'$(DisableTests)' != 'true'">
<Compile Include="Vector2\Distance.cs" />
<Compile Include="Vector2\GetHashCode.cs" />
<Compile Include="Vector2\Length.cs" />
@@ -56,7 +57,7 @@
<Compile Include="Vector2\AddOperator.cs" />
<Compile Include="VectorTests.cs" />
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(DisableTests)' != 'true'">
<ProjectReference Include="$(CommonPath)\..\perf\PerfRunner\PerfRunner.csproj">
<Project>{69e46a6f-9966-45a5-8945-2559fe337827}</Project>
<Name>PerfRunner</Name>

View File

@@ -35,6 +35,9 @@
<Compile Include="$(CommonTestPath)\System\PlatformDetection.cs">
<Link>Common\System\PlatformDetection.cs</Link>
</Compile>
<Compile Condition="'$(TargetGroup)' == 'netfx'" Include="..\..\Common\src\System\MathF.netstandard.cs">
<Link>System\MathF.netstandard.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="..\src\System\Numerics\ConstantHelper.tt">

View File

@@ -18,7 +18,6 @@ namespace System.Numerics.Tests
}
[Fact]
[ActiveIssue("TFS 444567 - Codegen optimization issue", TargetFrameworkMonikers.UapAot)]
public void Vector2CopyToTest()
{
Vector2 v1 = new Vector2(2.0f, 3.0f);
@@ -29,7 +28,17 @@ namespace System.Numerics.Tests
Assert.Throws<NullReferenceException>(() => v1.CopyTo(null, 0));
Assert.Throws<ArgumentOutOfRangeException>(() => v1.CopyTo(a, -1));
Assert.Throws<ArgumentOutOfRangeException>(() => v1.CopyTo(a, a.Length));
Assert.Throws<ArgumentException>(() => v1.CopyTo(a, 2));
if (!PlatformDetection.IsNetNative)
{
AssertExtensions.Throws<ArgumentException>(null, () => v1.CopyTo(a, 2));
}
else
{
// The .Net Native code generation optimizer does aggressive optimizations to range checks
// which result in an ArgumentOutOfRangeException exception being thrown at runtime.
Assert.ThrowsAny<ArgumentException>(() => v1.CopyTo(a, 2));
}
v1.CopyTo(a, 1);
v1.CopyTo(b);

View File

@@ -28,7 +28,7 @@ namespace System.Numerics.Tests
Assert.Throws<NullReferenceException>(() => v1.CopyTo(null, 0));
Assert.Throws<ArgumentOutOfRangeException>(() => v1.CopyTo(a, -1));
Assert.Throws<ArgumentOutOfRangeException>(() => v1.CopyTo(a, a.Length));
Assert.Throws<ArgumentException>(() => v1.CopyTo(a, a.Length - 2));
AssertExtensions.Throws<ArgumentException>(null, () => v1.CopyTo(a, a.Length - 2));
v1.CopyTo(a, 1);
v1.CopyTo(b);

View File

@@ -28,7 +28,7 @@ namespace System.Numerics.Tests
Assert.Throws<NullReferenceException>(() => v1.CopyTo(null, 0));
Assert.Throws<ArgumentOutOfRangeException>(() => v1.CopyTo(a, -1));
Assert.Throws<ArgumentOutOfRangeException>(() => v1.CopyTo(a, a.Length));
Assert.Throws<ArgumentException>(() => v1.CopyTo(a, a.Length - 2));
AssertExtensions.Throws<ArgumentException>(null, () => v1.CopyTo(a, a.Length - 2));
v1.CopyTo(a, 1);
v1.CopyTo(b);