92 lines
5.5 KiB
Markdown
Raw Permalink Normal View History

2020-04-25 14:22:54 +02:00
# capnproto-dotnetcore [![Build status](https://ci.appveyor.com/api/projects/status/tx4jjl2etiqve2xg/branch/master?svg=true)](https://ci.appveyor.com/project/c80k/capnproto-dotnetcore/branch/master) [![Coverage Status](https://coveralls.io/repos/github/c80k/capnproto-dotnetcore/badge.svg)](https://coveralls.io/github/c80k/capnproto-dotnetcore)
2019-09-03 21:29:49 +02:00
2020-04-27 20:54:30 +02:00
A Cap'n Proto implementation for .NET Standard 2.0 (credits to [lostinplace](https://github.com/lostinplace)) and .NET Core.
2019-06-14 20:12:23 +02:00
["Cap'n Proto is an insanely fast data interchange format and capability-based RPC system."](https://capnproto.org/) 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](https://capnproto.org/) and probably its [GitHub project](https://github.com/capnproto/capnproto).
2019-07-14 17:15:28 +02:00
## Getting started: Users
2019-07-14 17:16:35 +02:00
The overall deployment consists of two components:
2019-07-14 17:15:28 +02:00
- The C# code generator back end is required for generating `.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.
- The `Capnp.Net.Runtime` assembly is to be included as a reference into your particular application (or assembly).
2019-10-09 21:52:30 +02:00
### Code generator back end: Visual Studio / MSBuild integration
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
```
2020-04-27 20:52:58 +02:00
### Code generator back end: dotnet tool
2019-07-14 17:15:28 +02:00
2020-04-27 20:52:58 +02:00
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
2019-07-14 17:15:28 +02:00
```
2020-04-27 20:52:58 +02:00
dotnet tool install capnpc-csharp --global
2019-07-14 17:15:28 +02:00
```
2020-04-27 20:52:58 +02:00
### Code generator back end: Windows command line
There is also a self-contained [Chocolatey](https://chocolatey.org/) deployment for Windows (x86). To install, type
2019-07-14 17:15:28 +02:00
```
choco install capnpc-csharp-win-x86
```
2020-04-27 20:52:58 +02:00
This variant will also download and install the [Cap'n Proto tool set Chocolatey package](https://www.chocolatey.org/packages/capnproto). Note that the author does not maintain this package and has no influence on its contents.
2019-07-14 17:15:28 +02:00
### Runtime assembly
The `Capnp.Net.Runtime` assembly is available as [Nuget package](https://www.nuget.org/packages?q=Capnp.Net.Runtime). E.g. within VS package manage console, type
```
Install-Package Capnp.Net.Runtime
```
## Getting started: Developers
2019-06-14 20:12:23 +02:00
2019-10-09 21:54:31 +02:00
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](https://github.com/microsoft/vcpkg) and Cap'n Proto release 0.7.0:
2019-07-14 17:15:28 +02:00
2019-06-14 20:12:23 +02:00
```
vcpkg install capnproto
```
Solution/project structure is as follows:
2019-10-04 23:41:26 +02:00
- `Capnp.Net.sln` contains these projects:
2020-04-28 21:34:01 +02:00
* `Capnp.Net.Runtime` is the runtime implementation, a multi-target assembly.
2019-10-04 23:41:26 +02:00
* `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.
2020-04-28 21:31:43 +02:00
* `Capnp.Net.Runtime.Tests` is an MS test assembly, containing - you guessed it - the test suite.
2019-10-04 23:41:26 +02:00
* `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.
2019-06-14 20:37:10 +02:00
## Features
The following Cap'n Proto features are currently implemented:
2019-10-09 21:52:49 +02:00
- Serialization/deserialization of all kinds of data (structs, groups, unions, lists, capabilities, data, text, enums, even primitives)
2019-06-14 20:37:10 +02:00
- Generics
- Level 1 RPC, including promise pipelining, embargos, and automatic tail calls
- Security (pointer validation, protection against amplification and stack overflow DoS attacks)
- Compiler backend generates reader/writer classes, interfaces, proxies, skeletons (as you know it from the C++ implementation), and additionally so-called "domain classes" for all struct types. A domain class is like a "plain old C# class" for representing a schema-defined struct, but it is decoupled from any underlying message. It provides serialize/deserialize methods for assembling/disassembling the actual message. This provides more convenience, but comes at the price of non-zero serialization overhead (not "infinitely" faster anymore).
These features are not yet implemented:
2019-10-09 21:55:07 +02:00
- Level N RPC with N ≥ 2
2019-06-14 20:37:10 +02:00
- Packing
- Compression
- Canonicalization
- Dynamic Reflection
- mmap