diff --git a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/MarkupExtensionSerializer.cs b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/MarkupExtensionSerializer.cs index 7b857f6..a11f8ac 100644 --- a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/MarkupExtensionSerializer.cs +++ b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/MarkupExtensionSerializer.cs @@ -76,7 +76,7 @@ protected internal sealed override string SerializeToString(WorkflowMarkupSerial } else { - writer.WriteString(argType.FullName); + writer.WriteString(argType?.FullName ?? string.Empty); } } else diff --git a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/WorkflowMarkupSerializer.cs b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/WorkflowMarkupSerializer.cs index 536d544..cc033a2 100644 --- a/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/WorkflowMarkupSerializer.cs +++ b/LogicBuilder.Workflow.ComponentModel.Serialization/ComponentModel/Serialization/WorkflowMarkupSerializer.cs @@ -557,7 +557,7 @@ internal void SerializeContents(WorkflowMarkupSerializationManager serialization { writer.WriteValue(obj); } - // For Key properties, we don;t want to get the extended properties + // For Key properties, we don't want to get the extended properties if (!dictionaryKey) properties.AddRange(serializationManager.GetExtendedProperties(obj)); } @@ -586,24 +586,18 @@ internal void SerializeContents(WorkflowMarkupSerializationManager serialization } } - if (properties != null) + foreach (PropertyInfo propInfo in properties) { - foreach (PropertyInfo propInfo in properties) - { - // Do not serialize properties that have corresponding dynamic properties. - if (propInfo != null && !allProperties.ContainsKey(propInfo.Name)) - allProperties.Add(propInfo.Name, propInfo); - } + // Do not serialize properties that have corresponding dynamic properties. + if (propInfo != null && !allProperties.ContainsKey(propInfo.Name)) + allProperties.Add(propInfo.Name, propInfo); } - if (events != null) + foreach (EventInfo eventInfo in events) { - foreach (EventInfo eventInfo in events) - { - // Do not serialize events that have corresponding dynamic properties. - if (eventInfo != null && !allProperties.ContainsKey(eventInfo.Name)) - allProperties.Add(eventInfo.Name, eventInfo); - } + // Do not serialize events that have corresponding dynamic properties. + if (eventInfo != null && !allProperties.ContainsKey(eventInfo.Name)) + allProperties.Add(eventInfo.Name, eventInfo); } using (ContentProperty contentProperty = new(serializationManager, serializer, obj)) diff --git a/Workflow.ComponentModel.Serialization.Tests/ComponentModel/Design/HelpersTest.cs b/Workflow.ComponentModel.Serialization.Tests/ComponentModel/Design/HelpersTest.cs index 36bec69..f5b6569 100644 --- a/Workflow.ComponentModel.Serialization.Tests/ComponentModel/Design/HelpersTest.cs +++ b/Workflow.ComponentModel.Serialization.Tests/ComponentModel/Design/HelpersTest.cs @@ -121,6 +121,7 @@ public void CreateXmlWriter_WithInvalidType_ReturnsNull() public void CreateXmlWriter_WithNull_ReturnsNull() { // Arrange + System.Diagnostics.Trace.Listeners.Clear(); object? nullOutput = null; // Act diff --git a/Workflow.ComponentModel.Serialization.Tests/ComponentModel/SynchronizationHandlesTypeConverterTest.cs b/Workflow.ComponentModel.Serialization.Tests/ComponentModel/SynchronizationHandlesTypeConverterTest.cs index d1b88f0..0e6003f 100644 --- a/Workflow.ComponentModel.Serialization.Tests/ComponentModel/SynchronizationHandlesTypeConverterTest.cs +++ b/Workflow.ComponentModel.Serialization.Tests/ComponentModel/SynchronizationHandlesTypeConverterTest.cs @@ -185,7 +185,7 @@ public void ConvertFrom_UnescapesCommas() string input = "handle\\,with\\,commas, normalHandle"; // Act - var result = _converter.ConvertFrom(null, CultureInfo.InvariantCulture, input) as ICollection; + var result = _converter.ConvertFrom(null, CultureInfo.InvariantCulture, input) as ICollection ?? Array.Empty(); // Assert Assert.NotNull(result); @@ -201,7 +201,7 @@ public void ConvertFrom_TrimsWhitespace() string input = " handle1 , handle2 "; // Act - var result = _converter.ConvertFrom(null, CultureInfo.InvariantCulture, input) as ICollection; + var result = _converter.ConvertFrom(null, CultureInfo.InvariantCulture, input) as ICollection ?? Array.Empty(); // Assert Assert.NotNull(result); @@ -217,7 +217,7 @@ public void ConvertFrom_HandlesNewlineDelimiters() string input = "handle1\r\nhandle2\nhandle3"; // Act - var result = _converter.ConvertFrom(null, CultureInfo.InvariantCulture, input) as ICollection; + var result = _converter.ConvertFrom(null, CultureInfo.InvariantCulture, input) as ICollection ?? Array.Empty(); // Assert Assert.NotNull(result); @@ -234,7 +234,7 @@ public void ConvertFrom_RemovesDuplicates() string input = "handle1, handle2, handle1, handle3"; // Act - var result = _converter.ConvertFrom(null, CultureInfo.InvariantCulture, input) as ICollection; + var result = _converter.ConvertFrom(null, CultureInfo.InvariantCulture, input) as ICollection ?? Array.Empty(); // Assert Assert.NotNull(result); @@ -248,7 +248,7 @@ public void ConvertFrom_SkipsEmptyEntries() string input = "handle1, ,handle2, "; // Act - var result = _converter.ConvertFrom(null, CultureInfo.InvariantCulture, input) as ICollection; + var result = _converter.ConvertFrom(null, CultureInfo.InvariantCulture, input) as ICollection ?? Array.Empty(); // Assert Assert.NotNull(result);