Skip to content

Commit ba6d9f9

Browse files
committed
Release 5.25.0
1 parent 1b1a3f3 commit ba6d9f9

File tree

83 files changed

+3250
-2445
lines changed

Some content is hidden

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

83 files changed

+3250
-2445
lines changed

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.24.0</VersionPrefix>
14+
<VersionPrefix>5.25.0</VersionPrefix>
1515
<VersionSuffix></VersionSuffix>
1616
<AssemblyName>DotNext.IO</AssemblyName>
1717
<PackageLicenseExpression>MIT</PackageLicenseExpression>

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
<IsAotCompatible>false</IsAotCompatible>
1010
<Features>nullablePublicOnly</Features>
11-
<VersionPrefix>5.24.0</VersionPrefix>
11+
<VersionPrefix>5.25.0</VersionPrefix>
1212
<VersionSuffix></VersionSuffix>
1313
<Authors>.NET Foundation</Authors>
1414
<Product>.NEXT Family of Libraries</Product>

src/DotNext.Metaprogramming/Runtime/CompilerServices/AsyncStateMachineBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ private static MemberExpression[] CreateStateHolderType(Type returnType, bool us
560560
builder.Add(type);
561561
}
562562

563-
slots = builder.Build(sm.Build, out _);
563+
slots = builder.Build<MemberExpression>(sm.Build, out _);
564564
}
565565

566566
Debug.Assert(sm.StateMachine is not null);

src/DotNext.Tests/Buffers/BufferWriterSlimTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Collections.Immutable;
22
using System.Numerics;
33
using System.Text;
4-
using DotNext.Buffers.Binary;
54
using static System.Globalization.CultureInfo;
65

76
namespace DotNext.Buffers;

src/DotNext.Tests/DelegateHelpersTests.cs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public static void ContravarianceTest()
2121
[Fact]
2222
public static void ChangeDelegateType()
2323
{
24-
WaitCallback callback = static obj => { };
25-
callback += static obj => { };
24+
WaitCallback callback = static _ => { };
25+
callback += static _ => { };
2626
var result = callback.ChangeType<SendOrPostCallback>();
2727
NotNull(result);
2828
var list1 = callback.GetInvocationList().Select(static d => d.Method);
@@ -603,4 +603,39 @@ public static void HideReturnValue2()
603603

604604
int ChangeValue(int value) => box.Value = value;
605605
}
606+
607+
[Fact]
608+
public static void TryInvokeAction()
609+
{
610+
static MethodInfo GetMethod(int argCount)
611+
{
612+
const BindingFlags flags = BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly;
613+
return Single(typeof(DelegateHelpers).GetMethods(flags),
614+
candidate => candidate.Name == nameof(DelegateHelpers.TryInvoke) && candidate.GetParameters().Length == argCount + 1);
615+
}
616+
617+
var successValue = Expression.Empty();
618+
var failedValue = Expression.Throw(Expression.New(typeof(ArithmeticException)), typeof(void));
619+
for (var argCount = 0; argCount <= 10; argCount++)
620+
{
621+
var types = new Type[argCount];
622+
Array.Fill(types, typeof(string));
623+
var actionType = Expression.GetActionType(types);
624+
var parameters = new ParameterExpression[argCount];
625+
parameters.AsSpan().ForEach(static (ref ParameterExpression p, int _) => p = Expression.Parameter(typeof(string)));
626+
//prepare args
627+
var args = new object[parameters.LongLength + 1];
628+
Array.Fill(args, string.Empty);
629+
//find method to test
630+
var method = types is [] ? GetMethod(argCount) : GetMethod(argCount).MakeGenericMethod(types);
631+
//check success scenario
632+
args[0] = Expression.Lambda(actionType, successValue, parameters).Compile();
633+
var result = (Exception)method.Invoke(null, args);
634+
Null(result);
635+
//check failure
636+
args[0] = Expression.Lambda(actionType, failedValue, parameters).Compile();
637+
result = (Exception)method.Invoke(null, args);
638+
IsType<ArithmeticException>(result);
639+
}
640+
}
606641
}

src/DotNext.Tests/DotNext.Tests.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,4 @@
5656
<Generator></Generator>
5757
</EmbeddedResource>
5858
</ItemGroup>
59-
60-
<ItemGroup>
61-
<Folder Include="Threading\Concurrent\" />
62-
</ItemGroup>
6359
</Project>

src/DotNext.Tests/Net/Cluster/Consensus/Raft/StateMachine/WriteAheadLogTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public sealed class WriteAheadLogTests : Test
2020
[Fact]
2121
public static async Task LockManager()
2222
{
23-
await using var lockManager = new WriteAheadLog.LockManager(3);
23+
await using var lockManager = new WriteAheadLog.LockManager();
2424
await lockManager.AcquireReadLockAsync();
2525

2626
var readBarrierTask = lockManager.AcquireReadBarrierAsync().AsTask();
@@ -35,7 +35,7 @@ public static async Task StateManipulations()
3535
IPersistentState state;
3636
var member = ClusterMemberId.FromEndPoint(new IPEndPoint(IPAddress.IPv6Loopback, 3232));
3737

38-
var options = new WriteAheadLog.Options()
38+
var options = new WriteAheadLog.Options
3939
{
4040
Location = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()),
4141
};

src/DotNext.Tests/Runtime/SoftReferenceTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ public static void WithOptions()
3737
{
3838
var reference = CreateReference();
3939

40-
for (var i = 0; i < 30; i++)
40+
do
4141
{
42-
new object();
42+
GC.KeepAlive(new());
4343
GC.Collect();
4444
GC.WaitForPendingFinalizers();
45-
}
45+
} while (reference.As<IOptionMonad<Target>>().HasValue);
4646

4747
Null((Target)reference);
4848

src/DotNext.Tests/Threading/AsyncCountdownEventTests.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,17 @@ public static async Task AbortSuspendedCallers()
6868
{
6969
using var countdown = new AsyncCountdownEvent(4);
7070
var task = countdown.WaitAsync().AsTask();
71-
countdown.Reset();
71+
False(countdown.Reset());
72+
await ThrowsAsync<PendingTaskInterruptedException>(Func.Constant(task));
73+
}
74+
75+
[Fact]
76+
public static async Task AbortSuspendedCallersAndSetCounter()
77+
{
78+
const long initialCount = 4;
79+
using var countdown = new AsyncCountdownEvent(initialCount);
80+
var task = countdown.WaitAsync().AsTask();
81+
False(countdown.Reset(initialCount));
7282
await ThrowsAsync<PendingTaskInterruptedException>(Func.Constant(task));
7383
}
7484
}

src/DotNext.Tests/Threading/AsyncCounterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static async Task DecrementTwice()
7777
public static void IncrementWithUpperBound()
7878
{
7979
const long maxValue = 2L;
80-
using var counter = new AsyncCounter(0);
80+
using var counter = new AsyncCounter();
8181
True(counter.TryIncrement(maxValue));
8282
True(counter.TryIncrement(maxValue));
8383
False(counter.TryIncrement(maxValue));

0 commit comments

Comments
 (0)