Do not expose enum in WCF response

We had a backward compatibility problem in WCF client, when in Service application a new value was added to one of enums. We discussed different ways to avoid this backward compatibility issues, and I found recommendation do not expose enum in wcf response in http://stackoverflow.com/a/788281/52277.

It is still required to create new versions of our service interfaces to replace each enum fields with string field, that expects only documented values, and describe, what should be default behavior, if field has an unexpected value.

 

As a workaround for backward- compatibility of enums, they can be declared as [DataContract] and only old values set as [DataMember] , but left new values without the attribute until the new MAJOR release.Members that are not marked are not serialized.  See Enumeration Types in Data Contracts.

Advertisements