mbraceproject / FsPickler

A fast multi-format message serializer for .NET
http://mbraceproject.github.io/FsPickler/
MIT License
324 stars 52 forks source link

add 'omitHeader' arg to bson pickler #72

Closed vilinski closed 7 years ago

vilinski commented 8 years ago

PR for the https://github.com/nessos/FsPickler/issues/71

Unsure where to start to fix them

type Record = { Name : string ; Age : int }
type Union = A of int | B of string * int | C
let testRecord = { Name = "me" ; Age = 12 }
let testList = [A 42 ; B("test", 0) ; C]
let testExp = <@ 1 + 1 @>

let bsp = FsPickler.CreateBsonSerializer(omitHeader = true)
let bson1 = bsp.Pickle testRecord
bsp.UnPickle bson1 = testRecord
let bson2 = bsp.Pickle testList
bsp.UnPickle bson2 = testList
let bson3 = bsp.Pickle testExp
bsp.UnPickle bson3 = testExp
eiriktsarpalis commented 8 years ago

It's been a while, so I don't remember why I chose not to implement headerless serialization for BSON. However I'm pretty certain that there must have been a reason. Possibly because the format does not permit it.

dsyme commented 7 years ago

This PR has drifted a long way, closing it