MB.TinyRpc.Roslyn 1.12.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MB.TinyRpc.Roslyn --version 1.12.0                
NuGet\Install-Package MB.TinyRpc.Roslyn -Version 1.12.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="MB.TinyRpc.Roslyn" Version="1.12.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MB.TinyRpc.Roslyn --version 1.12.0                
#r "nuget: MB.TinyRpc.Roslyn, 1.12.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.
// Install MB.TinyRpc.Roslyn as a Cake Addin
#addin nuget:?package=MB.TinyRpc.Roslyn&version=1.12.0

// Install MB.TinyRpc.Roslyn as a Cake Tool
#tool nuget:?package=MB.TinyRpc.Roslyn&version=1.12.0                

MB.TinyRpc

TinyRpc is a small, fast 1:1 RPC client-server framework that uses source generation to communicate using binary data over pipes.

It sends as little data as necessary, without run-time checks. If the common interface doesn't have events, for example, the machinery to support them isn't generated. Similarly, void returns or parameters don't send anything over the pipe.

It also automatically starts the server when the client is instantiated and it automatically closes the server when the client shuts down (even if it doesn't shut down gracefully). There is no possibility of getting out-of-sync orphaned servers.

Support

Type .NET Windows C++
Server
Client

Common interface definition

The source of any operation is a .Net interface that can contain methods or events. This interface doesn't have to be a single common type as long as the definition matches. For example, in the sample provided it's used in a shared project (thus creating two different types):

internal interface IServer
{
    void Hi();
    void FancyHi(string name, int age);
    int Add(int x, int y);
    byte[] BufferCall(byte[] baseUtf8String, int n);
    (int a, int b, short c, byte[] utf8) GetValueTupleResult(string s);
    (uint a, long b, DateTime dt, double d)[] GetValueTupleArrayResult();

    event Action<double, string> OnData;
}

.NET Server

The pattern for creating a .NET server is as follows:

  1. Reference MB.TinyRpc.
  2. Instantiate the interface to a concrete class that handles the functions as needed.
  3. Create a new partial class and decorate it with [TinyRpcServerClass(typeof(ServerHandler))], where ServerHandler is your concrete class name.
  4. Instantiate the server class above in code. This will create the listener on your thread pool and keep the IsHealthy property up to date.

You can find an example of this here.

.NET Client

The pattern for creating a .NET client is as follows:

  1. Reference MB.TinyRpc.
  2. Create a partial class and decorate it with [TinyRpcClientClass(typeof(IServer))], where IServer is the common interface above.
  3. Instantiate the class and call the provided async functions on it, or fire its events.

You can find an example of this here.

C++ Client

  1. Reference MB.TinyRpc.CppGen.
  2. Add a pre-build event that calls the code generator on the .Net client project to extract information about the interface type and build the C++ header file:
"$(ProjectDir)TinyRpcCppGen\tinyRpc.CppGen.exe" --input-project-path "$(SolutionDir)SampleClient\SampleClient.csproj" --input-class-names "SampleShared.IServer" --output-path "$(ProjectDir)TinyRpcServer.h" --output-class-names "TinyRpcServer"
  1. Include the generated header file and call its functions or fire its events.

You can find an example of this here.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MB.TinyRpc.Roslyn:

Package Downloads
MB.TinyRpc

A small, fast 1:1 RPC client-server framework that uses source generation to communicate using binary data over pipes.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.13.0 111 9/30/2024
1.12.0 105 9/30/2024
1.11.0 107 9/29/2024
1.10.0 779 3/15/2024
1.9.0 1,726 11/5/2023
1.8.0 1,693 11/2/2023
1.7.0 1,752 10/31/2023
1.6.0 1,843 10/31/2023
1.5.0 1,689 10/28/2023
1.3.0 2,019 10/4/2023
1.2.0 1,818 10/3/2023
1.1.0 1,857 10/3/2023
1.0.0 1,728 10/2/2023