Lightweight .NET Standard 2.0 library to use method calls over named and anonymous pipes for IPC. Supports two-way communication with callbacks.
varpipeServer=newPipeServer<IAdder>(newNetJsonPipeSerializer(),"mypipe",()=>newAdder());awaitpipeServer.WaitForConnectionAsync();varpipeClient=newPipeClient<IAdder>(newNetJsonPipeSerializer(),"mypipe");awaitpipeClient.ConnectAsync();intresult=awaitpipeClient.InvokeAsync(adder =>adder.AddNumbers(1,3));varpipeServer=newPipeServerWithCallback<IConcatenator,IAdder>(newNetJsonPipeSerializer(),"mypipe",()=>newAdder());awaitpipeServer.WaitForConnectionAsync();stringconcatResult=awaitpipeServer.InvokeAsync(c =>c.Concatenate("a","b"));varpipeClient=newPipeClientWithCallback<IAdder,IConcatenator>(newNetJsonPipeSerializer(),"mypipe",()=>newConcatenator());awaitpipeClient.ConnectAsync();intresult=awaitpipeClient.InvokeAsync(a =>a.AddNumbers(4,7));This library uses named pipes to invoke method calls on a remote endpoint. The method arguments are serialized to binary and sent over the pipe.
PipeMethodCalls supports customizable serialization logic through IPipeSerializer. You've got two options:
- Use a pre-built serializer
new NetJsonPipeSerializer()from the PipeMethodCalls.NetJson package. That uses the System.Text.Json serializer that's built into .NET.new MessagePackPipeSerializer()from the PipeMethodCalls.MessagePack package. That uses the MessagePack-CSharp serializer, which has excellent performance.
- Plug in your own implementation of
IPipeSerializer. Refer to the NetJsonPipeSerializer code for an example of how to do this.
Open an issue or pull request if you'd like to see more built-in serializers.
- 100% asynchronous communication with .ConfigureAwait(false) to minimize context switches and reduce thread use
- 45KB with no built-in dependencies
- Invoking async methods
- Passing and returning complex types with pluggable JSON or binary serialization
- Interleaved or multiple simultaneous calls
- Throwing exceptions
- CancellationToken support
- Works on Windows, Linux and MacOS
- Methods with out and ref parameters
- Properties
- Method overloads