FsGrpc 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package FsGrpc --version 1.0.1
NuGet\Install-Package FsGrpc -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FsGrpc" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FsGrpc --version 1.0.1
#r "nuget: FsGrpc, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FsGrpc as a Cake Addin
#addin nuget:?package=FsGrpc&version=1.0.1

// Install FsGrpc as a Cake Tool
#tool nuget:?package=FsGrpc&version=1.0.1

FsGrpc

Idiomatic F# code generation for Protocol Buffers and gRPC

⚠️ this is currently a work in progress. See the "Status" section for more info

Generate idiomatic F# records from proto3 message definitions, complete with oneofs as discriminated unions, and serialize/deserialize to and from protocol buffer wire format.

Getting Started

If using buf.build, simply add the following "remote" line to your buf.gen.yaml:

version: v1
plugins:
  - remote: buf.build/divisions-maintenance-group/plugins/fsharp
    out: gen

Using buf generate with the above example will generate .fs files in the "gen" directory, and also a Protobuf.targets file in that directory which includes those files in correct dependency order.

You then add the following line to your .fsproj:

<Import Project="gen/Protobuf.targets" />

And run

dotnet add package fsgrpc --prerelease

or

Install-Package FsGrpc -Version -IncludePrerelease

Usage in F#

You can create a record by specifying all of the fields or using with syntax as follows:

let message =
	{ MyMessage.empty with
	    Name = "a name value"
	    Description = "some string here" }

Serializing a message to bytes looks like this:

let bytes = message |> FsGrpc.Protobuf.encode

And deserializing looks like this:

let message: MyMessage = bytes |> FsGrpc.Protobuf.decode

You can also serialize/deserialize from a CodedOutputStream/CodedInputStream using:

// decode from a CodedInputStream named cis
let message = MyMessage.Proto.Decode cis

// encode to a CodedOutputStream named cos
MyMessage.Proto.Encode cos message

Status

Note: This is currently a work in progress. Code generation for protocol buffers is currently working but considered an alpha version. gRPC and other features (such as code comments and reflection) are not complete.

The major features intended are:

  • Protobuf Messages as immutable F# record types
  • Oneofs as Discriminated Unions
  • proto3 optional keyword support
  • Support for optional wrapper types (e.g. google.protobuf.UInt32Val)
  • Support for well-known types Duration and Timestamp (represented using NodaTime types)
  • Automatic dependency-sorted inclusion of generated .fs files
  • Buf.build integration
  • Comment pass-through
  • Protocol Buffer reflection
  • Idiomatic functional implementation for gRPC endpoints
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on FsGrpc:

Package Downloads
FsGrpc.Tools

gRPC and Protocol Buffer compiler for F# projects

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.6 191 4/2/2024
1.0.5 5,755 5/12/2023
1.0.3 246 4/20/2023
1.0.2 951 3/9/2023
1.0.1 959 1/16/2023
1.0.0 740 11/18/2022
0.9.9 335 11/9/2022
0.9.8 410 10/7/2022
0.9.7 1,489 9/13/2022
0.9.6 390 9/1/2022
0.9.5 400 8/23/2022
0.9.4 385 8/22/2022
0.9.3 410 7/12/2022
0.9.2 430 7/8/2022
0.9.1-beta 144 7/7/2022
0.9.0-alpha-2 179 3/21/2022
0.9.0-alpha-1 163 3/19/2022