Skip to content

Commit

Permalink
Release 5.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sakno committed Oct 13, 2024
1 parent 06ed95f commit 5bdb434
Show file tree
Hide file tree
Showing 46 changed files with 675 additions and 173 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
Release Notes
====

# 10-13-2024
<a href="https://www.nuget.org/packages/dotnext/5.14.0">DotNext 5.14.0</a>
* Added helpers to `DelegateHelpers` class to convert delegates with synchronous signature to their asynchronous counterparts
* Added support of async enumerator to `SingletonList<T>`
* Fixed exception propagation in `DynamicTaskAwaitable`
* Added support of [ConfigureAwaitOptions](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.configureawaitoptions) to `DynamicTaskAwaitable`

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

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

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

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

<a href="https://www.nuget.org/packages/dotnext.net.cluster/5.14.0">DotNext.Net.Cluster 5.14.0</a>
* Fixed graceful shutdown of Raft TCP listener
* Updated vulnerable dependencies

<a href="https://www.nuget.org/packages/dotnext.aspnetcore.cluster/5.14.0">DotNext.AspNetCore.Cluster 5.14.0</a>
* Updated vulnerable dependencies

# 08-30-2024
<a href="https://www.nuget.org/packages/dotnext/5.13.0">DotNext 5.13.0</a>
* Improved interoperability of `DotNext.Runtime.ValueReference<T>` and `DotNext.Runtime.ReadOnlyValueReference<T>` with .NEXT ecosystem
Expand Down
35 changes: 16 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,35 +44,32 @@ 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: 08-30-2024
Release Date: 10-13-2024

<a href="https://www.nuget.org/packages/dotnext/5.13.0">DotNext 5.13.0</a>
* Improved interoperability of `DotNext.Runtime.ValueReference<T>` and `DotNext.Runtime.ReadOnlyValueReference<T>` with .NEXT ecosystem
* Fixed [249](https://github.com/dotnet/dotNext/issues/249)
* Improved codegen quality for ad-hoc enumerator types
<a href="https://www.nuget.org/packages/dotnext/5.14.0">DotNext 5.14.0</a>
* Added helpers to `DelegateHelpers` class to convert delegates with synchronous signature to their asynchronous counterparts
* Added support of async enumerator to `SingletonList<T>`
* Fixed exception propagation in `DynamicTaskAwaitable`
* Added support of [ConfigureAwaitOptions](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.configureawaitoptions) to `DynamicTaskAwaitable`

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

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

<a href="https://www.nuget.org/packages/dotnext.threading/5.13.0">DotNext.Threading 5.13.0</a>
* Redesigned `AsyncEventHub` to improve overall performance and reduce memory allocation
* Improved codegen quality for ad-hoc enumerator types

<a href="https://www.nuget.org/packages/dotnext.io/5.13.0">DotNext.IO 5.13.0</a>
* Improved codegen quality for ad-hoc enumerator types

<a href="https://www.nuget.org/packages/dotnext.net.cluster/5.13.0">DotNext.Net.Cluster 5.13.0</a>
<a href="https://www.nuget.org/packages/dotnext.threading/5.14.0">DotNext.Threading 5.14.0</a>
* Updated dependencies

<a href="https://www.nuget.org/packages/dotnext.aspnetcore.cluster/5.13.0">DotNext.AspNetCore.Cluster 5.13.0</a>
<a href="https://www.nuget.org/packages/dotnext.io/5.14.0">DotNext.IO 5.14.0</a>
* Updated dependencies

<a href="https://www.nuget.org/packages/dotnext.maintenanceservices/0.4.0">DotNext.MaintenanceServices 0.4.0</a>
* Added [gc refresh-mem-limit](https://learn.microsoft.com/en-us/dotnet/api/system.gc.refreshmemorylimit) maintenance command
* Updated dependencies
<a href="https://www.nuget.org/packages/dotnext.net.cluster/5.14.0">DotNext.Net.Cluster 5.14.0</a>
* Fixed graceful shutdown of Raft TCP listener
* Updated vulnerable dependencies

<a href="https://www.nuget.org/packages/dotnext.aspnetcore.cluster/5.14.0">DotNext.AspNetCore.Cluster 5.14.0</a>
* Updated vulnerable dependencies

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

Expand Down
18 changes: 9 additions & 9 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
<PackageVersion Include="System.IO.Hashing" Version="8.0.0" />
<PackageVersion Include="System.IO.Pipelines" Version="8.0.0" />
<PackageVersion Include="System.Resources.Extensions" Version="8.0.0"/>
<PackageVersion Include="System.Runtime.Caching" Version="8.0.0" />
<PackageVersion Include="System.Runtime.Caching" Version="8.0.1" />
<PackageVersion Include="System.Threading.Channels" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<!--Microsoft packages-->
<PackageVersion Include="Microsoft.AspNetCore.Connections.Abstractions" Version="8.0.4" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Connections.Abstractions" Version="8.0.10" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="2.3.2" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
</ItemGroup>
<ItemGroup>
<!--Misc packages-->
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.13.0</VersionPrefix>
<VersionPrefix>5.14.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<AssemblyName>DotNext.IO</AssemblyName>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
10 changes: 5 additions & 5 deletions src/DotNext.IO/IO/FileWriter.Binary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private ValueTask WriteAsync<T>(T arg, SpanAction<byte, T> writer, int length, C
[AsyncMethodBuilder(typeof(PoolingAsyncValueTaskMethodBuilder))]
private async ValueTask WriteBufferedAsync<T>(T arg, SpanAction<byte, T> writer, int length, CancellationToken token)
{
await FlushCoreAsync(token).ConfigureAwait(false);
await FlushAsync(token).ConfigureAwait(false);
writer(BufferSpan, arg);

Debug.Assert(bufferOffset is 0);
Expand Down Expand Up @@ -143,7 +143,7 @@ private int WriteLength(int length, LengthFormat lengthFormat)
public async ValueTask WriteAsync(ReadOnlyMemory<byte> input, LengthFormat lengthFormat, CancellationToken token = default)
{
if (FreeCapacity < SevenBitEncodedInt.MaxSize)
await FlushCoreAsync(token).ConfigureAwait(false);
await FlushAsync(token).ConfigureAwait(false);

WriteLength(input.Length, lengthFormat);
await WriteAsync(input, token).ConfigureAwait(false);
Expand All @@ -165,7 +165,7 @@ public async ValueTask<long> EncodeAsync(ReadOnlyMemory<char> chars, EncodingCon
if (lengthFormat.HasValue)
{
if (FreeCapacity < SevenBitEncodedInt.MaxSize)
await FlushCoreAsync(token).ConfigureAwait(false);
await FlushAsync(token).ConfigureAwait(false);

result = WriteLength(context.Encoding.GetByteCount(chars.Span), lengthFormat.GetValueOrDefault());
}
Expand All @@ -182,7 +182,7 @@ public async ValueTask<long> EncodeAsync(ReadOnlyMemory<char> chars, EncodingCon
for (int charsUsed, bytesUsed; !chars.IsEmpty; chars = chars.Slice(charsUsed), result += bytesUsed)
{
if (FreeCapacity < maxByteCount)
await FlushCoreAsync(token).ConfigureAwait(false);
await FlushAsync(token).ConfigureAwait(false);

Convert(encoder, chars.Span, BufferSpan, maxByteCount, chars.Length, out charsUsed, out bytesUsed);
Produce(bytesUsed);
Expand Down Expand Up @@ -285,7 +285,7 @@ private bool TryFormat<T>(T value, LengthFormat? lengthFormat, ReadOnlySpan<char
private async ValueTask<int> FormatSlowAsync<T>(T value, LengthFormat? lengthFormat, string? format, IFormatProvider? provider, CancellationToken token)
where T : notnull, IUtf8SpanFormattable
{
await FlushCoreAsync(token).ConfigureAwait(false);
await FlushAsync(token).ConfigureAwait(false);
if (!TryFormat(value, lengthFormat, format, provider, out var bytesWritten))
{
const int maxBufferSize = int.MaxValue / 2;
Expand Down
12 changes: 6 additions & 6 deletions src/DotNext.IO/IO/FileWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public FileWriter(FileStream destination, int bufferSize = 4096, MemoryAllocator
public int MaxBufferSize => buffer.Length;

/// <summary>
/// Marks the specified number of bytes in the buffer as consumed.
/// Marks the specified number of bytes in the buffer as produced.
/// </summary>
/// <param name="bytes">The number of consumed bytes.</param>
/// <param name="bytes">The number of produced bytes.</param>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="bytes"/> is larger than the length of <see cref="Buffer"/>.</exception>
public void Produce(int bytes)
{
Expand Down Expand Up @@ -140,10 +140,10 @@ public long FilePosition
/// </remarks>
public long WritePosition => fileOffset + bufferOffset;

private ValueTask FlushCoreAsync(CancellationToken token)
private ValueTask FlushAsync(CancellationToken token)
=> Submit(RandomAccess.WriteAsync(handle, WrittenBuffer, fileOffset, token), writeCallback);

private void FlushCore()
private void Flush()
{
RandomAccess.Write(handle, WrittenBuffer.Span, fileOffset);
fileOffset += bufferOffset;
Expand All @@ -165,7 +165,7 @@ public ValueTask WriteAsync(CancellationToken token = default)
if (token.IsCancellationRequested)
return ValueTask.FromCanceled(token);

return HasBufferedData ? FlushCoreAsync(token) : ValueTask.CompletedTask;
return HasBufferedData ? FlushAsync(token) : ValueTask.CompletedTask;
}

/// <summary>
Expand All @@ -191,7 +191,7 @@ public void Write()
ObjectDisposedException.ThrowIf(IsDisposed, this);

if (HasBufferedData)
FlushCore();
Flush();
}

/// <inheritdoc />
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.13.0</VersionPrefix>
<VersionPrefix>5.14.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<Authors>.NET Foundation</Authors>
<Product>.NEXT Family of Libraries</Product>
Expand Down
22 changes: 22 additions & 0 deletions src/DotNext.Tests/Buffers/BufferWriterSlimTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Numerics;
using System.Text;
using DotNext.Buffers.Binary;
using static System.Globalization.CultureInfo;

namespace DotNext.Buffers;
Expand Down Expand Up @@ -313,4 +315,24 @@ public static void Rendering()
writer.Format(CompositeFormat.Parse("{0}, {1}!"), ["Hello", "world"]);
Equal("Hello, world!", writer.ToString());
}

[Fact]
public static void WriteBlittable()
{
var writer = new BufferWriterSlim<byte>(stackalloc byte[16]);
writer.Write<Blittable<int>>(new() { Value = 42 });

var reader = new SpanReader<byte>(writer.WrittenSpan);
Equal(42, reader.Read<Blittable<int>>().Value);
}

[Fact]
public static void ReadWriteBigInteger()
{
var expected = (BigInteger)100500;
var writer = new BufferWriterSlim<byte>(stackalloc byte[16]);
Equal(3, writer.Write(expected));

Equal(expected, new BigInteger(writer.WrittenSpan));
}
}
49 changes: 46 additions & 3 deletions src/DotNext.Tests/Buffers/BufferWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,12 @@ public static void WriteInterpolatedStringToBufferWriter(int x, int y)
[InlineData(int.MaxValue, int.MinValue)]
public static async Task WriteInterpolatedStringToBufferWriterAsync(int x, int y)
{
var xt = Task.FromResult<int>(x);
var yt = Task.FromResult<int>(y);
var xt = Task.FromResult(x);
var yt = Task.FromResult(y);

using var buffer = new PoolingArrayBufferWriter<char>();
buffer.Interpolate($"{await xt,4:X} = {await yt,-3:X}");
var actualCount = buffer.Interpolate($"{await xt,4:X} = {await yt,-3:X}");
Equal(buffer.WrittenCount, actualCount);
Equal($"{x,4:X} = {y,-3:X}", buffer.ToString());
}

Expand Down Expand Up @@ -334,4 +335,46 @@ public static void Rendering()
writer.Format(CompositeFormat.Parse("{0}, {1}!"), ["Hello", "world"]);
Equal("Hello, world!", writer.WrittenSpan.ToString());
}

[Theory]
[InlineData(0)]
[InlineData(16)]
[InlineData(128)]
[InlineData(124)]
public static void WriteStringBuilder(int stringLength)
{
var str = Random.Shared.NextString("abcdefghijklmnopqrstuvwxyz", stringLength);

var builder = new StringBuilder();
for (var i = 0; i < 3; i++)
{
builder.Append(str);
}

var writer = new BufferWriterSlim<char>();

writer.Write(builder);
Equal(builder.ToString(), writer.WrittenSpan);
}

[Theory]
[InlineData(0)]
[InlineData(16)]
[InlineData(128)]
[InlineData(124)]
public static void WriteStringBuilder2(int stringLength)
{
var str = Random.Shared.NextString("abcdefghijklmnopqrstuvwxyz", stringLength);

var builder = new StringBuilder();
for (var i = 0; i < 3; i++)
{
builder.Append(str);
}

var writer = new ArrayBufferWriter<char>();

writer.Write(builder);
Equal(builder.ToString(), writer.WrittenSpan);
}
}
19 changes: 19 additions & 0 deletions src/DotNext.Tests/Buffers/ChunkSequenceTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Buffers;
using System.Text;

namespace DotNext.Buffers;

Expand Down Expand Up @@ -93,4 +94,22 @@ public static void CopyFromSequence()
Equal(10, writtenCount);
Equal(sequence.Slice(0, 10).ToArray(), dest.ToArray());
}

[Theory]
[InlineData(0)]
[InlineData(16)]
[InlineData(128)]
[InlineData(124)]
public static void StringBuilderToSequence(int stringLength)
{
var str = Random.Shared.NextString("abcdefghijklmnopqrstuvwxyz", stringLength);

var builder = new StringBuilder();
for (var i = 0; i < 3; i++)
{
builder.Append(str);
}

Equal(builder.ToString(), builder.ToReadOnlySequence().ToString());
}
}
22 changes: 22 additions & 0 deletions src/DotNext.Tests/Buffers/SpanReaderWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,26 @@ public static void Rendering()
True(writer.TryFormat(CompositeFormat.Parse("{0}, {1}!"), ["Hello", "world"]));
Equal("Hello, world!", writer.WrittenSpan.ToString());
}

[Theory]
[InlineData(0)]
[InlineData(16)]
[InlineData(128)]
[InlineData(124)]
public static void WriteStringBuilder(int stringLength)
{
var str = Random.Shared.NextString("abcdefghijklmnopqrstuvwxyz", stringLength);

var builder = new StringBuilder();
for (var i = 0; i < 3; i++)
{
builder.Append(str);
}

var chars = new char[builder.Length];
var writer = new SpanWriter<char>(chars);

writer.Write(builder);
Equal(builder.ToString(), writer.WrittenSpan);
}
}
7 changes: 7 additions & 0 deletions src/DotNext.Tests/Collections/Generic/AsyncEnumerableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,11 @@ public static async Task SkipNullsTestAsync()
True(Array.Exists(array, "a".Equals));
True(Array.Exists(array, "b".Equals));
}

[Fact]
public static void Singleton()
{
var enumerable = AsyncEnumerable.Singleton(42);
Equal(42, Single(enumerable));
}
}
Loading

0 comments on commit 5bdb434

Please sign in to comment.