diff --git a/src/NServiceBus.Core.Tests/NServiceBus.Core.Tests.csproj b/src/NServiceBus.Core.Tests/NServiceBus.Core.Tests.csproj
index 377646392a4..1a4f43abfed 100644
--- a/src/NServiceBus.Core.Tests/NServiceBus.Core.Tests.csproj
+++ b/src/NServiceBus.Core.Tests/NServiceBus.Core.Tests.csproj
@@ -91,6 +91,7 @@
+
diff --git a/src/NServiceBus.Core.Tests/Serializers/XML/Issue_2796.cs b/src/NServiceBus.Core.Tests/Serializers/XML/Issue_2796.cs
new file mode 100644
index 00000000000..5a3a5bda4ee
--- /dev/null
+++ b/src/NServiceBus.Core.Tests/Serializers/XML/Issue_2796.cs
@@ -0,0 +1,41 @@
+namespace NServiceBus.Core.Tests.Serializers.XML
+{
+ using System;
+ using System.IO;
+ using NServiceBus.Serializers.XML.Test;
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class Issue_2796
+ {
+ [Test]
+ public void Object_property_with_primitive_or_struct_value_should_serialize_correctly()
+ {
+ var serializer = SerializerFactory.Create();
+ var message = new SerializedPair
+ {
+ Key = "AddressId",
+ Value = new Guid("{ebdeeb33-baa7-4100-b1aa-eb4d6816fd3d}")
+ };
+
+ object[] messageDeserialized;
+ using (Stream stream = new MemoryStream())
+ {
+ serializer.Serialize(message, stream);
+
+ stream.Position = 0;
+
+ messageDeserialized = serializer.Deserialize(stream, new[] { message.GetType() });
+ }
+
+ Assert.AreEqual(message.Key, ((SerializedPair)messageDeserialized[0]).Key);
+ Assert.AreEqual(message.Value, ((SerializedPair)messageDeserialized[0]).Value);
+ }
+
+ public class SerializedPair
+ {
+ public string Key { get; set; }
+ public object Value { get; set; }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/NServiceBus.Core/Features/DisplayDiagnosticsForFeatures.cs b/src/NServiceBus.Core/Features/DisplayDiagnosticsForFeatures.cs
index f8504708d21..0371db473b5 100644
--- a/src/NServiceBus.Core/Features/DisplayDiagnosticsForFeatures.cs
+++ b/src/NServiceBus.Core/Features/DisplayDiagnosticsForFeatures.cs
@@ -27,7 +27,7 @@ public void Run(Configure config)
statusText.Append("Deactivation reason: ");
if (diagnosticData.PrerequisiteStatus != null && !diagnosticData.PrerequisiteStatus.IsSatisfied)
{
- statusText.AppendLine(string.Format("Did not fulfill its Prerequisites:"));
+ statusText.AppendLine("Did not fulfill its Prerequisites:");
foreach (var reason in diagnosticData.PrerequisiteStatus.Reasons)
{
diff --git a/src/NServiceBus.Core/Licensing/LicenseExpiredForm.cs b/src/NServiceBus.Core/Licensing/LicenseExpiredForm.cs
index 90806464ba5..5d3ba516490 100644
--- a/src/NServiceBus.Core/Licensing/LicenseExpiredForm.cs
+++ b/src/NServiceBus.Core/Licensing/LicenseExpiredForm.cs
@@ -61,7 +61,7 @@ void browseButton_Click(object sender, EventArgs e)
if (LicenseExpirationChecker.HasLicenseExpired(license))
{
- var message = string.Format("The license you provided has expired, please select another file.");
+ var message = "The license you provided has expired, please select another file.";
Logger.Warn(message);
MessageBox.Show(this, message, "License expired", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
diff --git a/src/NServiceBus.Core/Serializers/XML/XmlMessageSerializer.cs b/src/NServiceBus.Core/Serializers/XML/XmlMessageSerializer.cs
index 31f2efac476..0be23b0a311 100644
--- a/src/NServiceBus.Core/Serializers/XML/XmlMessageSerializer.cs
+++ b/src/NServiceBus.Core/Serializers/XML/XmlMessageSerializer.cs
@@ -831,12 +831,8 @@ object GetPropertyValue(Type type, XmlNode n)
public void Serialize(object message, Stream stream)
{
InitializeNamespaces(message);
- var messageBuilder = SerializeMessage(message);
+ var builder = SerializeMessage(message);
- var builder = new StringBuilder();
- builder.AppendLine("");
-
- builder.Append(messageBuilder);
var buffer = Encoding.UTF8.GetBytes(builder.ToString());
stream.Write(buffer, 0, buffer.Length);
}
@@ -850,9 +846,23 @@ public void Serialize(object message, Stream stream)
StringBuilder SerializeMessage(object message)
{
var messageBuilder = new StringBuilder();
+
+ messageBuilder.AppendLine("");
+
var t = mapper.GetMappedTypeFor(message.GetType());
+ var baseTypes = GetBaseTypes(message);
+
+ var objectBuilder = new StringBuilder();
+ var elementName = t.SerializationFriendlyName();
+
+ WriteObject(elementName, t, message, objectBuilder);
+
+ var startElementBuilder = new StringBuilder();
+ var ns = GetNamespace(message);
+ CreateStartElementWithNamespaces(ns, baseTypes, startElementBuilder, elementName);
- WriteObject(t.SerializationFriendlyName(), t, message, messageBuilder, true);
+ objectBuilder.Replace(string.Format("<{0}>", elementName), startElementBuilder.ToString());
+ messageBuilder.AppendLine(objectBuilder.ToString().TrimEnd());
return messageBuilder;
}
@@ -906,7 +916,7 @@ void WriteObject(string name, Type type, object value, StringBuilder builder, bo
{
var element = name;
- if (type == typeof(object) && (value.GetType().IsSimpleType()))
+ if (type == typeof(object) && value.GetType().IsSimpleType())
{
if (!namespacesToAdd.Contains(value.GetType()))
{
@@ -920,17 +930,7 @@ void WriteObject(string name, Type type, object value, StringBuilder builder, bo
return;
}
-
- if (useNS)
- {
- var @namespace = InitializeNamespaces(value);
- var baseTypes = GetBaseTypes(value);
- CreateStartElementWithNamespaces(@namespace, baseTypes, builder, element);
- }
- else
- {
- builder.AppendFormat("<{0}>\n", element);
- }
+ builder.AppendFormat("<{0}>\n", element);
Write(builder, type, value);