Skip to content

Commit

Permalink
Release 5.17.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sakno committed Dec 30, 2024
1 parent 09613ee commit 703ce02
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Release Notes
====

# 12-30-2024
<a href="https://www.nuget.org/packages/dotnext.io/5.17.1">DotNext.IO 5.17.1</a>
* Fixed `EndOfStreamException` caused by async read from `PoolingBufferedStream`

# 12-29-2024
This release is aimed to improve AOT compatibility. All the examples in the repo are now AOT compatible.
<a href="https://www.nuget.org/packages/dotnext/5.17.0">DotNext 5.17.0</a>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ This release is aimed to improve AOT compatibility. All the examples in the repo
<a href="https://www.nuget.org/packages/dotnext.threading/5.17.0">DotNext.Threading 5.17.0</a>
* Improved AOT support

<a href="https://www.nuget.org/packages/dotnext.io/5.17.0">DotNext.IO 5.17.0</a>
<a href="https://www.nuget.org/packages/dotnext.io/5.17.1">DotNext.IO 5.17.1</a>
* Reduced memory consumption for applications that use `FileReader` and `FileWriter` classes. These classes are now implemented by using lazy buffer pattern. It means that the different instances can reuse the same buffer taken from the pool
* Fixed [255](https://github.com/dotnet/dotNext/issues/255)
* `PoolingBufferedStream` is introduced to replace classic [BufferedStream](https://learn.microsoft.com/en-us/dotnet/api/system.io.bufferedstream). This class supports memory pooling and implements lazy buffer pattern
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.17.0</VersionPrefix>
<VersionPrefix>5.17.1</VersionPrefix>
<VersionSuffix></VersionSuffix>
<AssemblyName>DotNext.IO</AssemblyName>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
2 changes: 1 addition & 1 deletion src/DotNext.IO/IO/PoolingBufferedStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ public override ValueTask<int> ReadAsync(Memory<byte> data, CancellationToken to
{
task = ValueTask.FromException<int>(new NotSupportedException());
}
else if (buffer.IsEmpty)
else if (data.IsEmpty)
{
task = new(result: 0);
}
Expand Down
32 changes: 32 additions & 0 deletions src/DotNext.Tests/IO/PoolingBufferedStreamTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,36 @@ public static void ResetBuffer()
bufferedStream.Reset();
False(bufferedStream.HasBufferedDataToWrite);
}

[Fact]
public static void ReadFromFile()
{
var expected = RandomBytes(4096);
using var handle = File.OpenHandle(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()), FileMode.CreateNew, FileAccess.ReadWrite,
options: FileOptions.DeleteOnClose);
RandomAccess.Write(handle, expected, fileOffset: 0L);
RandomAccess.FlushToDisk(handle);

using var bufferedStream = new PoolingBufferedStream(handle.AsUnbufferedStream(FileAccess.Read)) { MaxBufferSize = 128 };
var actual = new byte[expected.Length];
bufferedStream.ReadExactly(actual);

Equal(expected, actual);
}

[Fact]
public static async Task ReadFromFileAsync()
{
var expected = RandomBytes(4096);
using var handle = File.OpenHandle(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()), FileMode.CreateNew, FileAccess.ReadWrite,
options: FileOptions.DeleteOnClose | FileOptions.Asynchronous);
await RandomAccess.WriteAsync(handle, expected, fileOffset: 0L);
RandomAccess.FlushToDisk(handle);

await using var bufferedStream = new PoolingBufferedStream(handle.AsUnbufferedStream(FileAccess.Read)) { MaxBufferSize = 128 };
var actual = new byte[expected.Length];
await bufferedStream.ReadExactlyAsync(actual);

Equal(expected, actual);
}
}
4 changes: 2 additions & 2 deletions src/examples/HyParViewPeer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ static Task PrintNeighborsAsync(HttpContext context)

file sealed class RumorSender : Disposable, IRumorSender
{
internal const string SenderAddressHeader = "X-Sender-Address";
internal const string SenderIdHeader = "X-Rumor-ID";
private const string SenderAddressHeader = "X-Sender-Address";
private const string SenderIdHeader = "X-Rumor-ID";

internal const string RumorResource = "/rumor";
internal const string BroadcastResource = "/broadcast";
Expand Down

0 comments on commit 703ce02

Please sign in to comment.