A Cap'n Proto implementation for .NET Standard 2.0 (credits to lostinplace) and .NET Core.
"Cap'n Proto is an insanely fast data interchange format and capability-based RPC system." Whilst the original implementation is written in C++ there are several ports to other languages. This is a C# implementation for .NET Core.
Disclaimer: Neither this project nor its author are affiliated with Cap'n Proto. This is just yet another independent implementation of the specification. The following sections assume that you are familiar with Cap'n Proto and probably its GitHub project.
The overall deployment consists of two components:
.cs
serialization classes from .capnp
schema files. It is designed to be used in conjunction with the Cap'n Proto tool set which is maintained at the original site. The tool set is required at compile time.Capnp.Net.Runtime
assembly is to be included as a reference into your particular application (or assembly).This is probably the most convenient option for Visual Studio development: The MSBuild integration package recognizes .capnp
files in your VS project and generates their code-behind during build.
A prerequisite is that the Cap'n Proto tool suite is installed (capnp.exe
must be on your PATH
). The simplest way to achieve this:
choco install capnproto
Then, for the VS project which hosts your .capnp
schema definitions:
Install-Package CapnpC.CSharp.MsBuild.Generation
The C# code generator back end is available as dotnet tool. It requires a .NET Core 3.1 (or higher) runtime or SDK (type dotnet
at command line prompt to check whether you already have one). This is the recommended variant. To install it globally, type
dotnet tool install capnpc-csharp --global
There is also a self-contained Chocolatey deployment for Windows (x86). To install, type
choco install capnpc-csharp-win-x86
This variant will also download and install the Cap'n Proto tool set Chocolatey package. Note that the author does not maintain this package and has no influence on its contents.
The Capnp.Net.Runtime
assembly is available as Nuget package. E.g. within VS package manage console, type
Install-Package Capnp.Net.Runtime
For building from scratch you will need Visual Studio ≥ 2019 (e.g. Community Edition) with suitable workloads for C# / .NET Core (currently .NET Core 2.1) development. For the test suite, you will also need the C++ native workload, vcpkg and Cap'n Proto release 0.7.0:
vcpkg install capnproto
Solution/project structure is as follows:
Capnp.Net.sln
contains these projects:
Capnp.Net.Runtime
is the runtime implementation, a multi-target assembly.CapnpC.CSharp.Generator
contains the generator backend logic for C# language. It is also a multi-target (.NET Standard 2.0 + .NET Core 2.1) assembly.capnpc-csharp
is the command line-based generator backend (a .NET Core 2.1 application).CapnpC.CSharp.MsBuild.Generation
provides the MSBuild integration for the generator backend.Capnp.Net.Runtime.Tests
is an MS test assembly, containing - you guessed it - the test suite.CapnpC.CSharp.Generator.Tests
contains the generator backend test suite.CapnpC.CSharp.MsBuild.Generation.Tests
contains tests for CapnpC.CSharp.MsBuild.Generation
.CapnpCompatTest.sln
compiles to a native x86 executable which depends on the original Cap'n Proto C++ implementation. It is (partially) required by the test suite for interoperability testing.MsBuildGenerationTest\MsBuildGenerationTest.sln
is a test solution/project for MSBuild integration.The following Cap'n Proto features are currently implemented:
These features are not yet implemented: