Skip to content

Commit

Permalink
RPC fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat committed Sep 8, 2020
1 parent 3dbf7cd commit 4cb7bf8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ public event EventHandler<BrokeredServicesChangedEventArgs>? AvailabilityChanged
clientConnection.AddLocalRpcTarget(options.ClientRpcTarget);
}

// Clear RPC target so that the server connection is forced to create a new proxy for the callback
// instead of just invoking the callback object directly (this emulates the product that does
// not serialize the callback object over).
options.ClientRpcTarget = null;

// Creates service instance and connects it to the pipe.
// We don't need to store the instance anywhere.
_ = _services.CreateBrokeredService(descriptor, pipePair.Item1, options);
Expand Down
14 changes: 12 additions & 2 deletions src/Workspaces/Remote/Core/ServiceDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ namespace Microsoft.CodeAnalysis.Remote
/// </summary>
internal sealed class ServiceDescriptor : ServiceJsonRpcDescriptor
{
private static readonly JsonRpcTargetOptions s_jsonRpcTargetOptions = new JsonRpcTargetOptions()
{
// Do not allow JSON-RPC to automatically subscribe to events and remote their calls.
NotifyClientOfEvents = false,

// Only allow public methods (may be on internal types) to be invoked remotely.
AllowNonPublicInvocation = false
};

// Enables remote APIs to pass Stream as parameter.
private static readonly MultiplexingStream.Options s_multiplexingStreamOptions = new MultiplexingStream.Options
{
Expand Down Expand Up @@ -54,7 +63,8 @@ internal static JsonMessageFormatter ConfigureFormatter(JsonMessageFormatter for
protected override JsonRpcConnection CreateConnection(JsonRpc jsonRpc)
{
jsonRpc.CancelLocallyInvokedMethodsWhenConnectionIsClosed = true;
return base.CreateConnection(jsonRpc);
}
var connection = base.CreateConnection(jsonRpc);
connection.LocalRpcTargetOptions = s_jsonRpcTargetOptions;
return connection;
}
}

0 comments on commit 4cb7bf8

Please sign in to comment.