Chriffizient.PlainlyIpc 0.9.0

dotnet add package Chriffizient.PlainlyIpc --version 0.9.0
                    
NuGet\Install-Package Chriffizient.PlainlyIpc -Version 0.9.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Chriffizient.PlainlyIpc" Version="0.9.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Chriffizient.PlainlyIpc" Version="0.9.0" />
                    
Directory.Packages.props
<PackageReference Include="Chriffizient.PlainlyIpc" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Chriffizient.PlainlyIpc --version 0.9.0
                    
#r "nuget: Chriffizient.PlainlyIpc, 0.9.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Chriffizient.PlainlyIpc@0.9.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Chriffizient.PlainlyIpc&version=0.9.0
                    
Install as a Cake Addin
#tool nuget:?package=Chriffizient.PlainlyIpc&version=0.9.0
                    
Install as a Cake Tool

PlainlyIpc

A minimalistic, easy-to-use library for inter-process communication (IPC) with .NET.

The basic one-way IPC communication is realized via the IIpcSender and IIpcReceiver interfaces. The IIpcHandler interface relies on these interfaces and enables bidirectional communication and Remote Procedure Calls (RPC).

The IpcFactory class allows the easy creation of corresponding instances for these interfaces:

IpcFactory ipcFactory = new IpcFactory();
IpcFactory ipcFactory = new IpcFactory(objectConverter);

Creating IIpcSender & IIpcReceiver instances based on named pipes or TCP:

// Named pipe
IIpcReceiver receiver = await ipcFactory.CreateNamedPipeIpcReceiver(namedPipeName);
IIpcSender sender = await ipcFactory.CreateNamedPipeIpcSender(namedPipeName);

// TCP
IIpcReceiver receiver = await ipcFactory.CreateTcpIpcReceiver(namedPipeName);
IIpcSender sender = await ipcFactory.CreateTcpIpcSender(namedPipeName);

Creating IpcHandler instances based on named pipes or TCP:

// Named pipe
IIpcHandler server = await ipcFactory.CreateNamedPipeIpcServer(namedPipeName);
IIpcHandler client = await ipcFactory.CreateNamedPipeIpcClient(namedPipeName);

// TCP
IIpcHandler server = await ipcFactory.CreateTcpIpcServer(namedPipeName);
IIpcHandler client = await ipcFactory.CreateTcpIpcClient(namedPipeName);

The IIpcSender offers the following methods:

Task SendAsync(byte[] data);
Task SendAsync(ReadOnlyMemory<byte> data);
Task SendStringAsync(string data);
Task SendObjectAsync<T>(T data);

The IIpcReceiver offers the following events:

event EventHandler<IpcMessageReceivedEventArgs>? MessageReceived;
event EventHandler<ErrorOccurredEventArgs>? ErrorOccurred;

The IpcHandler offers the features of IIpcSender and IIpcReceiver as well as the following RPC capabilities:

void RegisterService(Type type, object service);
void RegisterService<TIService>(TIService service) where TIService : notnull;
Task<TResult> ExecuteRemote<TIRemnoteService, TResult>(Expression<Func<TIRemnoteService, Task<TResult>>> func);
Task<TResult> ExecuteRemote<TIRemnoteService, TResult>(Expression<Func<TIRemnoteService, TResult>> func);
Task ExecuteRemote<TIRemnoteService>(Expression<Action<TIRemnoteService>> func);

Minimal example:

IpcFactory ipcFactory = new IpcFactory();

using IIpcHandler server = await ipcFactory.CreateNamedPipeIpcServer("MyNamedPipe");
server.MessageReceived += (sender, e) =>
{
	Console.WriteLine(e.Value);
};

using IIpcHandler client = await ipcFactory.CreateNamedPipeIpcClient("MyNamedPipe");
await client.SendStringAsync("Hello World!");

Console.ReadKey();

Additional usage examples can be found in the sample project "PlainlyIpcChatDemo" and the tests in the "PlainlyIpcTests" project.

For the easier use of the ExecuteRemote functionality of the IIpcHandler you can create proxy classes for RPC interfaces automatically.

With the RemoteProxyCreator:

RemoteProxyCreator.CreateProxyClass<TInterface>(string outputFolderPath, string baseNamespace);

Or via the "PlainlyIpc.SourceGenerator" package. This provides a [GenerateProxy] attribute that can be annotated to remote interfaces or partial classes that implement a remote interface. The source generator then generates the proxy implementations of the functions defined in the remote interface automatically.

[GenerateProxy] // Generates 'MyRemoteFunctionsInterfaceRemoteProxy' class in 'MyRemoteFunctionsInterfaceRemoteProxy.g.cs'
public interface IMyRemoteFunctionsInterface {
	Task MyFunction();
}
// Or
[GenerateProxy] // Generates partial 'MyRemoteFuctionClass' class in 'MyRemoteFuctionClass.g.cs'
public partial class MyRemoteFuctionClass : IMyRemoteFunctionsInterface {
}

Warning: The source generator is still a prototype and has only a very rudimentary implementation.

The basis for serialization and deserialization is the IObjectConverter interface. The default implementation is the System.Text.Json based implementation for this interface.

IObjectConverter objectConverter = new JsonObjectConverter();

The library is developed mainly for ".net8.0" and newer but also supports ".netstandard2.0" and is designed for completely asynchronous IPC and RPC communication. Only the ".netstandard2.0" version has dependencies to other NuGet packages (The packages "System.Memory" and "System.Text.Json" are required to add some functionalities which were introduced in later .NET versions.).

Warning: PlainlyIPC is still under development.

A version 1.0 will be released as soon as all planed features are implemented and properly tested. Therefore, there may be some breaking changes before the release of version 1.0.

NuGet: https://www.nuget.org/packages/Chriffizient.PlainlyIpc

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.9.0 92 5/24/2025
0.8.0 2,276 6/3/2023
0.7.3 4,385 3/10/2023
0.7.2 440 12/16/2022
0.7.1 614 11/10/2022
0.7.0 384 11/8/2022