I'm getting a bit frustrated by the lack of consistency within the different forms of serialization in .NET:
DataContractSerializer - uses new attributes OR old [Serializable] attributes, but the serializer itself does not implement IFormatter where some of the other WCF serializers do. Opt IN.
NetDataContractSerializer - uses new attributes OR old, serializer implements IFormatter, is compatible with WCF, and is Opt IN. Seems like the ideal solution!
XmlSerializer - totally independant set of attributes, but is legacy so can forgive this.
BinaryFormatter - implements IFormatter and uses the [Serializable] attributes. Opt OUT.
So my question is, why does DataContractSerializer not stay at least fairly interchangable with BinaryFormatter?
I really wish they'd settled on a nice clean interface for this from the start, its a shame really in the expanse of the .NET framework which is usually so ordered!
Edit: Just for those who are interested (I know this isnt really relevant to the rest of the topic), I've been doing some both time and size benchmarking of what I perceive as the most likely "on-the-wire" serialization methods:
============ Serialization ============
Protobuf x158,194 39,549 per/sec 1.00
OldFieldbase x58,191 14,548 per/sec 2.72
Fieldbase x57,445 14,361 per/sec 2.75
DataContract x54,611 13,653 per/sec 2.90
Binary x29,466 7,367 per/sec 5.37
Net x28,170 7,043 per/sec 5.62
Json x10,605 2,651 per/sec 14.92
And sizes:
============ SerializationSizes ============
Protobuffers 209 bytes 1.00
Fieldbase 246 bytes 1.18
OldFieldbase 248 bytes 1.19
Json 728 bytes 3.48
DataContract 1227 bytes 5.87
Net 1658 bytes 7.93
Binary 1826 bytes 8.74
NOTE: On a Core2 T9300 (single threaded) + 4GB.