Skip to content

Commit 9ece956

Browse files
Cleanup, fix, and update version.
1 parent 9cc5556 commit 9ece956

10 files changed

+59
-27
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,5 @@ paket-files/
258258

259259
# Python Tools for Visual Studio (PTVS)
260260
__pycache__/
261-
*.pyc
261+
*.pyc
262+
source/nuget.config

Open.Numeric.Primes.sln

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31410.357
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Open.Numeric.Primes", "source\Open.Numeric.Primes.csproj", "{A1D27164-24BD-4DE5-A783-7BF93B32253B}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Open.Numeric.Primes.Speed", "speed\Open.Numeric.Primes.Speed.csproj", "{12663275-69B7-4B4E-899B-07267780F7F0}"
9+
EndProject
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Open.Numeric.Primes.Tests", "tests\Open.Numeric.Primes.Tests.csproj", "{AE71AD73-B001-45E7-BC34-CC220CF29CD6}"
11+
EndProject
12+
Global
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
Release|Any CPU = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{A1D27164-24BD-4DE5-A783-7BF93B32253B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{A1D27164-24BD-4DE5-A783-7BF93B32253B}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{A1D27164-24BD-4DE5-A783-7BF93B32253B}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{A1D27164-24BD-4DE5-A783-7BF93B32253B}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{12663275-69B7-4B4E-899B-07267780F7F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{12663275-69B7-4B4E-899B-07267780F7F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{12663275-69B7-4B4E-899B-07267780F7F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{12663275-69B7-4B4E-899B-07267780F7F0}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{AE71AD73-B001-45E7-BC34-CC220CF29CD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{AE71AD73-B001-45E7-BC34-CC220CF29CD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{AE71AD73-B001-45E7-BC34-CC220CF29CD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{AE71AD73-B001-45E7-BC34-CC220CF29CD6}.Release|Any CPU.Build.0 = Release|Any CPU
30+
EndGlobalSection
31+
GlobalSection(SolutionProperties) = preSolution
32+
HideSolutionNode = FALSE
33+
EndGlobalSection
34+
GlobalSection(ExtensibilityGlobals) = postSolution
35+
SolutionGuid = {6A37AACA-4943-4B9F-9877-700D44C7EFCE}
36+
EndGlobalSection
37+
EndGlobal

source/MillerRabin.cs

-9
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,7 @@ static bool IsProbablePrimeInternal(in BigInteger source, int certainty = 10)
148148
// byte arrays of the same length as the source.
149149
var rng = RandomNumberGenerator.Create();
150150
var len = source.ToByteArray().Length; // .LongLength?
151-
#if NETSTANDARD2_1
152-
var byteArray = System.Buffers.ArrayPool<byte>.Shared.Rent(len);
153-
var bytes = byteArray.AsSpan();
154-
#else
155151
var bytes = new byte[len]; // .LongLength?
156-
#endif
157152

158153
for (var i = 0; i < certainty; i++)
159154
{
@@ -182,10 +177,6 @@ static bool IsProbablePrimeInternal(in BigInteger source, int certainty = 10)
182177
return false;
183178
}
184179

185-
#if NETSTANDARD2_1
186-
System.Buffers.ArrayPool<byte>.Shared.Return(byteArray);
187-
#endif
188-
189180
return true;
190181
}
191182

source/Open.Numeric.Primes.csproj

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
55
<LangVersion>latest</LangVersion>
66
<Nullable>enable</Nullable>
7+
<EnableNETAnalyzers>true</EnableNETAnalyzers>
78
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
89
<Authors>electricessence</Authors>
910
<Description>
@@ -16,7 +17,7 @@
1617
<PackageProjectUrl>https://github.com/Open-NET-Libraries/Open.Numeric.Primes/</PackageProjectUrl>
1718
<RepositoryUrl>https://github.com/Open-NET-Libraries/Open.Numeric.Primes/</RepositoryUrl>
1819
<RepositoryType>git</RepositoryType>
19-
<Version>2.0.0</Version>
20+
<Version>2.0.1</Version>
2021
<PackageReleaseNotes></PackageReleaseNotes>
2122
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2223
<PublishRepositoryUrl>true</PublishRepositoryUrl>
@@ -38,8 +39,8 @@
3839

3940
<ItemGroup>
4041
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
41-
<PackageReference Include="Open.Collections" Version="2.8.0" />
42-
<PackageReference Include="System.Collections.Immutable" Version="1.7.1" />
42+
<PackageReference Include="Open.Collections" Version="2.10.2" />
43+
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />
4344
</ItemGroup>
4445

4546
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">

source/Optimized.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ protected override bool IsPrimeInternal(in ulong value)
1313
? Polynomial.IsPrimeInternal(Convert.ToUInt32(value))
1414
: MillerRabin.IsPrime(in value);
1515

16-
public readonly BigInt Big = new BigInt();
16+
public readonly BigInt Big = new();
1717

1818
public class BigInt : PrimalityBigIntBase
1919
{

source/PrimalityBase.cs

-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Open.Numeric.Primes
99
{
10-
[SuppressMessage("ReSharper", "MemberCanBeProtected.Global")]
1110
public abstract class PrimalityBase<T> : IEnumerable<T>
1211
where T : struct
1312
{
@@ -125,7 +124,6 @@ public override IEnumerator<uint> GetEnumerator()
125124
/// </summary>
126125
/// <param name="value">Allows for skipping ahead any integer before checking for inclusive and subsequent primes. Passing a negative number here will produce a negative set of prime numbers.</param>
127126
/// <returns>An enumerable that will iterate every prime starting at the starting value</returns>
128-
[SuppressMessage("ReSharper", "SuspiciousTypeConversion.Global")]
129127
public IEnumerable<int> StartingAt(int value)
130128
{
131129
var absStart = (uint)Math.Abs(value);
@@ -317,7 +315,6 @@ public override IEnumerator<ulong> GetEnumerator()
317315
/// </summary>
318316
/// <param name="value">Allows for skipping ahead any integer before checking for inclusive and subsequent primes. Passing a negative number here will produce a negative set of prime numbers.</param>
319317
/// <returns>An enumerable that will iterate every prime starting at the starting value</returns>
320-
[SuppressMessage("ReSharper", "SuspiciousTypeConversion.Global")]
321318
public IEnumerable<long> StartingAt(long value)
322319
{
323320
var absStart = (ulong)Math.Abs(value);

source/Primes.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static double ToDouble(in float value)
122122
: double.Parse(value.ToString(CultureInfo.InvariantCulture));
123123
}
124124

125-
public static readonly Optimized Numbers = new Optimized();
125+
public static readonly Optimized Numbers = new();
126126

127127
/// <summary>
128128
/// Iterates the prime factors of the provided value.

source/TrialDivision.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ namespace Open.Numeric.Primes
1010
public static class TrialDivision
1111
{
1212
public static readonly ImmutableArray<ushort> FirstKnown
13-
= (new ushort[] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541 })
14-
.ToImmutableArray();
13+
= ImmutableArray.Create<ushort>(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541);
1514

16-
static readonly ushort LastKnown = FirstKnown.Last();
15+
//static readonly ushort LastKnown = FirstKnown.Last();
1716

1817
public class U32 : PrimalityU32Base
1918
{

speed/Open.Numeric.Primes.Speed.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net5.0</TargetFramework>
55
</PropertyGroup>
66
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
77
<LangVersion>preview</LangVersion>

tests/Open.Numeric.Primes.Tests.csproj

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net5.0</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
11-
<PackageReference Include="xunit" Version="2.4.0" />
12-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
13-
<PackageReference Include="coverlet.collector" Version="1.2.0" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
11+
<PackageReference Include="xunit" Version="2.4.1" />
12+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
13+
<PrivateAssets>all</PrivateAssets>
14+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
15+
</PackageReference>
16+
<PackageReference Include="coverlet.collector" Version="3.0.3">
17+
<PrivateAssets>all</PrivateAssets>
18+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
19+
</PackageReference>
1420
</ItemGroup>
1521

1622
<ItemGroup>

0 commit comments

Comments
 (0)