You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Could you please consider making marshaled object support available for custom interfaces?
The goal would be to allow an RPC interface to expose APIs like
public interface IMyServer
{
Task<IFoo> GetSomethingAsync();
Task GiveSomethingAsync(IBar bar);
}
The caller would call await GetSomethingAsync() and receive a disposable proxy of an IFoo object.
The caller would call await GiveSomethingAsync(bar) and the server would receive a disposable proxy for the bar object.
Calls to methods exposed by the IFoo and IBar proxies would result in RPC calls and the corresponding method being executed on the corresponding object.
The receiver of a marshaled object will be responsible for disposing of the proxy. I am not sure if it should be mandatory for interfaces that are marshaled as objects to be IDisposable (i.e., interface IFoo : IDisposable and interface IBar : IDisposable).
This feature request doesn't cover any other members other than methods (e.g. properties), I don't have a use case for that.
Thanks
The text was updated successfully, but these errors were encountered:
This line (and the surrounding array) is what controls which types will get marshaled instead of serialized.
At the moment this is a static list. I believe the static list should remain, but any use of that list may be augmented with another list that is maintained on a per-JsonRpc instance basis, or perhaps by checking for an attribute on the interface being tested.
I think we should start with requiring any additional interfaces to derive from IDisposable, since that makes it more obvious to the receiver that they should dispose of these proxies. If we need to we can always remove that requirement, but adding it later would be a breaking change, so I prefer to start conservatively.
AArnott
changed the title
[Feature request] Make support for marshaled objects available for custom types
Make support for marshaled objects available for custom types
Mar 3, 2022
This PR addresses #774.
Added the `RpcMarshalable` attribute that can be applied to an interface that:
- extends IDisposable,
- doesn't have properties,
- doesn't have events.
See https://github.com/microsoft/vs-streamjsonrpc/blob/main/doc/rpc_marshalable_objects.md for more information.
Co-authored-by: Matteo Prosperi <maprospe@microsoft.com>
Co-authored-by: Andrew Arnott <andrewarnott@gmail.com>
Could you please consider making marshaled object support available for custom interfaces?
The goal would be to allow an RPC interface to expose APIs like
The caller would call
await GetSomethingAsync()
and receive a disposable proxy of anIFoo
object.The caller would call
await GiveSomethingAsync(bar)
and the server would receive a disposable proxy for thebar
object.Calls to methods exposed by the
IFoo
andIBar
proxies would result in RPC calls and the corresponding method being executed on the corresponding object.The receiver of a marshaled object will be responsible for disposing of the proxy. I am not sure if it should be mandatory for interfaces that are marshaled as objects to be
IDisposable
(i.e.,interface IFoo : IDisposable
andinterface IBar : IDisposable
).This feature request doesn't cover any other members other than methods (e.g. properties), I don't have a use case for that.
Thanks
The text was updated successfully, but these errors were encountered: