Data Contracts

  1. Use the DataMemberAttribute on properties or read-only public members only.

  2. Avoid explicit XML serialization on your own types.

  3. When using the Order property, assign the same value to all members coming from the same level in the class hierarchy.

  4. Support IExtensibleDataObject on your data contracts.

  5. Avoid setting IgnoreExtensionDataObject on the ServiceBehavior and CallbackBehavior attributes to true. Keep the default of false.

  6. Do not mark delegates and events as data members.

  7. Do not pass .NET-specific types, such as Type, as operation parameters.

  8. Do not accept or return ADO.NET DataSet and DataTable (or their type-safe subclasses) from operations. Return a natural representation such as an array.

  9. Suppress the generation of a generic type parameter hash code and provide a legible type name instead.

  10. Avoid the /ct switch of SvcUtil or any other way of sharing an assembly type across the service boundary.

Get Programming WCF Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.