From 16e2ca19ecb743456425e01325b10bc52deb42ad Mon Sep 17 00:00:00 2001 From: Elad Zelingher Date: Tue, 22 Aug 2023 17:06:25 -0400 Subject: [PATCH] Fix previous issues with progress --- .../Integration/RpcProgressTests.cs | 24 +++++++++++++++++++ .../ProgressiveAsyncMethodInfoRpcOperation.cs | 7 ++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/netstandard/Tests/WampSharp.Tests.Wampv2/Integration/RpcProgressTests.cs b/src/netstandard/Tests/WampSharp.Tests.Wampv2/Integration/RpcProgressTests.cs index 4fa77a6d..ae53b414 100644 --- a/src/netstandard/Tests/WampSharp.Tests.Wampv2/Integration/RpcProgressTests.cs +++ b/src/netstandard/Tests/WampSharp.Tests.Wampv2/Integration/RpcProgressTests.cs @@ -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(); + + 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() { diff --git a/src/netstandard/WampSharp/WAMP2/V2/Rpc/Callee/Reflection/ProgressiveAsyncMethodInfoRpcOperation.cs b/src/netstandard/WampSharp/WAMP2/V2/Rpc/Callee/Reflection/ProgressiveAsyncMethodInfoRpcOperation.cs index 3ef79aa7..15b057c5 100644 --- a/src/netstandard/WampSharp/WAMP2/V2/Rpc/Callee/Reflection/ProgressiveAsyncMethodInfoRpcOperation.cs +++ b/src/netstandard/WampSharp/WAMP2/V2/Rpc/Callee/Reflection/ProgressiveAsyncMethodInfoRpcOperation.cs @@ -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 @@ -28,10 +29,12 @@ public ProgressiveAsyncMethodInfoRpcOperation(Func 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); } }