FsPickler


FsPickler : A fast, multi-format messaging serializer for .NET

FsPickler is a serialization library that facilitates the distribution of objects across .NET processes. The implementation focuses on performance and supporting as many types as possible, where possible. It supports multiple, pluggable serialization formats such as XML, JSON and BSON; also included is a fast binary format of its own. The library is based on the functional programming concept of pickler combinators which has been adapted to accommodate the .NET type system.

The FsPickler library can be installed from NuGet:
PM> Install-Package FsPickler
PM> Install-Package FsPickler.Json
PM> Install-Package FsPickler.CSharp

Example

This example demonstrates a basic serialization roundtrip using the library

1: 
2: 
3: 
4: 
5: 
6: 
7: 
#r "FsPickler.dll"
open MBrace.FsPickler

let binarySerializer = FsPickler.CreateBinarySerializer()

let pickle = binarySerializer.Pickle [Some 1; None ; Some -1]
binarySerializer.UnPickle<int option list> pickle

Why FsPickler?

The principal motivation behind creating FsPickler is the need for a library that provides efficient, correct and complete serialization of objects in the CLR and mono runtime. It is aimed at providing a foundation for efficient communication across homogeneous .NET clusters.

FsPickler is ideally suited for serializing:

  • Large and complex object graphs, such as dictionaries, trees and cyclic graphs.
  • Abstract classes, subtypes, delegates and closures.
  • ISerializable, DataContract or attribute-based serialization.
  • F# unions, records and quotations.
  • Inaccessible types or types unknown at compile time.

FsPickler is NOT:

  • a general-purpose XML/JSON/BSON framework.
  • a library designed for cross-platform communication.
  • a library designed with version tolerance in mind. Avoid using for long-term persistence.

Documentation & Technical Overview

A collection of tutorials, technical overviews and API references of the library.

  • Tutorial A short introduction to FsPickler.

  • Technical Overview A walkthrough of the library's implementation details.

  • Performance Benchmarks comparing FsPickler to other established serialization libraries.

  • API Reference contains automatically generated documentation for all types, modules and functions in the library.

Who uses FsPickler?

  • MBrace framework - MBrace is a framework for distributed computation in the cloud. Its programming model uses continuations, so a library that supports serialization of closures was essential. FsPickler was designed out of this requirement.

  • Akka.NET - Used in the Akka.FSharp library for its quotation serialization capabilities.

  • Suave.IO - "we needed a simple way of serialising CLR types to put in cookies. After fighting .Net's JSONDataContractSerializer for a good while we tried FsPickler. It was a straight success; it just worked".

  • Tachyus - "FsPickler serializes and deserializes objects of virtually any type quickly and reliably in a single line of F# code. For us this makes communications between applications across computing environments effortless. There are no implementation details to obsess about".

Contributing and copyright

The project is hosted on GitHub where you can report issues, fork the project and submit pull requests.

The library is available under the MIT License. For more information see the License file in the GitHub repository.

namespace MBrace
namespace MBrace.FsPickler
val binarySerializer : BinarySerializer

Full name: Index.binarySerializer
type FsPickler =
  private new : unit -> FsPickler
  static member Clone : value:'T * ?pickler:Pickler<'T> * ?streamingContext:StreamingContext -> 'T
  static member ComputeHash : value:'T * ?hashFactory:IHashStreamFactory -> HashResult
  static member ComputeSize : value:'T * ?pickler:Pickler<'T> -> int64
  static member CreateBinarySerializer : ?forceLittleEndian:bool * ?typeConverter:ITypeNameConverter -> BinarySerializer
  static member CreateObjectSizeCounter : ?encoding:Encoding * ?resetInterval:int64 -> ObjectSizeCounter
  static member CreateXmlSerializer : ?typeConverter:ITypeNameConverter * ?indent:bool -> XmlSerializer
  static member DeclareSerializable : unit -> unit
  static member DeclareSerializable : predicate:(Type -> bool) -> unit
  static member DeclareSerializable : t:Type -> unit
  ...

Full name: MBrace.FsPickler.FsPickler
static member FsPickler.CreateBinarySerializer : ?forceLittleEndian:bool * ?typeConverter:ITypeNameConverter -> BinarySerializer
val pickle : byte []

Full name: Index.pickle
member FsPicklerSerializer.Pickle : value:'T * ?pickler:Pickler<'T> * ?streamingContext:System.Runtime.Serialization.StreamingContext * ?encoding:System.Text.Encoding -> byte []
union case Option.Some: Value: 'T -> Option<'T>
union case Option.None: Option<'T>
member FsPicklerSerializer.UnPickle : data:byte [] * ?pickler:Pickler<'T> * ?streamingContext:System.Runtime.Serialization.StreamingContext * ?encoding:System.Text.Encoding -> 'T
Multiple items
val int : value:'T -> int (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.int

--------------------
type int = int32

Full name: Microsoft.FSharp.Core.int

--------------------
type int<'Measure> = int

Full name: Microsoft.FSharp.Core.int<_>
type 'T option = Option<'T>

Full name: Microsoft.FSharp.Core.option<_>
type 'T list = List<'T>

Full name: Microsoft.FSharp.Collections.list<_>
Fork me on GitHub