Skip to content

Commit

Permalink
Issue #24343 Vector Ctor using Span
Browse files Browse the repository at this point in the history
  • Loading branch information
WinCPP committed Mar 8, 2018
1 parent eac445c commit bc84c90
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
10 changes: 6 additions & 4 deletions src/System.Numerics.Vectors/ref/System.Numerics.Vectors.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<ProjectGuid>{650277B5-9423-4ACE-BB54-2659995B21C7}</ProjectGuid>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx' OR '$(TargetGroup)' == 'net46'">true</IsPartialFacadeAssembly>
<DefineConstants Condition="'$(TargetGroup)'=='netcoreapp'">$(DefineConstants);netcoreapp</DefineConstants>
<IsTargetingNetFx Condition="'$(TargetGroup)'=='netfx' OR '$(TargetGroup)'=='net46'">true</IsTargetingNetFx>
<IsTargetingNetCoreApp Condition="'$(TargetGroup)'=='netcoreapp' OR '$(TargetGroup)'=='uap'">true</IsTargetingNetCoreApp>
<IsPartialFacadeAssembly Condition="'$(IsTargetingNetFx)'=='true'">true</IsPartialFacadeAssembly>
<DefineConstants Condition="'$(IsTargetingNetCoreApp)'=='true'">$(DefineConstants);netcoreapp</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net46-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net46-Release|AnyCPU'" />
Expand All @@ -23,14 +25,14 @@
<ItemGroup>
<Compile Include="System.Numerics.Vectors.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netfx' OR '$(TargetGroup)' == 'net46'">
<ItemGroup Condition="'$(IsTargetingNetFx)'=='true'">
<Reference Include="mscorlib" />
<Reference Include="System.Numerics" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netstandard1.0'">
<Reference Include="System.Runtime" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' OR '$(TargetGroup)' == 'uap' OR '$(TargetGroup)' == 'uapaot'">
<ItemGroup Condition="'$(IsTargetingNetCoreApp)'=='true'">
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<IsTargetingNetCoreApp Condition="'$(TargetGroup)'=='netcoreapp' OR '$(TargetGroup)'=='uap' OR '$(TargetGroup)'=='uapaot'">true</IsTargetingNetCoreApp>
<IsPartialFacadeAssembly Condition="'$(IsTargetingNetFx)'=='true' OR '$(IsTargetingNetCoreApp)'=='true'">true</IsPartialFacadeAssembly>
<PackageTargetFramework Condition="'$(TargetGroup)' == 'netstandard1.0'">netstandard1.0;portable-net45+win8+wp8+wpa81</PackageTargetFramework>
<DefineConstants Condition="'$(IsTargetingNetCoreApp)' != 'true'">$(DefineConstants);netcoreapp</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net46-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net46-Release|AnyCPU'" />
Expand Down
5 changes: 2 additions & 3 deletions src/System.Numerics.Vectors/tests/GenericVectorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2699,12 +2699,11 @@ private static void ValidateVector<T>(Vector<T> vector, Action<int, T> indexVali
}
}

internal static T[] GenerateRandomValuesForVector<T>(int numValues = int.MinValue) where T : struct
internal static T[] GenerateRandomValuesForVector<T>(int? numValues = null) where T : struct
{
int minValue = GetMinValue<T>();
int maxValue = GetMaxValue<T>();
numValues = numValues == int.MinValue ? Vector<T>.Count : numValues;
return Util.GenerateRandomValues<T>(numValues, minValue, maxValue);
return Util.GenerateRandomValues<T>(numValues ?? Vector<T>.Count, minValue, maxValue);
}

internal static int GetMinValue<T>() where T : struct
Expand Down
16 changes: 13 additions & 3 deletions src/System.Numerics.Vectors/tests/GenericVectorTests.tt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<#@ import namespace="System" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Runtime.InteropServices" #>
<#@ include file="..\src\System\Numerics\GenerationConfig.ttinclude" #><# GenerateCopyrightHeader(); #>
<#@ include file="..\..\common\src\corelib\System\Numerics\GenerationConfig.ttinclude" #><# GenerateCopyrightHeader(); #>

using System;
using System.Globalization;
Expand Down Expand Up @@ -1792,11 +1792,11 @@ namespace System.Numerics.Tests
}
}

internal static T[] GenerateRandomValuesForVector<T>() where T : struct
internal static T[] GenerateRandomValuesForVector<T>(int? numValues = null) where T : struct
{
int minValue = GetMinValue<T>();
int maxValue = GetMaxValue<T>();
return Util.GenerateRandomValues<T>(Vector<T>.Count, minValue, maxValue);
return Util.GenerateRandomValues<T>(numValues ?? Vector<T>.Count, minValue, maxValue);
}

internal static int GetMinValue<T>() where T : struct
Expand Down Expand Up @@ -1867,6 +1867,16 @@ namespace System.Numerics.Tests
}
throw new NotSupportedException();
}

internal static T[] GetArrayOfDefaultValues<T>(int count)
{
T[] arr = new T[count];
for (int index = 0; index < count; ++index)
{
arr[index] = default(T);
}
return arr;
}
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<Link>System\MathF.netstandard.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' OR '$(TargetGroup)' == 'uap'">
<Compile Include="GenericVectorTests.netcoreapp.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
Expand Down

0 comments on commit bc84c90

Please sign in to comment.