Serialization changes in Version 6

Component: NServiceBus

BinarySerializer deprecated

The BinarySerializer is deprecated. Use one of the supported serializers, or an external serializer.

No dependency injection for IMessageSerializer

The IMessageSerializer instances are now produced by a factory (as described in this article) instead of being resolved through a container.

Built-in serializers are internal

Built-in JSON and XML serializers are internal starting with Version 6. If a custom serializer depends on them in any way the code will need to be copied.

Standardized XML Serialization

Null types within the XML serializer now conforms to the W3C Specification by using the xsi:nil="true" attribute.

This change is backward compatible and will have no impact on communication between older versions of endpoints and newer versions. Older versions will be able to communicate with newer versions and vice versa.

Given the following class:

public class MessageWithNullable : IMessage
{
    public string FirstName { get; set; }
    public DateTime? BirthDate { get; set; } //Nullable DateTime property
}

A null BirthDate would result in a message in the following:

6.x NServiceBus
<MessageWithNullable 
  xmlns="http://tempuri.net/NServiceBus.Serializers.XML.Test">
  <FirstName>FirstName</FirstName>
  <BirthDate xsi:nil="true"></BirthDate>
</MessageWithNullable>
5.x NServiceBus
<MessageWithNullable 
  xmlns="http://tempuri.net/NServiceBus.Serializers.XML.Test">
  <FirstName>FirstName</FirstName>
  <BirthDate>null</BirthDate>
</MessageWithNullable>
External integration systems need to ensure compatibility when receiving messages in the new format.

BSON serializer deprecated

The BSON serializer build into the core has been removed. Use the Newtonsoft serializer as a replacement. Also see the Newtonsoft BSON sample.


Last modified