Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ internal static XmlWriter CreateXmlWriter(object output)
return XmlWriter.Create(output as TextWriter, settings);
else
{
#if !UNITTESTS && DEBUG
Debug.Assert(false, "Invalid argument type. 'output' must either be string or TextWriter.");
#endif
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,6 @@ protected WorkflowMarkupSerializationException(SerializationInfo info, Streaming
this.columnNumber = info.GetInt32("columnNumber");
}

public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)
throw new ArgumentNullException("info");

base.GetObjectData(info, context);

info.AddValue("lineNumber", this.lineNumber, typeof(int));
info.AddValue("columnNumber", this.columnNumber, typeof(int));
}

public int LineNumber
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ private void DeserializeContents(WorkflowMarkupSerializationManager serializatio
//DependencyProperty dependencyProperty = ResolveDependencyProperty(serializationManager, reader, obj, reader.LocalName);
if (property == null)
serializationManager.ReportError(CreateSerializationError(SR.GetString(SR.Error_InvalidElementFoundForType, reader.LocalName, obj.GetType().FullName), reader));
else if (property != null)
else
{
//Deserialize the compound property
serializationManager.Context.Push(property);
Expand Down Expand Up @@ -1004,9 +1004,7 @@ private object InternalDeserializeFromString(WorkflowMarkupSerializationManager
object propVal = null;
if (!(serializationManager.WorkflowMarkupStack[typeof(XmlReader)] is XmlReader reader))
{
#if !UNITTESTS && DEBUG
Debug.Assert(false, "XmlReader not available.");
#endif
return null;
}
if (IsValidCompactAttributeFormat(value))
Expand Down Expand Up @@ -1358,8 +1356,7 @@ private void DeserializeCompoundProperty(WorkflowMarkupSerializationManager seri
if (isReadOnly)
{
object propValue = null;
if (property != null)
propValue = property.CanRead ? property.GetValue(obj, null) : null;
propValue = property.CanRead ? property.GetValue(obj, null) : null;

if (propValue != null)
DeserializeContents(serializationManager, propValue, reader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,12 @@ public override object ProvideValue(IServiceProvider provider)
type = manager.GetType(new XmlQualifiedName(typename, reader.LookupNamespace(string.Empty)));

// To Support Beta2 format
if (type == null)
if (type == null && manager.GetService(typeof(ITypeResolutionService)) == null)
{
// If not design mode, get the value from serialization manager
// At design time, we need to get the type from ITypeProvider else
// we need to store the string in the hashtable we maintain internally
if (type == null && manager.GetService(typeof(ITypeResolutionService)) == null)
type = manager.SerializationManager.GetType(typename);
type = manager.SerializationManager.GetType(typename);
}
if (type != null)
return type;
Expand Down
4 changes: 0 additions & 4 deletions LogicBuilder.Workflow.ComponentModel.Serialization/SR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ internal static string GetString(CultureInfo culture, string name, params object
if (sys == null)
return null;
string res = sys.resources.GetString(name, culture);
#if !UNITTESTS && DEBUG
System.Diagnostics.Debug.Assert(res != null, string.Format(CultureInfo.CurrentCulture, "String resource {0} not found.", new object[] { name }));
#endif
if (args != null && args.Length > 0)
{
return string.Format(CultureInfo.CurrentCulture, res, args);
Expand All @@ -133,9 +131,7 @@ internal static string GetString(CultureInfo culture, string name)
if (sys == null)
return null;
string res = sys.resources.GetString(name, culture);
#if !UNITTESTS && DEBUG
System.Diagnostics.Debug.Assert(res != null, string.Format(CultureInfo.CurrentCulture, "String resource {0} not found.", new object[] { name }));
#endif
return res;
}

Expand Down
3 changes: 0 additions & 3 deletions LogicBuilder.Workflow.ComponentModel.Serialization/Utility.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

[assembly: CLSCompliant(true)]
Expand All @@ -23,9 +22,7 @@ internal static Guid CreateGuid(string guidString)
{
if (!success)
{
#if !UNITTESTS && DEBUG
System.Diagnostics.Debug.Assert(false, "Creation of the Guid failed.");
#endif
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using LogicBuilder.Workflow.ComponentModel.Serialization;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection;
using System.Xml;
Expand Down Expand Up @@ -373,6 +374,7 @@ public void Equals_WithDifferentUnifiedAssemblyName_ReturnsFalse()
}

[Fact]
[SuppressMessage("Style", "CA1062:Validate arguments of public methods", Justification = "Testing explicit null handling")]
public void Equals_WithNull_ReturnsFalse()
{
// Arrange
Expand Down
1 change: 1 addition & 0 deletions Workflow.ComponentModel.Serialization.Tests/SRTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public void SRDescriptionAttribute_SetsDescriptionValue_WhenCreatedWithResourceK
public void SRDescriptionAttribute_ReturnsEmptyString_WhenResourceKeyDoesNotExist()
{
// Arrange & Act
System.Diagnostics.Trace.Listeners.Clear();
var attribute = new SRDescriptionAttribute("NonExistentKey12345");

// Assert
Expand Down
4 changes: 4 additions & 0 deletions Workflow.ComponentModel.Serialization.Tests/UtilityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void CreateGuid_ReturnsValidGuid_WhenGuidStringHasBraces()
public void CreateGuid_ReturnsValidGuid_WhenGuidStringHasParentheses()
{
// Arrange
System.Diagnostics.Trace.Listeners.Clear();
string guidString = "(12345678-1234-1234-1234-123456789abc)";
Guid expected = new(guidString);

Expand All @@ -66,6 +67,7 @@ public void CreateGuid_ReturnsValidGuid_WhenGuidStringHasParentheses()
public void CreateGuid_ThrowsArgumentNullException_WhenGuidStringIsNull()
{
// Arrange
System.Diagnostics.Trace.Listeners.Clear();
string guidString = null!;

// Act & Assert
Expand All @@ -76,6 +78,7 @@ public void CreateGuid_ThrowsArgumentNullException_WhenGuidStringIsNull()
public void CreateGuid_ThrowsFormatException_WhenGuidStringIsInvalid()
{
// Arrange
System.Diagnostics.Trace.Listeners.Clear();
string guidString = "invalid-guid-string";

// Act & Assert
Expand All @@ -96,6 +99,7 @@ public void CreateGuid_ThrowsFormatException_WhenGuidStringIsEmpty()
public void CreateGuid_ThrowsFormatException_WhenGuidStringIsTooShort()
{
// Arrange
System.Diagnostics.Trace.Listeners.Clear();
string guidString = "12345678";

// Act & Assert
Expand Down