Simple data file versioning with DataContractSerializer

后端 未结 2 1905
不知归路
不知归路 2021-01-05 08:37

Having read Data Contract Versioning we concluded that it\'s not really the whole story. For example, what happens if you used to have ValueA, and in the new version it\'s n

2条回答
  •  情深已故
    2021-01-05 09:04

    1 year later I have to say that DataContractSerializer has really sucked for versioning. It's far too rigid. It's really meant for contracts that aren't very likely to change, and then only in specific ways. You have to do extra work to use it just to make it fast - like the KnownTypeAttribute for example. I would only recommend it if you require relatively fast serialization - which, arguably, is rather important for what it was designed for.

    Another project I work on uses a more flexible serializer which, for example, doesn't skip calling the class constructor (something has has caused much inconvenience), and doesn't require items to be in a specific order. It deals gracefully with new fields (they are left at whatever the constructor set them to) and removed fields with zero programmer intervention.

    Now if only I could post it here... It is however about 5x-10x slower than the DataContractSerializer.

提交回复
热议问题