Skip to content

Commit

Permalink
Fix previous issues with progress
Browse files Browse the repository at this point in the history
  • Loading branch information
darkl committed Aug 22, 2023
1 parent fac1e63 commit 16e2ca1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,30 @@ public async Task ProgressiveCallsCalleeProxyProgressValueTuples()
Assert.That(result, Is.EqualTo((10, "10")));
}


[Test]
public async Task ProgressiveCallsCalleeProxyProgressValueTuplesReflectionCallee()
{
WampPlayground playground = new WampPlayground();

CallerCallee dualChannel = await playground.GetCallerCalleeDualChannel();
IWampChannel calleeChannel = dualChannel.CalleeChannel;
IWampChannel callerChannel = dualChannel.CallerChannel;

await calleeChannel.RealmProxy.Services.RegisterCallee(new LongOpService());
ILongOpService proxy = callerChannel.RealmProxy.Services.GetCalleeProxy<ILongOpService>();

List<(int a, int b)> results = new List<(int a, int b)>();
MyProgress<(int a, int b)> progress = new MyProgress<(int a, int b)>(i => results.Add(i));

var result = await proxy.LongOpValueTuple(10, progress);

CollectionAssert.AreEquivalent(Enumerable.Range(0, 10).Select(x => (a:x,b:x)), results);

Assert.That(result, Is.EqualTo((10, "10")));
}


[Test]
public async Task ProgressiveCallsCalleeProxyProgressTask()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading;
using WampSharp.Core.Serialization;
using WampSharp.Core.Utilities;
using WampSharp.Core.Utilities.ValueTuple;
using WampSharp.V2.Core.Contracts;

namespace WampSharp.V2.Rpc
Expand All @@ -28,10 +29,12 @@ public ProgressiveAsyncMethodInfoRpcOperation(Func<object> instanceProvider, Met
mProgressExtractor = WampResultExtractor.GetResultExtractor(this, true);

ParameterInfo progressParameter = method.GetProgressParameter();

Type progressType = progressParameter.ParameterType.GetGenericArguments()[0];

if (progressParameter.ParameterType.IsValueType)
if (progressType.IsValueTuple())
{
mProgressExtractor = WampResultExtractor.GetValueTupleResultExtractor(progressParameter.ParameterType, progressParameter);
mProgressExtractor = WampResultExtractor.GetValueTupleResultExtractor(progressType, progressParameter);
}
}

Expand Down

0 comments on commit 16e2ca1

Please sign in to comment.