Skip to content

Commit 5bdb434

Browse files
committed
Release 5.14.0
1 parent 06ed95f commit 5bdb434

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+675
-173
lines changed

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
11
Release Notes
22
====
33

4+
# 10-13-2024
5+
<a href="https://www.nuget.org/packages/dotnext/5.14.0">DotNext 5.14.0</a>
6+
* Added helpers to `DelegateHelpers` class to convert delegates with synchronous signature to their asynchronous counterparts
7+
* Added support of async enumerator to `SingletonList<T>`
8+
* Fixed exception propagation in `DynamicTaskAwaitable`
9+
* Added support of [ConfigureAwaitOptions](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.configureawaitoptions) to `DynamicTaskAwaitable`
10+
11+
<a href="https://www.nuget.org/packages/dotnext.metaprogramming/5.14.0">DotNext.Metaprogramming 5.14.0</a>
12+
* Updated dependencies
13+
14+
<a href="https://www.nuget.org/packages/dotnext.unsafe/5.14.0">DotNext.Unsafe 5.14.0</a>
15+
* Updated dependencies
16+
17+
<a href="https://www.nuget.org/packages/dotnext.threading/5.14.0">DotNext.Threading 5.14.0</a>
18+
* Updated dependencies
19+
20+
<a href="https://www.nuget.org/packages/dotnext.io/5.14.0">DotNext.IO 5.14.0</a>
21+
* Updated dependencies
22+
23+
<a href="https://www.nuget.org/packages/dotnext.net.cluster/5.14.0">DotNext.Net.Cluster 5.14.0</a>
24+
* Fixed graceful shutdown of Raft TCP listener
25+
* Updated vulnerable dependencies
26+
27+
<a href="https://www.nuget.org/packages/dotnext.aspnetcore.cluster/5.14.0">DotNext.AspNetCore.Cluster 5.14.0</a>
28+
* Updated vulnerable dependencies
29+
430
# 08-30-2024
531
<a href="https://www.nuget.org/packages/dotnext/5.13.0">DotNext 5.13.0</a>
632
* Improved interoperability of `DotNext.Runtime.ValueReference<T>` and `DotNext.Runtime.ReadOnlyValueReference<T>` with .NEXT ecosystem

README.md

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,35 +44,32 @@ All these things are implemented in 100% managed code on top of existing .NET AP
4444
* [NuGet Packages](https://www.nuget.org/profiles/rvsakno)
4545

4646
# What's new
47-
Release Date: 08-30-2024
47+
Release Date: 10-13-2024
4848

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

54-
<a href="https://www.nuget.org/packages/dotnext.metaprogramming/5.13.0">DotNext.Metaprogramming 5.13.0</a>
55+
<a href="https://www.nuget.org/packages/dotnext.metaprogramming/5.14.0">DotNext.Metaprogramming 5.14.0</a>
5556
* Updated dependencies
5657

57-
<a href="https://www.nuget.org/packages/dotnext.unsafe/5.13.0">DotNext.Unsafe 5.13.0</a>
58+
<a href="https://www.nuget.org/packages/dotnext.unsafe/5.14.0">DotNext.Unsafe 5.14.0</a>
5859
* Updated dependencies
5960

60-
<a href="https://www.nuget.org/packages/dotnext.threading/5.13.0">DotNext.Threading 5.13.0</a>
61-
* Redesigned `AsyncEventHub` to improve overall performance and reduce memory allocation
62-
* Improved codegen quality for ad-hoc enumerator types
63-
64-
<a href="https://www.nuget.org/packages/dotnext.io/5.13.0">DotNext.IO 5.13.0</a>
65-
* Improved codegen quality for ad-hoc enumerator types
66-
67-
<a href="https://www.nuget.org/packages/dotnext.net.cluster/5.13.0">DotNext.Net.Cluster 5.13.0</a>
61+
<a href="https://www.nuget.org/packages/dotnext.threading/5.14.0">DotNext.Threading 5.14.0</a>
6862
* Updated dependencies
6963

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

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

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

src/Directory.Packages.props

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@
1414
<PackageVersion Include="System.IO.Hashing" Version="8.0.0" />
1515
<PackageVersion Include="System.IO.Pipelines" Version="8.0.0" />
1616
<PackageVersion Include="System.Resources.Extensions" Version="8.0.0"/>
17-
<PackageVersion Include="System.Runtime.Caching" Version="8.0.0" />
17+
<PackageVersion Include="System.Runtime.Caching" Version="8.0.1" />
1818
<PackageVersion Include="System.Threading.Channels" Version="8.0.0" />
1919
</ItemGroup>
2020
<ItemGroup>
2121
<!--Microsoft packages-->
22-
<PackageVersion Include="Microsoft.AspNetCore.Connections.Abstractions" Version="8.0.4" />
23-
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
24-
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
25-
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
26-
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.0" />
22+
<PackageVersion Include="Microsoft.AspNetCore.Connections.Abstractions" Version="8.0.10" />
23+
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
24+
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.1" />
25+
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
26+
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.1" />
2727
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
28-
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
29-
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="2.3.2" />
30-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
28+
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
29+
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
30+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
3131
</ItemGroup>
3232
<ItemGroup>
3333
<!--Misc packages-->

src/DotNext.IO/DotNext.IO.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Authors>.NET Foundation and Contributors</Authors>
1212
<Company />
1313
<Product>.NEXT Family of Libraries</Product>
14-
<VersionPrefix>5.13.0</VersionPrefix>
14+
<VersionPrefix>5.14.0</VersionPrefix>
1515
<VersionSuffix></VersionSuffix>
1616
<AssemblyName>DotNext.IO</AssemblyName>
1717
<PackageLicenseExpression>MIT</PackageLicenseExpression>

src/DotNext.IO/IO/FileWriter.Binary.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private ValueTask WriteAsync<T>(T arg, SpanAction<byte, T> writer, int length, C
4747
[AsyncMethodBuilder(typeof(PoolingAsyncValueTaskMethodBuilder))]
4848
private async ValueTask WriteBufferedAsync<T>(T arg, SpanAction<byte, T> writer, int length, CancellationToken token)
4949
{
50-
await FlushCoreAsync(token).ConfigureAwait(false);
50+
await FlushAsync(token).ConfigureAwait(false);
5151
writer(BufferSpan, arg);
5252

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

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

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

187187
Convert(encoder, chars.Span, BufferSpan, maxByteCount, chars.Length, out charsUsed, out bytesUsed);
188188
Produce(bytesUsed);
@@ -285,7 +285,7 @@ private bool TryFormat<T>(T value, LengthFormat? lengthFormat, ReadOnlySpan<char
285285
private async ValueTask<int> FormatSlowAsync<T>(T value, LengthFormat? lengthFormat, string? format, IFormatProvider? provider, CancellationToken token)
286286
where T : notnull, IUtf8SpanFormattable
287287
{
288-
await FlushCoreAsync(token).ConfigureAwait(false);
288+
await FlushAsync(token).ConfigureAwait(false);
289289
if (!TryFormat(value, lengthFormat, format, provider, out var bytesWritten))
290290
{
291291
const int maxBufferSize = int.MaxValue / 2;

src/DotNext.IO/IO/FileWriter.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ public FileWriter(FileStream destination, int bufferSize = 4096, MemoryAllocator
9191
public int MaxBufferSize => buffer.Length;
9292

9393
/// <summary>
94-
/// Marks the specified number of bytes in the buffer as consumed.
94+
/// Marks the specified number of bytes in the buffer as produced.
9595
/// </summary>
96-
/// <param name="bytes">The number of consumed bytes.</param>
96+
/// <param name="bytes">The number of produced bytes.</param>
9797
/// <exception cref="ArgumentOutOfRangeException"><paramref name="bytes"/> is larger than the length of <see cref="Buffer"/>.</exception>
9898
public void Produce(int bytes)
9999
{
@@ -140,10 +140,10 @@ public long FilePosition
140140
/// </remarks>
141141
public long WritePosition => fileOffset + bufferOffset;
142142

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

146-
private void FlushCore()
146+
private void Flush()
147147
{
148148
RandomAccess.Write(handle, WrittenBuffer.Span, fileOffset);
149149
fileOffset += bufferOffset;
@@ -165,7 +165,7 @@ public ValueTask WriteAsync(CancellationToken token = default)
165165
if (token.IsCancellationRequested)
166166
return ValueTask.FromCanceled(token);
167167

168-
return HasBufferedData ? FlushCoreAsync(token) : ValueTask.CompletedTask;
168+
return HasBufferedData ? FlushAsync(token) : ValueTask.CompletedTask;
169169
}
170170

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

193193
if (HasBufferedData)
194-
FlushCore();
194+
Flush();
195195
}
196196

197197
/// <inheritdoc />

src/DotNext.Metaprogramming/DotNext.Metaprogramming.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<ImplicitUsings>true</ImplicitUsings>
99
<IsTrimmable>false</IsTrimmable>
1010
<Features>nullablePublicOnly</Features>
11-
<VersionPrefix>5.13.0</VersionPrefix>
11+
<VersionPrefix>5.14.0</VersionPrefix>
1212
<VersionSuffix></VersionSuffix>
1313
<Authors>.NET Foundation</Authors>
1414
<Product>.NEXT Family of Libraries</Product>

src/DotNext.Tests/Buffers/BufferWriterSlimTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
using System.Numerics;
12
using System.Text;
3+
using DotNext.Buffers.Binary;
24
using static System.Globalization.CultureInfo;
35

46
namespace DotNext.Buffers;
@@ -313,4 +315,24 @@ public static void Rendering()
313315
writer.Format(CompositeFormat.Parse("{0}, {1}!"), ["Hello", "world"]);
314316
Equal("Hello, world!", writer.ToString());
315317
}
318+
319+
[Fact]
320+
public static void WriteBlittable()
321+
{
322+
var writer = new BufferWriterSlim<byte>(stackalloc byte[16]);
323+
writer.Write<Blittable<int>>(new() { Value = 42 });
324+
325+
var reader = new SpanReader<byte>(writer.WrittenSpan);
326+
Equal(42, reader.Read<Blittable<int>>().Value);
327+
}
328+
329+
[Fact]
330+
public static void ReadWriteBigInteger()
331+
{
332+
var expected = (BigInteger)100500;
333+
var writer = new BufferWriterSlim<byte>(stackalloc byte[16]);
334+
Equal(3, writer.Write(expected));
335+
336+
Equal(expected, new BigInteger(writer.WrittenSpan));
337+
}
316338
}

src/DotNext.Tests/Buffers/BufferWriterTests.cs

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,12 @@ public static void WriteInterpolatedStringToBufferWriter(int x, int y)
226226
[InlineData(int.MaxValue, int.MinValue)]
227227
public static async Task WriteInterpolatedStringToBufferWriterAsync(int x, int y)
228228
{
229-
var xt = Task.FromResult<int>(x);
230-
var yt = Task.FromResult<int>(y);
229+
var xt = Task.FromResult(x);
230+
var yt = Task.FromResult(y);
231231

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

@@ -334,4 +335,46 @@ public static void Rendering()
334335
writer.Format(CompositeFormat.Parse("{0}, {1}!"), ["Hello", "world"]);
335336
Equal("Hello, world!", writer.WrittenSpan.ToString());
336337
}
338+
339+
[Theory]
340+
[InlineData(0)]
341+
[InlineData(16)]
342+
[InlineData(128)]
343+
[InlineData(124)]
344+
public static void WriteStringBuilder(int stringLength)
345+
{
346+
var str = Random.Shared.NextString("abcdefghijklmnopqrstuvwxyz", stringLength);
347+
348+
var builder = new StringBuilder();
349+
for (var i = 0; i < 3; i++)
350+
{
351+
builder.Append(str);
352+
}
353+
354+
var writer = new BufferWriterSlim<char>();
355+
356+
writer.Write(builder);
357+
Equal(builder.ToString(), writer.WrittenSpan);
358+
}
359+
360+
[Theory]
361+
[InlineData(0)]
362+
[InlineData(16)]
363+
[InlineData(128)]
364+
[InlineData(124)]
365+
public static void WriteStringBuilder2(int stringLength)
366+
{
367+
var str = Random.Shared.NextString("abcdefghijklmnopqrstuvwxyz", stringLength);
368+
369+
var builder = new StringBuilder();
370+
for (var i = 0; i < 3; i++)
371+
{
372+
builder.Append(str);
373+
}
374+
375+
var writer = new ArrayBufferWriter<char>();
376+
377+
writer.Write(builder);
378+
Equal(builder.ToString(), writer.WrittenSpan);
379+
}
337380
}

src/DotNext.Tests/Buffers/ChunkSequenceTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Buffers;
2+
using System.Text;
23

34
namespace DotNext.Buffers;
45

@@ -93,4 +94,22 @@ public static void CopyFromSequence()
9394
Equal(10, writtenCount);
9495
Equal(sequence.Slice(0, 10).ToArray(), dest.ToArray());
9596
}
97+
98+
[Theory]
99+
[InlineData(0)]
100+
[InlineData(16)]
101+
[InlineData(128)]
102+
[InlineData(124)]
103+
public static void StringBuilderToSequence(int stringLength)
104+
{
105+
var str = Random.Shared.NextString("abcdefghijklmnopqrstuvwxyz", stringLength);
106+
107+
var builder = new StringBuilder();
108+
for (var i = 0; i < 3; i++)
109+
{
110+
builder.Append(str);
111+
}
112+
113+
Equal(builder.ToString(), builder.ToReadOnlySequence().ToString());
114+
}
96115
}

0 commit comments

Comments
 (0)