Skip to content

Commit 09613ee

Browse files
committed
Release 5.17.0
1 parent 931fb6c commit 09613ee

File tree

90 files changed

+3188
-804
lines changed

Some content is hidden

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

90 files changed

+3188
-804
lines changed

CHANGELOG.md

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

4+
# 12-29-2024
5+
This release is aimed to improve AOT compatibility. All the examples in the repo are now AOT compatible.
6+
<a href="https://www.nuget.org/packages/dotnext/5.17.0">DotNext 5.17.0</a>
7+
* Fixed AOT compatibility in `TaskType` class
8+
* Added [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable) and [IParsable&lt;T&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.iparsable-1) interfaces to `HttpEndPoint`
9+
* Introduced `TryEncodeAsUtf8` extension method for `SpanWriter<T>`
10+
* Added more factory methods to `DotNext.Buffers.Memory` class to create [ReadOnlySequence&lt;T&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.buffers.readonlysequence-1)
11+
* `Intrinsics.KeepAlive` is introduced for value types
12+
* Added `Synchronization.Wait()` synchronous methods for blocking wait of [value tasks](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.valuetask) without wait handles
13+
14+
<a href="https://www.nuget.org/packages/dotnext.metaprogramming/5.17.0">DotNext.Metaprogramming 5.17.0</a>
15+
* Updated dependencies
16+
17+
<a href="https://www.nuget.org/packages/dotnext.unsafe/5.17.0">DotNext.Unsafe 5.17.0</a>
18+
* Improved AOT support
19+
* Fixed finalizer for unmanaged memory manager that allows to release the allocated unmanaged memory automatically by GC to avoid memory leak
20+
* Updated dependencies
21+
22+
<a href="https://www.nuget.org/packages/dotnext.threading/5.17.0">DotNext.Threading 5.17.0</a>
23+
* Improved AOT support
24+
25+
<a href="https://www.nuget.org/packages/dotnext.io/5.17.0">DotNext.IO 5.17.0</a>
26+
* 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
27+
* Fixed [255](https://github.com/dotnet/dotNext/issues/255)
28+
* `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
29+
30+
<a href="https://www.nuget.org/packages/dotnext.net.cluster/5.17.0">DotNext.Net.Cluster 5.17.0</a>
31+
* Improved AOT support
32+
33+
<a href="https://www.nuget.org/packages/dotnext.aspnetcore.cluster/5.17.0">DotNext.AspNetCore.Cluster 5.17.0</a>
34+
* Improved AOT support
35+
* Fixed [254](https://github.com/dotnet/dotNext/issues/254)
36+
37+
<a href="https://www.nuget.org/packages/dotnext.maintenanceservices/0.5.0">DotNext.MaintenanceServices 0.5.0</a>
38+
* Improved AOT support
39+
440
# 12-07-2024
541
<a href="https://www.nuget.org/packages/dotnext/5.16.0">DotNext 5.16.1</a>
642
* Added [LEB128](https://en.wikipedia.org/wiki/LEB128) encoder and decoder as a public API. See `DotNext.Buffers.Binary.Leb128<T>` type for more information

README.md

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,34 +44,42 @@ 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: 12-07-2024
48-
49-
<a href="https://www.nuget.org/packages/dotnext/5.16.0">DotNext 5.16.1</a>
50-
* Added [LEB128](https://en.wikipedia.org/wiki/LEB128) encoder and decoder as a public API. See `DotNext.Buffers.Binary.Leb128<T>` type for more information
51-
* Added `SlideToEnd` method to `SpanWriter<T>` type
52-
* Added `IsBitSet` and `SetBit` generic methods to `Number` type
53-
* Added `DetachOrCopyBuffer` to `BufferWriterSlim<T>` type
54-
55-
<a href="https://www.nuget.org/packages/dotnext.metaprogramming/5.16.1">DotNext.Metaprogramming 5.16.1</a>
47+
Release Date: 12-29-2024
48+
49+
This release is aimed to improve AOT compatibility. All the examples in the repo are now AOT compatible.
50+
<a href="https://www.nuget.org/packages/dotnext/5.17.0">DotNext 5.17.0</a>
51+
* Fixed AOT compatibility in `TaskType` class
52+
* Added [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable) and [IParsable&lt;T&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.iparsable-1) interfaces to `HttpEndPoint`
53+
* Introduced `TryEncodeAsUtf8` extension method for `SpanWriter<T>`
54+
* Added more factory methods to `DotNext.Buffers.Memory` class to create [ReadOnlySequence&lt;T&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.buffers.readonlysequence-1)
55+
* `Intrinsics.KeepAlive` is introduced for value types
56+
* Added `Synchronization.Wait()` synchronous methods for blocking wait of [value tasks](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.valuetask) without wait handles
57+
58+
<a href="https://www.nuget.org/packages/dotnext.metaprogramming/5.17.0">DotNext.Metaprogramming 5.17.0</a>
5659
* Updated dependencies
5760

58-
<a href="https://www.nuget.org/packages/dotnext.unsafe/5.16.1">DotNext.Unsafe 5.16.1</a>
61+
<a href="https://www.nuget.org/packages/dotnext.unsafe/5.17.0">DotNext.Unsafe 5.17.0</a>
62+
* Improved AOT support
63+
* Fixed finalizer for unmanaged memory manager that allows to release the allocated unmanaged memory automatically by GC to avoid memory leak
5964
* Updated dependencies
6065

61-
<a href="https://www.nuget.org/packages/dotnext.threading/5.16.1">DotNext.Threading 5.16.1</a>
62-
* Async locks with synchronous acquisition methods now throw [LockRecursionException](https://learn.microsoft.com/en-us/dotnet/api/system.threading.lockrecursionexception) if the current thread tries to acquire the lock synchronously and recursively.
63-
* Added support of cancellation token to synchronous acquisition methods of `AsyncExclusiveLock` and `AsyncReaderWriterLock` classes
64-
* Introduced `LinkTo` method overload that supports multiple cancellation tokens
66+
<a href="https://www.nuget.org/packages/dotnext.threading/5.17.0">DotNext.Threading 5.17.0</a>
67+
* Improved AOT support
6568

66-
<a href="https://www.nuget.org/packages/dotnext.io/5.16.1">DotNext.IO 5.16.1</a>
67-
* Introduced `RandomAccessStream` class that represents [Stream](https://learn.microsoft.com/en-us/dotnet/api/system.io.stream) wrapper over the underlying data storage that supports random access pattern
68-
* Added extension method for `SpanWriter<byte>` that provides length-prefixed string encoding
69+
<a href="https://www.nuget.org/packages/dotnext.io/5.17.0">DotNext.IO 5.17.0</a>
70+
* 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
71+
* Fixed [255](https://github.com/dotnet/dotNext/issues/255)
72+
* `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
6973

70-
<a href="https://www.nuget.org/packages/dotnext.net.cluster/5.16.1">DotNext.Net.Cluster 5.16.1</a>
71-
* Updated dependencies
74+
<a href="https://www.nuget.org/packages/dotnext.net.cluster/5.17.0">DotNext.Net.Cluster 5.17.0</a>
75+
* Improved AOT support
7276

73-
<a href="https://www.nuget.org/packages/dotnext.aspnetcore.cluster/5.16.1">DotNext.AspNetCore.Cluster 5.16.1</a>
74-
* Updated dependencies
77+
<a href="https://www.nuget.org/packages/dotnext.aspnetcore.cluster/5.17.0">DotNext.AspNetCore.Cluster 5.17.0</a>
78+
* Improved AOT support
79+
* Fixed [254](https://github.com/dotnet/dotNext/issues/254)
80+
81+
<a href="https://www.nuget.org/packages/dotnext.maintenanceservices/0.5.0">DotNext.MaintenanceServices 0.5.0</a>
82+
* Improved AOT support
7583

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

azure-pipelines.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ variables:
22
Solution: src/DotNext.sln
33
TestFolder: src/DotNext.Tests
44
TestProject: $(TestFolder)/DotNext.Tests.csproj
5+
AotTestFolder: src/DotNext.AotTests
6+
AotTestProject: $(AotTestFolder)/DotNext.AotTests.csproj
57
InternetAccess: false
68
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
79
isMain: $[eq(variables['Build.SourceBranch'], 'refs/heads/master')]
@@ -47,6 +49,19 @@ stages:
4749
feedsToUse: 'config'
4850
nugetConfigPath: 'NuGet.config'
4951
arguments: --configuration Debug
52+
- task: DotNetCoreCLI@2
53+
displayName: Publish AOT Tests
54+
inputs:
55+
command: publish
56+
publishWebProjects: false
57+
zipAfterPublish: false
58+
projects: $(AotTestProject)
59+
arguments: --configuration Release --output $(AotTestFolder)/bin/
60+
- task: CmdLine@2
61+
displayName: Run AOT Tests
62+
inputs:
63+
workingDirectory: $(AotTestFolder)/bin/DotNext.AotTests
64+
script: ./DotNext.AotTests
5065
- task: DotNetCoreCLI@2
5166
displayName: Test Debug
5267
inputs:

src/Directory.Packages.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
2929
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
3030
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
31+
<PackageVersion Include="MSTest.Engine" Version="1.0.0-alpha.24562.1" />
32+
<PackageVersion Include="MSTest.SourceGeneration" Version="1.0.0-alpha.24562.1" />
33+
<PackageVersion Include="Microsoft.Testing.Extensions.TrxReport" Version="1.0.2" />
34+
<PackageVersion Include="Microsoft.Testing.Platform.MSBuild" Version="1.5.0" />
35+
<PackageVersion Include="MSTest.TestFramework" Version="3.7.0" />
36+
<PackageVersion Include="MSTest.Analyzers" Version="3.7.0" />
3137
</ItemGroup>
3238
<ItemGroup>
3339
<!--Misc packages-->
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace DotNext.Collections.Generic;
2+
3+
[TestClass]
4+
public class ListTests
5+
{
6+
[TestMethod]
7+
public void Indexer()
8+
{
9+
IList<long> array = [5L, 6L, 30L];
10+
Assert.AreEqual(30L, List.Indexer<long>.Getter(array, 2));
11+
List.Indexer<long>.Setter(array, 1, 10L);
12+
Assert.AreEqual(10L, array.IndexerGetter().Invoke(1));
13+
array.IndexerSetter().Invoke(0, 6L);
14+
Assert.AreEqual(6L, array.IndexerGetter().Invoke(0));
15+
}
16+
17+
[TestMethod]
18+
public void ReadOnlyIndexer()
19+
{
20+
IReadOnlyList<long> array = [5L, 6L, 20L];
21+
Assert.AreEqual(20L, List.Indexer<long>.ReadOnly(array, 2));
22+
Assert.AreEqual(6L, array.IndexerGetter().Invoke(1));
23+
}
24+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<RootNamespace>DotNext</RootNamespace>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<Version>5.17.0</Version>
9+
<IsPackable>false</IsPackable>
10+
<Authors>.NET Foundation and Contributors</Authors>
11+
<Product>.NEXT Family of Libraries</Product>
12+
<Description>AOT compatibility tests for .NEXT Familiy of Libraries</Description>
13+
<Copyright>Copyright © .NET Foundation and Contributors</Copyright>
14+
<PackageLicenseUrl>https://github.com/dotnet/DotNext/blob/master/LICENSE</PackageLicenseUrl>
15+
<PackageProjectUrl>https://github.com/dotnet/DotNext</PackageProjectUrl>
16+
<RepositoryUrl>https://github.com/dotnet/DotNext.git</RepositoryUrl>
17+
<RepositoryType>git</RepositoryType>
18+
<InvariantGlobalization>true</InvariantGlobalization>
19+
<PublishAot>true</PublishAot>
20+
</PropertyGroup>
21+
22+
<ItemGroup>
23+
<ProjectReference Include="..\DotNext\DotNext.csproj"/>
24+
<PackageReference Include="MSTest.Engine" />
25+
<PackageReference Include="MSTest.SourceGeneration" />
26+
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" />
27+
<PackageReference Include="Microsoft.Testing.Platform.MSBuild"/>
28+
<PackageReference Include="MSTest.TestFramework" />
29+
<PackageReference Include="MSTest.Analyzers" />
30+
</ItemGroup>
31+
32+
<ItemGroup>
33+
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
34+
</ItemGroup>
35+
</Project>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace DotNext.Reflection;
2+
3+
[TestClass]
4+
public class TaskTypeTests
5+
{
6+
[TestMethod]
7+
public void IsCompletedSuccessfullyPropertyGetter()
8+
{
9+
Assert.IsTrue(TaskType.IsCompletedSuccessfullyGetter(Task.CompletedTask));
10+
}
11+
12+
[TestMethod]
13+
public void GetResultSynchronously()
14+
{
15+
Assert.AreEqual(42, TaskType.GetResultGetter<int>().Invoke(Task.FromResult(42)));
16+
}
17+
18+
[TestMethod]
19+
public void IsCompletedPropertyGetter()
20+
{
21+
Assert.IsTrue(Task.CompletedTask.GetIsCompletedGetter().Invoke());
22+
}
23+
}

src/DotNext.Benchmarks/DotNext.Benchmarks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<RootNamespace>DotNext</RootNamespace>
99
<StartupObject>DotNext.Program</StartupObject>
1010
<IsPackable>false</IsPackable>
11-
<Version>5.16.1</Version>
11+
<Version>5.17.0</Version>
1212
<Authors>.NET Foundation and Contributors</Authors>
1313
<Product>.NEXT Family of Libraries</Product>
1414
<Description>Various benchmarks demonstrating performance aspects of .NEXT extensions</Description>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Buffers;
2+
3+
namespace DotNext.Buffers;
4+
5+
/// <summary>
6+
/// Represents buffered reader or writer.
7+
/// </summary>
8+
public interface IBufferedChannel : IResettable, IDisposable
9+
{
10+
/// <summary>
11+
/// Gets buffer allocator.
12+
/// </summary>
13+
MemoryAllocator<byte>? Allocator { get; init; }
14+
15+
/// <summary>
16+
/// Gets the maximum size of the internal buffer.
17+
/// </summary>
18+
int MaxBufferSize { get; init; }
19+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
namespace DotNext.Buffers;
2+
3+
/// <summary>
4+
/// Represents buffered reader.
5+
/// </summary>
6+
public interface IBufferedReader : IBufferedChannel
7+
{
8+
/// <summary>
9+
/// Gets unconsumed part of the buffer.
10+
/// </summary>
11+
ReadOnlyMemory<byte> Buffer { get; }
12+
13+
/// <summary>
14+
/// Advances read position.
15+
/// </summary>
16+
/// <param name="count">The number of consumed bytes.</param>
17+
/// <exception cref="ObjectDisposedException">The reader has been disposed.</exception>
18+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="count"/> is larger than the length of <see cref="Buffer"/>.</exception>
19+
void Consume(int count);
20+
21+
/// <summary>
22+
/// Fetches the data from the underlying storage to the internal buffer.
23+
/// </summary>
24+
/// <param name="token">The token that can be used to cancel the operation.</param>
25+
/// <returns>
26+
/// <see langword="true"/> if the data has been copied from the underlying storage to the internal buffer;
27+
/// <see langword="false"/> if no more data to read.
28+
/// </returns>
29+
/// <exception cref="ObjectDisposedException">The reader has been disposed.</exception>
30+
/// <exception cref="InternalBufferOverflowException">Internal buffer has no free space.</exception>
31+
/// <exception cref="OperationCanceledException">The operation has been canceled.</exception>
32+
ValueTask<bool> ReadAsync(CancellationToken token = default);
33+
34+
/// <summary>
35+
/// Reads the block of the memory.
36+
/// </summary>
37+
/// <param name="destination">The output buffer.</param>
38+
/// <param name="token">The token that can be used to cancel the operation.</param>
39+
/// <returns>The number of bytes copied to <paramref name="destination"/>.</returns>
40+
/// <exception cref="ObjectDisposedException">The reader has been disposed.</exception>
41+
/// <exception cref="OperationCanceledException">The operation has been canceled.</exception>
42+
async ValueTask<int> ReadAsync(Memory<byte> destination, CancellationToken token = default)
43+
{
44+
var result = 0;
45+
for (int bytesRead; result < destination.Length; result += bytesRead, destination = destination.Slice(bytesRead))
46+
{
47+
Buffer.Span.CopyTo(destination.Span, out bytesRead);
48+
Consume(bytesRead);
49+
if (!await ReadAsync(token).ConfigureAwait(false))
50+
break;
51+
}
52+
53+
return result;
54+
}
55+
}

0 commit comments

Comments
 (0)