3 ms·
There is a dangerous form https://docs.microsoft.com/en-us/dotnet/standard/serialization/binary-serialization https://docs.microsoft.com/en-us/dotnet/standard/s
by benaadams 8y ago
There is a dangerous form https://docs.microsoft.com/en-us/dotnet/standard/serialization/binary-serialization https://docs.microsoft.com/en-us/dotnet/standard/serializati...
> Binary serialization can be dangerous. Never deserialize data from an untrusted source and never round-trip serialized data to systems not under your control.
The killed it in .NET Core 1.x; but brought it back in .NET Core 2.x due to back compat and interop complaints
- _pmf_ 8y ago> The killed it in .NET Core 1.x; but brought it back in .NET Core 2.x due to back compat and interop complaints I've been using .NET binary serialization for dirt cheap local snapshots for the purpose of undo/redo. It's perfect for this.
- GordonS 8y agoThere are plenty of other options though, such as JSON, MessagePack, Protocol Buffers etc. And BinaryFormatter has always performed poorly against 3rd party libs, especially other binary formatters such MessagePack
- _pmf_ 8y agoDo any of these options support proper handling of cycles in the object graph out of the box?
- GordonS 8y agoYes. Using the Newtonsoft library you can configure it using `JsonSerializerSettings.ReferenceLoopHandling`, and with with protobuf-net you set `AsReference` on your class's `ProtoContractAttribute`. I don't think MessagePack-CSharp or msgpack-cli support cyclic references tho.