This question does a good job of explaining the difference in functionality between the serializers. BinaryFormatter is fast, XmlSerializer is interoperable, etc. I know that.
But what is the difference in intent? What use-case was each class designed for?
In particular:
- Why did they decide to make
XmlSerializerblind for private data, whenBinaryFormattersees it fast enough (via the supposedly-slow reflection) - Why did they make 3 separate XML serializers -
XmlSerializer,SoapFormatterandDataContractSerializer? - Why are some opt-in and some opt-out?
- Why did they make the interfaces so inconsistent? E.g. XmlSerializer doesn't provide an
OnDeserializedCallbackequivalent. Another example - XmlSerializer usesIsNullable[XmlIgnore]for what BinarySerializer uses[OptionalField]and[NonSerialized].