11using System . Diagnostics ;
22using Microsoft . VisualStudio . Threading ;
3- using StreamJsonRpc ;
4- using StreamJsonRpc . Protocol ;
5- using Xunit ;
6- using Xunit . Abstractions ;
73
84public class JsonRpcDelegatedDispatchAndSendTests : TestBase
95{
@@ -37,6 +33,14 @@ public async Task DispatchRequestIsPassedCorrectTypeOfRequest()
3733 Assert . Equal ( "StreamJsonRpc.JsonMessageFormatter+InboundJsonRpcRequest" , this . serverRpc . LastRequestDispatched ? . GetType ( ) . FullName ) ;
3834 }
3935
36+ [ Fact ]
37+ public async Task DispatchRequestTargetMethod ( )
38+ {
39+ await this . clientRpc . InvokeAsync < string > ( nameof ( Server . TestMethodAsync ) ) ;
40+ Assert . Equal ( typeof ( Server ) , this . serverRpc . LastTargetMethodDispatched ? . TargetObjectType ) ;
41+ Assert . Equal ( typeof ( Server ) . GetMethod ( nameof ( Server . TestMethodAsync ) ) , this . serverRpc . LastTargetMethodDispatched ? . TargetMethodInfo ) ;
42+ }
43+
4044 [ Fact ]
4145 public async Task DelegatedDispatcherCanDispatchInReverseOrderBasedOnTopLevelProperty ( )
4246 {
@@ -84,7 +88,7 @@ public class DelegatedJsonRpc : JsonRpc
8488 {
8589 private const string MessageOrderPropertyName = "messageOrder" ;
8690
87- private AsyncQueue < ( JsonRpcRequest , TaskCompletionSource < bool > , Task < JsonRpcMessage > ) > requestSignalQueue = new AsyncQueue < ( JsonRpcRequest , TaskCompletionSource < bool > , Task < JsonRpcMessage > ) > ( ) ;
91+ private readonly AsyncQueue < ( JsonRpcRequest , TaskCompletionSource < bool > , Task < JsonRpcMessage > ) > requestSignalQueue = new AsyncQueue < ( JsonRpcRequest , TaskCompletionSource < bool > , Task < JsonRpcMessage > ) > ( ) ;
8892 private int messageCounter = 0 ;
8993
9094 public DelegatedJsonRpc ( IJsonRpcMessageHandler handler )
@@ -101,6 +105,8 @@ public DelegatedJsonRpc(IJsonRpcMessageHandler handler, object target)
101105
102106 public JsonRpcRequest ? LastRequestDispatched { get ; private set ; }
103107
108+ public TargetMethod ? LastTargetMethodDispatched { get ; private set ; }
109+
104110 public async Task FlushRequestQueueAsync ( int expectedCount )
105111 {
106112 var requests = new SortedList < int , ( TaskCompletionSource < bool > , Task < JsonRpcMessage > ) > ( ) ;
@@ -124,6 +130,7 @@ public async Task FlushRequestQueueAsync(int expectedCount)
124130 protected override async ValueTask < JsonRpcMessage > DispatchRequestAsync ( JsonRpcRequest request , TargetMethod targetMethod , CancellationToken cancellationToken )
125131 {
126132 this . LastRequestDispatched = request ;
133+ this . LastTargetMethodDispatched = targetMethod ;
127134 TaskCompletionSource < JsonRpcMessage > ? completionTcs = null ;
128135
129136 if ( this . EnableBuffering )
0 commit comments