Skip to content

Commit bc84c90

Browse files
committed
Issue #24343 Vector Ctor using Span
1 parent eac445c commit bc84c90

5 files changed

+22
-12
lines changed

src/System.Numerics.Vectors/ref/System.Numerics.Vectors.csproj

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
44
<PropertyGroup>
55
<ProjectGuid>{650277B5-9423-4ACE-BB54-2659995B21C7}</ProjectGuid>
6-
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx' OR '$(TargetGroup)' == 'net46'">true</IsPartialFacadeAssembly>
7-
<DefineConstants Condition="'$(TargetGroup)'=='netcoreapp'">$(DefineConstants);netcoreapp</DefineConstants>
6+
<IsTargetingNetFx Condition="'$(TargetGroup)'=='netfx' OR '$(TargetGroup)'=='net46'">true</IsTargetingNetFx>
7+
<IsTargetingNetCoreApp Condition="'$(TargetGroup)'=='netcoreapp' OR '$(TargetGroup)'=='uap'">true</IsTargetingNetCoreApp>
8+
<IsPartialFacadeAssembly Condition="'$(IsTargetingNetFx)'=='true'">true</IsPartialFacadeAssembly>
9+
<DefineConstants Condition="'$(IsTargetingNetCoreApp)'=='true'">$(DefineConstants);netcoreapp</DefineConstants>
810
</PropertyGroup>
911
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net46-Debug|AnyCPU'" />
1012
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net46-Release|AnyCPU'" />
@@ -23,14 +25,14 @@
2325
<ItemGroup>
2426
<Compile Include="System.Numerics.Vectors.cs" />
2527
</ItemGroup>
26-
<ItemGroup Condition="'$(TargetGroup)' == 'netfx' OR '$(TargetGroup)' == 'net46'">
28+
<ItemGroup Condition="'$(IsTargetingNetFx)'=='true'">
2729
<Reference Include="mscorlib" />
2830
<Reference Include="System.Numerics" />
2931
</ItemGroup>
3032
<ItemGroup Condition="'$(TargetGroup)' == 'netstandard1.0'">
3133
<Reference Include="System.Runtime" />
3234
</ItemGroup>
33-
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' OR '$(TargetGroup)' == 'uap' OR '$(TargetGroup)' == 'uapaot'">
35+
<ItemGroup Condition="'$(IsTargetingNetCoreApp)'=='true'">
3436
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
3537
</ItemGroup>
3638
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />

src/System.Numerics.Vectors/src/System.Numerics.Vectors.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<IsTargetingNetCoreApp Condition="'$(TargetGroup)'=='netcoreapp' OR '$(TargetGroup)'=='uap' OR '$(TargetGroup)'=='uapaot'">true</IsTargetingNetCoreApp>
1111
<IsPartialFacadeAssembly Condition="'$(IsTargetingNetFx)'=='true' OR '$(IsTargetingNetCoreApp)'=='true'">true</IsPartialFacadeAssembly>
1212
<PackageTargetFramework Condition="'$(TargetGroup)' == 'netstandard1.0'">netstandard1.0;portable-net45+win8+wp8+wpa81</PackageTargetFramework>
13-
<DefineConstants Condition="'$(IsTargetingNetCoreApp)' != 'true'">$(DefineConstants);netcoreapp</DefineConstants>
1413
</PropertyGroup>
1514
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net46-Debug|AnyCPU'" />
1615
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net46-Release|AnyCPU'" />

src/System.Numerics.Vectors/tests/GenericVectorTests.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -2699,12 +2699,11 @@ private static void ValidateVector<T>(Vector<T> vector, Action<int, T> indexVali
26992699
}
27002700
}
27012701

2702-
internal static T[] GenerateRandomValuesForVector<T>(int numValues = int.MinValue) where T : struct
2702+
internal static T[] GenerateRandomValuesForVector<T>(int? numValues = null) where T : struct
27032703
{
27042704
int minValue = GetMinValue<T>();
27052705
int maxValue = GetMaxValue<T>();
2706-
numValues = numValues == int.MinValue ? Vector<T>.Count : numValues;
2707-
return Util.GenerateRandomValues<T>(numValues, minValue, maxValue);
2706+
return Util.GenerateRandomValues<T>(numValues ?? Vector<T>.Count, minValue, maxValue);
27082707
}
27092708

27102709
internal static int GetMinValue<T>() where T : struct

src/System.Numerics.Vectors/tests/GenericVectorTests.tt

+13-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<#@ import namespace="System" #>
66
<#@ import namespace="System.Linq" #>
77
<#@ import namespace="System.Runtime.InteropServices" #>
8-
<#@ include file="..\src\System\Numerics\GenerationConfig.ttinclude" #><# GenerateCopyrightHeader(); #>
8+
<#@ include file="..\..\common\src\corelib\System\Numerics\GenerationConfig.ttinclude" #><# GenerateCopyrightHeader(); #>
99

1010
using System;
1111
using System.Globalization;
@@ -1792,11 +1792,11 @@ namespace System.Numerics.Tests
17921792
}
17931793
}
17941794

1795-
internal static T[] GenerateRandomValuesForVector<T>() where T : struct
1795+
internal static T[] GenerateRandomValuesForVector<T>(int? numValues = null) where T : struct
17961796
{
17971797
int minValue = GetMinValue<T>();
17981798
int maxValue = GetMaxValue<T>();
1799-
return Util.GenerateRandomValues<T>(Vector<T>.Count, minValue, maxValue);
1799+
return Util.GenerateRandomValues<T>(numValues ?? Vector<T>.Count, minValue, maxValue);
18001800
}
18011801

18021802
internal static int GetMinValue<T>() where T : struct
@@ -1867,6 +1867,16 @@ namespace System.Numerics.Tests
18671867
}
18681868
throw new NotSupportedException();
18691869
}
1870+
1871+
internal static T[] GetArrayOfDefaultValues<T>(int count)
1872+
{
1873+
T[] arr = new T[count];
1874+
for (int index = 0; index < count; ++index)
1875+
{
1876+
arr[index] = default(T);
1877+
}
1878+
return arr;
1879+
}
18701880
#endregion
18711881
}
18721882
}

src/System.Numerics.Vectors/tests/System.Numerics.Vectors.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<Link>System\MathF.netstandard.cs</Link>
3636
</Compile>
3737
</ItemGroup>
38-
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
38+
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' OR '$(TargetGroup)' == 'uap'">
3939
<Compile Include="GenericVectorTests.netcoreapp.cs">
4040
<AutoGen>True</AutoGen>
4141
<DesignTime>True</DesignTime>

0 commit comments

Comments
 (0)