FAkka.ProtoBuf.FSharp 10.2.2

dotnet add package FAkka.ProtoBuf.FSharp --version 10.2.2
                    
NuGet\Install-Package FAkka.ProtoBuf.FSharp -Version 10.2.2
                    
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="FAkka.ProtoBuf.FSharp" Version="10.2.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FAkka.ProtoBuf.FSharp" Version="10.2.2" />
                    
Directory.Packages.props
<PackageReference Include="FAkka.ProtoBuf.FSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FAkka.ProtoBuf.FSharp --version 10.2.2
                    
#r "nuget: FAkka.ProtoBuf.FSharp, 10.2.2"
                    
#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.
#:package FAkka.ProtoBuf.FSharp@10.2.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FAkka.ProtoBuf.FSharp&version=10.2.2
                    
Install as a Cake Addin
#tool nuget:?package=FAkka.ProtoBuf.FSharp&version=10.2.2
                    
Install as a Cake Tool

Protobuf-Net FSharp Wrapper

This library is intended to provide a set of helper functions to allow F# types to be seriaised/deserialised using the protobuf-net library making it easier to use from a F# environment.

NuGet Badge CI Badge

Aims

  • Support common F# types (Options, Records, DU)
  • Leverage improvements/work done in protobuf-net library whilst adding F# specifc improvements on top (e.g. proto generation, gRpc, etc.)
  • Make it friendly to use from an F# environment (e.g. no implicit nulls during deserialisation where F# compiler doesn't expect them).

Supported/Non supported features

  • Records
  • Discriminated Unions
  • Option fields on the above types
  • Empty arrays and strings are populated across the whole object graph during deserialisation to avoid unexpected null's in an F# context.

Currently the non-supported features are mainly around the F# collections (Set, List, etc.). For the moment it is recommended to use arrays in your contract types to be serialised/deserialised. More work is required to support these.

How to build/test

Using Net Core 3.1 or above:

dotnet tool restore
dotnet build

To run tests:

dotnet test

How to use

All methods are in the ProtoBuf.FSharp.Serialiser module. They all require a previous RuntimeTypeModel to be created and/or retrieved in advance. Detailed examples are found in the unit test projects.

A quick example of how to get the runtime model, and register both an existing record and DU type against it is as follows:

open ProtoBuf.FSharp

let model = 
    RuntimeTypeModel.Create("Model") // OR RuntimeTypeModel.Default
    |> Serialiser.registerRecordIntoModel<RecordType> 
    |> Serialiser.registerUnionIntoModel<UnionType>

An example below of how to use the model to serialise and deserialise an object assuming the code above has been run:

let typeToTest = { RecordType.TestData = "TEST" }
use ms = new MemoryStream()
Serialiser.serialise model ms typeToTest
ms.Seek(0L, SeekOrigin.Begin) |> ignore
let rtData = Serialiser.deserialise<'t> model ms

Details

Option Serialisation

By default any usages of F# options in your registered records and/or unions are also registered into the Protobuf model.

An example for the Option<string> type the message as described in a proto file would be:

message OptionalString {
   bool HasValue = 1;
   string Item = 2;
}

The default behaviour for the name of the protobuf message type (in this case OptionalString) are:

  • All option types are prefixed with "Optional".
  • The suffix for the name is the parameter type's "Name" property.

You can customise the suffix by registering the option type yourself but note this needs to be done before registering any types that use this type else the default behaviour of this library takes precedence.

Note: As per the Protobuf spec default values can't be distinguished from missing values. The HasValue property distinguishes "None" cases from a (Some defaultValue) case.

Default Value Serialisation

Because default values are not serialised by Protobuf (empty strings, lists, etc) protobuf-net at time of writing when deserialising these objects often does not populate these fields leaving them with CLR null values. This breaks the F# assumption that fields on records and unions unless specified are not nullable and inhibits roundtrip serialisation. In other words serialising then deserialising an F# type does not preserve these values. This creates problems in an F# context especially with records and unions where constructors can't be overriden easily to prepopulate these types and the environment doesn't expect nulls to be definable on these types in normal use.

This library adds a dynamic factory for registered types that populates the default values upon deserialsation for types.

As an example the record

type ExampleRecord = { TestOne: string; TestTwo: int array }
let objectToSerialise = { TestOne = String.Empty; TestTwo = Array.empty }

will now deserialise as

{ TestOne = String.Empty; TestTwo = Array.empty }

vs the default protobuf-net behaviour at time of writing

{ TestOne = null; TestTwo = null }

Issues

Any issues using this feel free to raise an issue on this repository.

Product 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 is compatible.  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 is compatible.  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 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on FAkka.ProtoBuf.FSharp:

Package Downloads
PersistedConcurrentSortedList

SortedList with persistency and threadsafty.

FAkka.FCell2

Standalone fCell2 key/value cell model with protobuf helpers and presentation shapes.

FAkka.Fsi.Contracts

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.2.2 0 10/22/2026
10.2.1 60 10/21/2026
10.2.0 85 10/20/2026
10.1.400 7,880 9/4/2026
10.1.302 1,375 7/21/2026
10.1.301.3 219 7/3/2026
10.1.301.2 164 7/3/2026
10.1.301 4,136 6/19/2026
10.1.300 371 6/7/2026
10.1.201 246 4/7/2026
10.0.103.2-dgx 718 3/10/2026
10.0.102 153 1/20/2026
10.0.101.2 738 12/22/2025
10.0.101.1 233 12/22/2025
10.0.101 219 12/22/2025
9.0.14.300 661 7/20/2025
9.0.14 461 4/6/2025
9.0.13 233 4/6/2025
9.0.12 223 4/6/2025
9.0.11 453 11/9/2024
Loading failed