Dotnet Core 2.1 Project that uses Google's Probuf message interchange format. Contains three main directories: Cli
, Models
, and WebApi
.
All of the proto
files will be located in the Models
directory, and the resulting C# classes will be ignored via git. The WebApi has implementations on implementing the Input and Output for any requests with Content-Type: application/x-protobuf
. The CLI is a simple project to take a binary, and perform a POST on the WebApi.
The following are dependencies to run:
- DotnetCore 2.1 SDK
- Nuget or some Internal Mirror of it
- First Clone the repository:
git clone git@github.com:wagnerjt/dotnet-protobuf.git
- Generate the Protocol Buffer Messages:
protoc --csharp_out=./Models/ ./Models/*.proto
Note: - I used Protoc 3.8 -protoc --version
- Build the
CLI
orWebApi
projectdotnet build {Project}/*.csproj
- Run the Project
- Check out the
Helpful Resources
section below. Some things I wanted to test pretty quickly.
Generating the Messages: protoc --csharp_out=./Models/ ./Models/*.proto
Generating a Json file: curl -H "Content-Type: application/json" https://localhost:5001/api/values/proto -k > x.json
Getting the Proto binary: curl -H "Content-Type: application/x-protobuf" https://localhost:5001/api/values/proto -k > x.bin
Posting the Proto binary back: curl -d "@x.bin" -H "Content-Type: application/x-protobuf" https://localhost:5001/api/values/person -k
Posting the Json file back: curl -d "@x.json" -H "Content-Type: application/json" https://localhost:5001/api/values/person -k
Add an issue, or even create a MR. Knock out some of those TODOS down below, or something even more :).
- - Documentation
- - Create Generic Type for deserialization from web response in CLI
- - Add Error Handling
- - Add VsCode Build Steps across the board
- - Use the Protoc's Nuget package to generate the proto files
- - Add Tests
- - Create More Complex Protos
- - Ensure ICollections of IMessages can be serialized on the Output of WebApi
- - Add Error Handling on the CLI Request