I would like to add a DataMember
to one of my DataContract
s. I would like to know how existing servers and clients will behave in the presence of a new DataMember
if one of the parties isn't updated.
I recall there is a way to make the DataMember
optional, but I wonder if it would work in all scenarios:
WCF will gracefully handle new members that it doesn't recognize. The consumer of the contract (on either the client or the server side) simply won't "see" that member, therefore a consequence is that the new member should never be an IsRequired=true
property.
Furthermore, WCF will transparently bridge the new property between components as long as the DataContract implements IExtensibleDataObject
. EG, if the message path goes:
updated client => old server => updated server
then the updated server on the end of the chain will still see the new DataMember. However, the "old server" will not see that new DataMember.
If an old server sends a message to an updated client, then the new DataMember will be set to default(type)
upon deserialization in the new client.
There's more about Best Practices for DataContract versioning here.
And this article discusses the difference between Breaking and Non-Breaking changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With