Skip to content

Commit

Permalink
Release 5.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sakno committed Mar 8, 2024
1 parent 3e6ff7c commit b20da06
Show file tree
Hide file tree
Showing 25 changed files with 632 additions and 137 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
Release Notes
====

# 03-08-2024
<a href="https://www.nuget.org/packages/dotnext/5.2.0">DotNext 5.2.0</a>
* Added `Number.IsPrime` static method that allows to check whether the specified number is a prime number
* Fixed AOT compatibility issues

<a href="https://www.nuget.org/packages/dotnext.metaprogramming/5.2.0">DotNext.Metaprogramming 5.2.0</a>
* Updated dependencies

<a href="https://www.nuget.org/packages/dotnext.unsafe/5.2.0">DotNext.Unsafe 5.2.0</a>
* Updated dependencies

<a href="https://www.nuget.org/packages/dotnext.threading/5.2.0">DotNext.Threading 5.2.0</a>
* Added specialized `IndexPool` data type that can be useful for implementing fast object pools

<a href="https://www.nuget.org/packages/dotnext.io/5.2.0">DotNext.IO 5.2.0</a>
* Updated dependencies

<a href="https://www.nuget.org/packages/dotnext.net.cluster/5.2.0">DotNext.Net.Cluster 5.2.0</a>
* Fixed [226](https://github.com/dotnet/dotNext/issues/226)
* Fixed [221](https://github.com/dotnet/dotNext/issues/221)

<a href="https://www.nuget.org/packages/dotnext.aspnetcore.cluster/5.2.0">DotNext.AspNetCore.Cluster 5.2.0</a>
* Fixed [226](https://github.com/dotnet/dotNext/issues/226)
* Fixed [221](https://github.com/dotnet/dotNext/issues/221)

# 02-28-2024
<a href="https://www.nuget.org/packages/dotnext/5.1.0">DotNext 5.1.0</a>
* Added `Span.Advance<T>` extension method for spans
Expand Down
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,31 @@ All these things are implemented in 100% managed code on top of existing .NET AP
* [NuGet Packages](https://www.nuget.org/profiles/rvsakno)

# What's new
Release Date: 02-28-2024
Release Date: 03-08-2024

<a href="https://www.nuget.org/packages/dotnext/5.1.0">DotNext 5.1.0</a>
* Added `Span.Advance<T>` extension method for spans
* `CollectionType.GetItemType` now correctly recognizes enumerable pattern even if target type doesn't implement `IEnumerable<T>`
<a href="https://www.nuget.org/packages/dotnext/5.2.0">DotNext 5.2.0</a>
* Added `Number.IsPrime` static method that allows to check whether the specified number is a prime number
* Fixed AOT compatibility issues

<a href="https://www.nuget.org/packages/dotnext.metaprogramming/5.1.0">DotNext.Metaprogramming 5.1.0</a>
<a href="https://www.nuget.org/packages/dotnext.metaprogramming/5.2.0">DotNext.Metaprogramming 5.2.0</a>
* Updated dependencies

<a href="https://www.nuget.org/packages/dotnext.unsafe/5.1.0">DotNext.Unsafe 5.1.0</a>
* Added `UnmanagedMemory.AsMemory` static method that allows to wrap unmanaged pointer into [Memory&lt;T&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.memory-1)

<a href="https://www.nuget.org/packages/dotnext.threading/5.1.0">DotNext.Threading 5.1.0</a>
<a href="https://www.nuget.org/packages/dotnext.unsafe/5.2.0">DotNext.Unsafe 5.2.0</a>
* Updated dependencies

<a href="https://www.nuget.org/packages/dotnext.io/5.1.0">DotNext.IO 5.1.0</a>
* Merged [225](https://github.com/dotnet/dotNext/pull/225)
* Added `AsUnbufferedStream` extension method for [SafeFileHandle](https://learn.microsoft.com/en-us/dotnet/api/microsoft.win32.safehandles.safefilehandle) class
<a href="https://www.nuget.org/packages/dotnext.threading/5.2.0">DotNext.Threading 5.2.0</a>
* Added specialized `IndexPool` data type that can be useful for implementing fast object pools

<a href="https://www.nuget.org/packages/dotnext.net.cluster/5.1.0">DotNext.Net.Cluster 5.1.0</a>
<a href="https://www.nuget.org/packages/dotnext.io/5.2.0">DotNext.IO 5.2.0</a>
* Updated dependencies

<a href="https://www.nuget.org/packages/dotnext.aspnetcore.cluster/5.1.0">DotNext.AspNetCore.Cluster 5.1.0</a>
* Updated dependencies
<a href="https://www.nuget.org/packages/dotnext.net.cluster/5.2.0">DotNext.Net.Cluster 5.2.0</a>
* Fixed [226](https://github.com/dotnet/dotNext/issues/226)
* Fixed [221](https://github.com/dotnet/dotNext/issues/221)

<a href="https://www.nuget.org/packages/dotnext.aspnetcore.cluster/5.2.0">DotNext.AspNetCore.Cluster 5.2.0</a>
* Fixed [226](https://github.com/dotnet/dotNext/issues/226)
* Fixed [221](https://github.com/dotnet/dotNext/issues/221)

Changelog for previous versions located [here](./CHANGELOG.md).

Expand Down
2 changes: 1 addition & 1 deletion src/DotNext.IO/DotNext.IO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Authors>.NET Foundation and Contributors</Authors>
<Company />
<Product>.NEXT Family of Libraries</Product>
<VersionPrefix>5.1.0</VersionPrefix>
<VersionPrefix>5.2.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<AssemblyName>DotNext.IO</AssemblyName>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
2 changes: 1 addition & 1 deletion src/DotNext.Metaprogramming/DotNext.Metaprogramming.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ImplicitUsings>true</ImplicitUsings>
<IsTrimmable>false</IsTrimmable>
<Features>nullablePublicOnly</Features>
<VersionPrefix>5.1.0</VersionPrefix>
<VersionPrefix>5.2.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<Authors>.NET Foundation</Authors>
<Product>.NEXT Family of Libraries</Product>
Expand Down
107 changes: 107 additions & 0 deletions src/DotNext.Tests/Collections/Concurrent/IndexPoolTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
namespace DotNext.Collections.Concurrent;

public sealed class IndexPoolTests : Test
{
[Fact]
public static void EmptyPool()
{
var pool = default(IndexPool);
False(pool.TryPeek(out _));
False(pool.TryTake(out _));
DoesNotContain(10, pool);
Empty(pool);
}

[Fact]
public static void TakeAll()
{
var pool = new IndexPool();
NotEmpty(pool);

for (var i = 0; i <= IndexPool.MaxValue; i++)
{
Equal(i, pool.Take());
}

Throws<OverflowException>(() => pool.Take());
}

[Fact]
public static void ContainsAll()
{
var pool = new IndexPool();
for (var i = 0; i <= IndexPool.MaxValue; i++)
{
True(pool.Contains(i));
}

for (var i = 0; i <= IndexPool.MaxValue; i++)
{
Equal(i, pool.Take());
}

for (var i = 0; i <= IndexPool.MaxValue; i++)
{
False(pool.Contains(i));
}
}

[Fact]
public static void Enumerator()
{
var pool = new IndexPool();
var expected = new int[pool.Count];
Span.ForEach(expected, static (ref int value, int index) => value = index);

Equal(expected, pool.ToArray());

while (pool.TryTake(out _))
{
// take all indicies
}

Equal(Array.Empty<int>(), pool.ToArray());
}

[Fact]
public static void CustomMaxValue()
{
var pool = new IndexPool(maxValue: 2);
Equal(3, pool.Count);

Equal(0, pool.Take());
Equal(1, pool.Take());
Equal(2, pool.Take());

False(pool.TryTake(out _));
Empty(pool);
}

[Fact]
public static void Consistency()
{
var pool = new IndexPool();
Equal(0, pool.Take());

Equal(1, pool.Take());
pool.Return(1);

Equal(1, pool.Take());
pool.Return(1);

pool.Return(0);
}

[Fact]
public static void TakeReturnMany()
{
var pool = new IndexPool();
Span<int> indicies = stackalloc int[IndexPool.Capacity];

Equal(IndexPool.Capacity, pool.Take(indicies));
Empty(pool);

pool.Return(indicies);
NotEmpty(pool);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,19 @@ public static void Resize()

private static LeaderState<DummyRaftClusterMember>.Replicator CreateReplicator(DummyRaftClusterMember member)
=> new(member, NullLogger.Instance);

[Fact]
public static void RegressionIssue221()
{
const int length = 16;
using var context = new LeaderState<DummyRaftClusterMember>.Context(length);

var keys = new DummyRaftClusterMember[length];
Span.Initialize<DummyRaftClusterMember>(keys);

for (var i = 0; i < length; i++)
{
var ctx = context.GetOrCreate(keys[i], CreateReplicator);
}
}
}
11 changes: 11 additions & 0 deletions src/DotNext.Tests/Numerics/NumberTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,15 @@ public static void BinarySize()
Equal(sizeof(int), Number.GetMaxByteCount<int>());
Equal(sizeof(long), Number.GetMaxByteCount<long>());
}

[Fact]
public static void IsPrime()
{
False(Number.IsPrime(1L));
True(Number.IsPrime(2L));
True(Number.IsPrime<sbyte>(3));
False(Number.IsPrime(4));

True(Number.IsPrime(1669));
}
}
Loading

0 comments on commit b20da06

Please sign in to comment.