Question

When doing lax versioning in DataContract classes, the Best Practices: Data Contract Versioning guide states:

Do not change the IsRequired property on any existing data members from version to version.

But then the Data Contract Versioning guide states:

Changing the IsRequired property value from true to false is not breaking, but changing it from false to true may be breaking if any prior versions of the type do not have the data member in question.

The first guide says that IsRequired should never be changed, and then the second guide says changing from false to true is non-breaking.

How would you reflect that a property is no longer required in a later version of a contract? If I change IsRequired from true to false wouldn't that break clients who are using the earlier version? They would be able to omit the once required property. Would this kind of change require the introduction of a new contract?

Was it helpful?

Solution

When you change IsRequired from true to false, it means every caller are already using a value in the field. Removing the IsRequired is not gonna change anything for them, since they already include a value, thus 'not breaking'.

Your clients can then decide to keep sending the given value or omit it in the future version of their call to your WebService. In this case, I wouldn't use a new contract.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top