Skip to content

Commit

Permalink
Release 5.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sakno committed Aug 1, 2024
1 parent 2d5abd2 commit 6cd709b
Show file tree
Hide file tree
Showing 63 changed files with 1,345 additions and 149 deletions.
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
Release Notes
====

# 08-01-2024
<a href="https://www.nuget.org/packages/dotnext/5.11.0">DotNext 5.11.0</a>
* Added `DotNext.Threading.Epoch` for epoch-based reclamation
* Fixed one-shot FNV1a hashing method
* Fixed [248](https://github.com/dotnet/dotNext/issues/248)
* Minor performance improvements

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

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

<a href="https://www.nuget.org/packages/dotnext.threading/5.11.0">DotNext.Threading 5.11.0</a>
* Fixed `AsyncSharedLock.Downgrade` behavior, so it can be used to release a weak lock
* Updated dependencies

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

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

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

# 07-15-2024
<a href="https://www.nuget.org/packages/dotnext/5.8.0">DotNext 5.8.0</a>
* Added `FirstOrNone` and `LastOrNone` extension methods back from .NEXT 4.x as requested in [247](https://github.com/dotnet/dotNext/issues/247)
Expand Down
34 changes: 27 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,35 @@ 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: 07-15-2024
Release Date: 08-01-2024

<a href="https://www.nuget.org/packages/dotnext/5.8.0">DotNext 5.8.0</a>
* Added `FirstOrNone` and `LastOrNone` extension methods back from .NEXT 4.x as requested in [247](https://github.com/dotnet/dotNext/issues/247)
<a href="https://www.nuget.org/packages/dotnext/5.11.0">DotNext 5.11.0</a>
* Added `DotNext.Threading.Epoch` for epoch-based reclamation
* Fixed one-shot FNV1a hashing method
* Fixed [248](https://github.com/dotnet/dotNext/issues/248)
* Minor performance improvements

<a href="https://www.nuget.org/packages/dotnext.threading/5.10.0">DotNext.Threading 5.10.0</a>
* Added `TaskQueue<T>` class
* Added `Completion` optional property to [TaskCompletionPipe&lt;T&gt;](https://dotnet.github.io/dotNext/api/DotNext.Threading.Tasks.TaskCompletionPipe-1.html) that allows to synchronize on full completion of the pipe
* Added one-shot static methods to [TaskCompletionPipe](https://dotnet.github.io/dotNext/api/DotNext.Threading.Tasks.TaskCompletionPipe.html) to take `IAsyncEnumerable<T>` over tasks as they complete
<a href="https://www.nuget.org/packages/dotnext.metaprogramming/5.11.0">DotNext.Metaprogramming 5.11.0</a>
* Minor performance improvements
* Updated dependencies

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

<a href="https://www.nuget.org/packages/dotnext.threading/5.11.0">DotNext.Threading 5.11.0</a>
* Fixed `AsyncSharedLock.Downgrade` behavior, so it can be used to release a weak lock
* Updated dependencies

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

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/DotNext.Benchmarks/DotNext.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<RootNamespace>DotNext</RootNamespace>
<StartupObject>DotNext.Program</StartupObject>
<IsPackable>false</IsPackable>
<Version>5.7.0</Version>
<Version>5.11.0</Version>
<Authors>.NET Foundation and Contributors</Authors>
<Product>.NEXT Family of Libraries</Product>
<Description>Various benchmarks demonstrating performance aspects of .NEXT extensions</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void Setup()
}

[GlobalCleanup]
public void Cleanup()
public void CleanUp()
{
data.Clear();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public async Task ProduceConsumeCompletionPipe()
Task<int> consumer = Task.Run(async () =>
{
var sum = 0;
await foreach (var item in pipe.GetConsumer())
await foreach (var item in pipe.Consume())
sum += item;

return sum;
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.7.1</VersionPrefix>
<VersionPrefix>5.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<AssemblyName>DotNext.IO</AssemblyName>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
11 changes: 7 additions & 4 deletions src/DotNext.IO/IO/IDataTransferObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,13 @@ ValueTask<TResult> TransformAsync<TResult, TTransformation>(TTransformation tran
if (TryGetMemory(out var memory))
return transformation.TransformAsync(IAsyncBinaryReader.Create(memory), token);

if (Length.TryGetValue(out var length))
return length < FileBufferingWriter.Options.DefaultMemoryThreshold ? GetSmallObjectDataAsync<TResult, TTransformation>(transformation, length, token) : GetLargeObjectDataAsync<TResult, TTransformation>(transformation, length, token);

return GetUnknownObjectDataAsync<TResult, TTransformation>(transformation, token);
return Length switch
{
{ } length and < FileBufferingWriter.Options.DefaultMemoryThreshold => GetSmallObjectDataAsync<TResult, TTransformation>(transformation,
length, token),
{ } length => GetLargeObjectDataAsync<TResult, TTransformation>(transformation, length, token),
_ => GetUnknownObjectDataAsync<TResult, TTransformation>(transformation, token)
};
}

/// <summary>
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.7.0</VersionPrefix>
<VersionPrefix>5.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<Authors>.NET Foundation</Authors>
<Product>.NEXT Family of Libraries</Product>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public override Expression Reduce()
Expression? disposeCall;
MethodInfo? disposeMethod;

if (this.configureAwait.TryGetValue(out var configureAwait))
if (this.configureAwait is { } configureAwait)
{
moveNextCall = moveNextCall.Await(configureAwait);
disposeMethod = enumeratorVar.Type.GetDisposeAsyncMethod();
Expand Down
10 changes: 5 additions & 5 deletions src/DotNext.Metaprogramming/Linq/Expressions/UsingExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ public Expression Body
/// <returns>Updated expression.</returns>
public UsingExpression Update(Expression body)
{
var resource = assignment is null ? Resource : assignment.Right;
var result = this.configureAwait.TryGetValue(out var configureAwait) ?
new UsingExpression(resource, configureAwait) :
new UsingExpression(resource);
var resource = assignment?.Right ?? Resource;
var result = this.configureAwait is { } configureAwait
? new UsingExpression(resource, configureAwait)
: new UsingExpression(resource);
result.Body = body;
return result;
}
Expand All @@ -149,7 +149,7 @@ public UsingExpression Update(Expression body)
public override Expression Reduce()
{
Expression disposeCall = Call(Resource, disposeMethod);
if (this.configureAwait.TryGetValue(out var configureAwait))
if (this.configureAwait is { } configureAwait)
{
disposeCall = disposeCall.Await(configureAwait);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ private ConditionalBuilder Branch(Func<Expression, ConditionalBuilder> branch, A
private protected override ConditionalExpression Build()
=> Expression.Condition(test, ifTrue ?? Expression.Empty(), ifFalse ?? Expression.Empty(), Type);

private protected override void Cleanup()
private protected override void CleanUp()
{
ifTrue = ifFalse = null;
base.Cleanup();
base.CleanUp();
}

private sealed class BranchStatement : Statement, ILexicalScope<ConditionalBuilder, Action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public ExpressionBuilder<TExpression> OfType(Type expressionType)
/// <inheritdoc />
TExpression ISupplier<TExpression>.Invoke() => Build();

private protected virtual void Cleanup() => currentScope = null;
private protected virtual void CleanUp() => currentScope = null;

/// <summary>
/// Finalizes construction of the expression
Expand All @@ -70,6 +70,6 @@ public void End()
if (currentScope is null)
throw new InvalidOperationException();
currentScope.AddStatement(Build());
Cleanup();
CleanUp();
}
}
4 changes: 2 additions & 2 deletions src/DotNext.Metaprogramming/Metaprogramming/MatchBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,11 @@ private protected override BlockExpression Build()
return assignment is null ? Expression.Block(instructions) : Expression.Block(List.Singleton(value), instructions);
}

private protected override void Cleanup()
private protected override void CleanUp()
{
patterns.Clear();
defaultCase = null;
base.Cleanup();
base.CleanUp();
}

private delegate ConditionalExpression PatternMatch(LabelTarget endOfMatch);
Expand Down
4 changes: 2 additions & 2 deletions src/DotNext.Metaprogramming/Metaprogramming/SwitchBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ private SwitchBuilder Case(Func<Expression, SwitchBuilder> @case, Action body)

private protected override SwitchExpression Build() => Expression.Switch(Type, switchValue, defaultExpression, null, cases);

private protected override void Cleanup()
private protected override void CleanUp()
{
cases.Clear();
defaultExpression = null;
base.Cleanup();
base.CleanUp();
}

private sealed class CaseStatement : Statement, ILexicalScope<SwitchBuilder, Action>
Expand Down
4 changes: 2 additions & 2 deletions src/DotNext.Metaprogramming/Metaprogramming/TryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ public TryBuilder Finally(Action body)

private protected override TryExpression Build() => Expression.MakeTry(Type, tryBlock, finallyBlock, faultBlock, handlers);

private protected override void Cleanup()
private protected override void CleanUp()
{
handlers.Clear();
faultBlock = finallyBlock = null;
base.Cleanup();
base.CleanUp();
}

private sealed class CatchStatement : Statement, ILexicalScope<TryBuilder, Action<ParameterExpression>>, ILexicalScope<TryBuilder, Action>
Expand Down
13 changes: 13 additions & 0 deletions src/DotNext.Tests/BasicExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ public static void CopyDataStorage2()
Equal(42L, obj1.GetUserData().Get(slot));
}

[Fact]
public static void RegressionIssue248()
{
var slot = new UserDataSlot<long>();
var str1 = new string('a', 3);
var str2 = new string('b', 3);
NotSame(str1, str2);
str2.GetUserData().Set(slot, 42L);
str1.GetUserData().CopyTo(str2);

False(str2.GetUserData().TryGet(slot, out _));
}

[Fact]
public static void UserDataStorageGetOrSet()
{
Expand Down
2 changes: 1 addition & 1 deletion src/DotNext.Tests/DotNext.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<LangVersion>latest</LangVersion>
<ImplicitUsings>true</ImplicitUsings>
<EnableNETAnalyzers>false</EnableNETAnalyzers>
<Version>5.7.0</Version>
<Version>5.11.0</Version>
<IsPackable>false</IsPackable>
<Authors>.NET Foundation and Contributors</Authors>
<Product>.NEXT Family of Libraries</Product>
Expand Down
2 changes: 1 addition & 1 deletion src/DotNext.Tests/EnumTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private static void ToPrimitive<TEnum>(TEnum zero, TEnum one, TEnum two)
}

[Fact]
public static void ConvertionToPrimitive()
public static void ConversionToPrimitive()
{
ToPrimitive(ByteEnum.Zero, ByteEnum.One, ByteEnum.Two);
ToPrimitive(SByteEnum.Zero, SByteEnum.One, SByteEnum.Two);
Expand Down
25 changes: 20 additions & 5 deletions src/DotNext.Tests/OptionalTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace DotNext;

using Runtime.CompilerServices;

public sealed class OptionalTest : Test
{
[Fact]
Expand Down Expand Up @@ -270,40 +272,53 @@ public static void Flatten()
[Fact]
public static void ConvertNoneToValueType()
{
var value = Optional<int>.None.Convert<string>(static i => i.ToString());
var value = Optional<int>.None.Convert(static i => i.ToString());
False(value.HasValue);
False(value.IsNull);
}

[Fact]
public static void ConvertValueTypeToValueType()
{
var value = new Optional<int>(42).Convert<int>(static i => i + 1);
var value = new Optional<int>(42).Convert(static i => i + 1);
True(value.HasValue);
Equal(43, value.Value);
}

[Fact]
public static unsafe void ConvertNullToValueType()
{
var value = new Optional<string>(null).Convert<int>(&int.Parse);
var value = new Optional<string>(null).Convert(&int.Parse);
False(value.HasValue);
False(value.IsNull);
}

[Fact]
public static void ConvertNullToRefType()
{
var value = new Optional<string>(null).Convert<string>(Converter.Identity<string, string>());
var value = new Optional<string>(null).Convert(Converter.Identity<string, string>());
False(value.HasValue);
True(value.IsNull);
}

[Fact]
public static void ConvertNoneToRefType()
{
var value = Optional<string>.None.Convert<string>(Converter.Identity<string, string>());
var value = Optional<string>.None.Convert(Converter.Identity<string, string>());
False(value.HasValue);
False(value.IsNull);
}

[Fact]
public static void OptionalToDelegate()
{
IFunctional<Func<object>> functional = Optional.None<object>();
Null(functional.ToDelegate().Invoke());

functional = new Optional<int>(42);
Equal(42, functional.ToDelegate().Invoke());

functional = Optional.None<int>();
Null(functional.ToDelegate().Invoke());
}
}
20 changes: 19 additions & 1 deletion src/DotNext.Tests/ResultTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace DotNext;

using Runtime.CompilerServices;

public sealed class ResultTests : Test
{
[Fact]
Expand All @@ -19,7 +21,7 @@ public static void EmptyResult2()
var r = default(Result<int, EnvironmentVariableTarget>);
Equal(default(EnvironmentVariableTarget), r.Error);
True(r.IsSuccessful);
Equal(0, r.Value);
Equal(0, r.ValueRef);
Equal(default, r);
True(r.TryGet(out _));
}
Expand Down Expand Up @@ -204,6 +206,22 @@ public static void FromErrorFactory()
False(FromError<EnvironmentVariableTarget, Result<int, EnvironmentVariableTarget>>(EnvironmentVariableTarget.Machine).IsSuccessful);
}

[Fact]
public static void ResultToDelegate()
{
IFunctional<Func<object>> functional = Result.FromException<int>(new Exception());
Null(functional.ToDelegate().Invoke());

functional = new Result<int>(42);
Equal(42, functional.ToDelegate().Invoke());

functional = new Result<int, EnvironmentVariableTarget>(EnvironmentVariableTarget.Machine);
Null(functional.ToDelegate().Invoke());

functional = new Result<int, EnvironmentVariableTarget>();
NotNull(functional.ToDelegate().Invoke());
}

private static TResult FromError<TError, TResult>(TError error)
where TResult : struct, IResultMonad<int, TError, TResult>
=> TResult.FromError(error);
Expand Down
Loading

0 comments on commit 6cd709b

Please sign in to comment.