Skip to content

Commit

Permalink
Patch for Metaprogramming 5.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sakno committed May 15, 2024
1 parent 9944784 commit 021f439
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 37 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Release Notes
====

# 05-15-2024
<a href="https://www.nuget.org/packages/dotnext.metaprogramming/5.3.1">DotNext.Metaprogramming 5.3.1</a>
* Fixed [234](https://github.com/dotnet/dotNext/issues/234)
* Updated dependencies

# 05-10-2024
<a href="https://www.nuget.org/packages/dotnext.net.cluster/5.5.1">DotNext.Net.Cluster 5.5.1</a>
* Fixed behavior of `IRaftCluster.ConsensusToken` when a node is in **standby** mode
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ 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: 05-10-2024
Release Date: 05-15-2024

<a href="https://www.nuget.org/packages/dotnext.net.cluster/5.5.1">DotNext.Net.Cluster 5.5.1</a>
* Fixed behavior of `IRaftCluster.ConsensusToken` when a node is in **standby** mode

<a href="https://www.nuget.org/packages/dotnext.aspnetcore.cluster/5.5.1">DotNext.AspNetCore.Cluster 5.5.1</a>
<a href="https://www.nuget.org/packages/dotnext.metaprogramming/5.3.1">DotNext.Metaprogramming 5.3.1</a>
* Fixed [234](https://github.com/dotnet/dotNext/issues/234)
* Updated dependencies

Changelog for previous versions located [here](./CHANGELOG.md).
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.3.0</VersionPrefix>
<VersionPrefix>5.3.1</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 @@ -136,17 +136,16 @@ void IAsyncStateMachine.MoveNext()
}

// finalize state machine
if (StateId == IAsyncStateMachine<TState>.FinalState)
if (StateId is IAsyncStateMachine<TState>.FinalState)
{
if (exception is null)
builder.SetResult();
if (exception?.SourceException is { } e)
{
builder.SetException(e);
}
else
builder.SetException(exception.SourceException);

// perform cleanup after resuming of all suspended tasks
guardedRegionsCounter = 0;
exception = null;
State = default;
{
builder.SetResult();
}
}
}

Expand Down Expand Up @@ -376,18 +375,16 @@ void IAsyncStateMachine.MoveNext()
}

// finalize state machine
if (StateId == IAsyncStateMachine<TState>.FinalState)
if (StateId is IAsyncStateMachine<TState>.FinalState)
{
if (exception is null)
builder.SetResult(result);
if (exception?.SourceException is { } e)
{
builder.SetException(e);
}
else
builder.SetException(exception.SourceException);

// perform cleanup after resuming of all suspended tasks
guardedRegionsCounter = 0;
exception = null;
result = default;
State = default;
{
builder.SetResult(result);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,16 @@ void IAsyncStateMachine.MoveNext()
}

// finalize state machine
if (StateId == IAsyncStateMachine<TState>.FinalState)
if (StateId is IAsyncStateMachine<TState>.FinalState)
{
if (exception is null)
builder.SetResult();
if (exception?.SourceException is { } e)
{
builder.SetException(e);
}
else
builder.SetException(exception.SourceException);
{
builder.SetResult();
}

// perform cleanup after resuming of all suspended tasks
guardedRegionsCounter = 0;
Expand Down Expand Up @@ -376,12 +380,16 @@ void IAsyncStateMachine.MoveNext()
}

// finalize state machine
if (StateId == IAsyncStateMachine<TState>.FinalState)
if (StateId is IAsyncStateMachine<TState>.FinalState)
{
if (exception is null)
builder.SetResult(result);
if (exception?.SourceException is { } e)
{
builder.SetException(e);
}
else
builder.SetException(exception.SourceException);
{
builder.SetResult(result);
}

// perform cleanup after resuming of all suspended tasks
guardedRegionsCounter = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,12 @@ internal MemberExpression Build(Type stateType)
Type stateMachineType;
if (returnType == typeof(void))
{
stateMachineType = usePooling ? typeof(AsyncStateMachine<>) : typeof(PoolingAsyncStateMachine<>);
stateMachineType = usePooling ? typeof(PoolingAsyncStateMachine<>) : typeof(AsyncStateMachine<>);
stateMachineType = stateMachineType.MakeGenericType(stateType);
}
else
{
stateMachineType = usePooling ? typeof(AsyncStateMachine<,>) : typeof(PoolingAsyncStateMachine<,>);
stateMachineType = usePooling ? typeof(PoolingAsyncStateMachine<,>) : typeof(AsyncStateMachine<,>);
stateMachineType = stateMachineType.MakeGenericType(stateType, returnType);
}

Expand Down
18 changes: 18 additions & 0 deletions src/DotNext.Tests/Metaprogramming/LambdaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,4 +475,22 @@ public static async Task ParameterClosure()

Equal("hello, world", await lambda.Compile().Invoke(", world"));
}

[Fact]
public static async Task RegressionIssue234()
{
var asyncMethod = new Func<Task>(DoAsync).Method;
var lambda = AsyncLambda<Func<ValueTask<int>>>(usePooling: true, (ctx, result) =>
{
Await(Expression.Call(asyncMethod));
Assign(result, 42.Const());
}).Compile();

Equal(42, await lambda.Invoke());
Equal(42, await lambda.Invoke());
Equal(42, await lambda.Invoke());
Equal(42, await lambda.Invoke());

static Task DoAsync() => Task.Delay(1);
}
}
2 changes: 0 additions & 2 deletions src/DotNext.Tests/Metaprogramming/RegressionIssue223.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Linq.Expressions;
using System.Reflection;
using DotNext.Linq.Expressions;

namespace DotNext.Metaprogramming;

Expand Down

0 comments on commit 021f439

Please sign in to comment.