Total Downloads
349
349
Published
Oct 23, 2026
26d ago
Get Started
dotnet add package Nerdbank.JsonRpc --version 0.2.48-alpha
| Product | Versions |
|---|---|
| .NET | |
| .NET Standard | |
| Other |
README
Nerdbank.JsonRpc
Nerdbank.JsonRpc is a NativeAOT-safe .NET library for building strongly typed JSON-RPC clients and servers over MessagePack or UTF-8 JSON.
Features
- Strongly typed RPC: Register local targets and issue typed requests or notifications.
- Generated client proxies: A built-in source generator creates interface-backed proxies with positional or named arguments.
- MessagePack or JSON: MessagePack (default, length-header or self-delimiting framing) or UTF-8 JSON (newline-delimited or
Content-Lengthframing). - Peer-to-peer: One connection can both expose local methods and invoke remote ones.
- Batching: Send independent requests and notifications in one JSON-RPC payload.
- Cancellation and robust error handling: Propagates cancellation and distinguishes malformed protocol messages from application failures.
- Ordered dispatch: Inbound requests start in the order sent, while running concurrently.
- Deadlock mitigation: Propagates
JoinableTaskFactorycontext across processes, compatible with StreamJsonRpc. - Exotic types: Marshal interfaces, observers, progress, streams, and async sequences by reference.
Quick start
Define a contract shared by both parties:
using Nerdbank.JsonRpc;
using PolyType;
[GenerateJsonRpcProxy]
[GenerateShape(IncludeMethods = MethodShapeFlags.PublicInstance)]
public partial interface ICalculator
{
ValueTask<int> AddAsync(int a, int b, CancellationToken cancellationToken);
}
public class Calculator : ICalculator
{
public ValueTask<int> AddAsync(int a, int b, CancellationToken cancellationToken) => new(a + b);
}
Connect over any bidirectional stream, expose a local target, and call the remote party through a proxy:
using Nerdbank.Streams;
using JsonRpc rpc = new(new JsonRpcMessagePackChannel(stream.UsePipe()));
// Expose a local target the remote party can call.
rpc.AddRpcTarget<ICalculator>(new Calculator());
rpc.Start();
// Invoke a method on the remote party.
ICalculator remote = rpc.Attach<ICalculator>();
int sum = await remote.AddAsync(1, 2, CancellationToken.None);
Learn more
Downloads by Version
Depended On By
Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.
Adoption Assessment
A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.
This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 4 target frameworks; confirm the exact target used by your application.The published metadata declares 22 direct dependency entries across framework groups. Inspect the resolved dependency graph for your target framework.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.