NexusRpc 0.2.0
dotnet add package NexusRpc --version 0.2.0
NuGet\Install-Package NexusRpc -Version 0.2.0
<PackageReference Include="NexusRpc" Version="0.2.0" />
<PackageVersion Include="NexusRpc" Version="0.2.0" />
<PackageReference Include="NexusRpc" />
paket add NexusRpc --version 0.2.0
#r "nuget: NexusRpc, 0.2.0"
#:package NexusRpc@0.2.0
#addin nuget:?package=NexusRpc&version=0.2.0
#tool nuget:?package=NexusRpc&version=0.2.0
Nexus .NET SDK
⚠️ This SDK is currently at an experimental release stage. Backwards-incompatible changes are anticipated until a stable release is announced. ⚠️
.NET SDK for working with Nexus RPC.
What is Nexus?
Nexus is a synchronous RPC protocol. Arbitrary length operations are modelled on top of a set of pre-defined synchronous RPCs.
A Nexus caller calls a handler. The handler may respond inline or return a reference for a future, asynchronous operation. The caller can cancel an asynchronous operation, check for its outcome, or fetch its current state. The caller can also specify a callback URL, which the handler uses to asynchronously deliver the result of an operation when it is ready.
Installation
Add the NexusRpc
package from NuGet. For example, using the dotnet CLI:
dotnet add package NexusRpc
The .NET SDK supports .NET Framework >= 4.6.2, .NET Core >= 3.1 (so includes .NET 5+), and .NET Standard >= 2.0.
Usage
The SDK currently supports defining Nexus services and implementing handlers for them.
Defining Services and Operations
Define a Nexus service with an interface containing a [NexusService]
attribute. Each operation is an interface method
accepting 0 or 1 parameters that has the [NexusOperation]
attribute. For example:
using NexusRpc;
[NexusService]
public interface IGreetingService
{
[NexusOperation]
string SayHello1(string name);
[NexusOperation]
string SayHello2(string name);
}
This can be used by both Nexus callers and Nexus handler implementers. Although not yet implemented in this SDK, clients can leverage this service for type-safe Nexus invocations. Handlers can be implemented that conform to this service as seen in the next section.
Implementing Services and Operations
Nexus service handlers are classes that have the NexusServiceHandler
attribute and reference the service interface.
Nexus operation handlers are returned via parameterless methods that are effectively "operation handler factories" and
are named the same as the operation. Some shortcuts exist for making operations. For example:
using NexusRpc.Handlers;
namespace NexusRpc.Tests.Example;
[NexusServiceHandler(typeof(IGreetingService))]
public class GreetingService(IApiClient ApiClient)
{
// Can be static
[NexusOperationHandler]
public static IOperationHandler<string, string> SayHello1() =>
// Simple, synchronous operations can use a helper for a lambda
OperationHandler.Sync<string, string>((ctx, name) => $"Hello, {name}!");
[NexusOperationHandler]
public IOperationHandler<string, string> SayHello2() =>
// Advanced, potentially asynchronous operations can
new SayHello2Handler(ApiClient);
public class SayHello2Handler(IApiClient ApiClient) : IOperationHandler<string, string>
{
public Task<OperationStartResult<string>> StartAsync(
OperationStartContext context, string name) =>
throw new NotImplementedException("Excluded for brevity");
public Task<string> FetchResultAsync(OperationFetchResultContext context) =>
throw new NotImplementedException("Excluded for brevity");
public Task<OperationInfo> FetchInfoAsync(OperationFetchInfoContext context) =>
throw new NotImplementedException("Excluded for brevity");
public Task CancelAsync(OperationCancelContext context) =>
throw new NotImplementedException("Excluded for brevity");
}
}
Development
Build
Prerequisites:
- .NET
- This repository cloned
With all prerequisites in place, run:
dotnet build
Or for release:
dotnet build --configuration Release
Code formatting
This project uses StyleCop analyzers with some overrides in .editorconfig
. To format, run:
dotnet format
Can also run with --verify-no-changes
to ensure it is formatted.
Testing
Run:
dotnet test
Can add options like:
--logger "console;verbosity=detailed"
to show logs--filter "FullyQualifiedName=NexusRpc.Tests.ServiceDefinitionTests.FromType_NonInterface_Bad"
to run a specific test
To help show full stdout/stderr, this is also available as an in-proc test program. Run:
dotnet run --project tests/NexusRpc.Tests
Extra args can be added after --
, e.g. -- -verbose
would show verbose logs and -- --help
would show other
options. If the arguments are anything but --help
, the current assembly is prepended to the args before sending to the
xUnit runner.
Product | Versions 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 was computed. 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 was computed. 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 is compatible. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 is compatible. 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. |
-
.NETCoreApp 3.1
- No dependencies.
-
.NETFramework 4.6.2
- Microsoft.Bcl.HashCode (>= 6.0.0)
- System.ValueTuple (>= 4.6.1)
-
.NETStandard 2.0
- Microsoft.Bcl.HashCode (>= 6.0.0)
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
0.2.0 | 3 | 9/22/2025 |