XmlSerializer now serializes properties of object
type properly
#2796
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Who's affected
Users with V5.X endpoints configured to use XML message serialization, when using fields of type
System.Object
that are assigned primitive or simple (e.g. Guid, DateTime) types.Symptoms
Serialization will not generate namespaces for simple types, and deserialization will fail, since the message element does not have all the appropriate namespaces.
Steps to reproduce
Trying to serialize, then deserialize the following type fill fail, when the
Value
property is assigned a simple type, e.g. Guid:Workaround
none
Original bug report
I'm currently upgrading from NServiceBus 4.7.5 to NServiceBus 5.2.4, and when using the XmlSerializer, I noticed that it generates an invalid XML message when I try to serialize a message -
the namespaces for the simple types are no longer declared, but they're still used in the document.
For example, if I try to serialize a message that exposes a SerializedPair property that is defined as follows:
in 4.7.5 it would be serialized as:
In 5.2.4, it gets serialized as:
Note that the "Messages" element is no longer present, and the "xmlns:guid" namespace declaration is also missing, which makes this invalid XML.
How do I get NServiceBus to generate valid xml again?
For completeness, my BusConfiguration looks like:
This was originally posted in http://stackoverflow.com/q/31943814/90882