Skip to content

Commit

Permalink
XmlSerializer WSDL: Use uppercase letter for ArrayOf<Type> type
Browse files Browse the repository at this point in the history
Added a test that verifies the correct behavior.

Fixes DigDes#1008
  • Loading branch information
vidrenning committed Feb 7, 2024
1 parent af7107b commit f66e91b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/SoapCore.Tests/Wsdl/Services/ArrayService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,14 @@ public class ArrayRequest
public long[] LongArray { get; set; }
public long[][] LongArrayArray { get; set; }
public List<List<string>> StringListList { get; set; }
public List<innerClass> InnerClassList { get; set; }
}

// Class starts with lower-case letter on purpose for a test
#pragma warning disable SA1300 // Element should begin with upper-case letter
public class innerClass
#pragma warning restore SA1300 // Element should begin with upper-case letter
{
public string Name { get; set; }
}
}
4 changes: 4 additions & 0 deletions src/SoapCore.Tests/Wsdl/WsdlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,10 @@ public async Task CheckArrayServiceWsdl()
var stringListList = root.XPathSelectElement("//xsd:complexType[@name='ArrayRequest']/xsd:sequence/xsd:element[@name='StringListList' and @type='tns:ArrayOfArrayOfString' and @nillable='true']", nm);
Assert.IsNotNull(stringListList);

// verify that ArrayOfInnerClass uses upper-case "i", even though the class starts with a lower-case letter.
var innerClassList = root.XPathSelectElement("//xsd:complexType[@name='ArrayRequest']/xsd:sequence/xsd:element[@name='InnerClassList' and @type='tns:ArrayOfInnerClass' and @nillable='true']", nm);
Assert.IsNotNull(innerClassList);

var nullableEnumerable = root.XPathSelectElement("//xsd:complexType[@name='EnumerableResponse']/xsd:sequence/xsd:element[@name='LongNullableEnumerable' and @type='tns:ArrayOfNullableLong' and @nillable='true']", nm);
Assert.IsNotNull(nullableEnumerable);

Expand Down
2 changes: 1 addition & 1 deletion src/SoapCore/Meta/BodyWriterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public static string GetSerializedTypeName(this Type type)

private static string GetArrayTypeName(string typeName, bool isNullable)
{
return "ArrayOf" + (isNullable ? "Nullable" : null) + (ClrTypeResolver.ResolveOrDefault(typeName).FirstCharToUpperOrDefault() ?? typeName);
return "ArrayOf" + (isNullable ? "Nullable" : null) + (ClrTypeResolver.ResolveOrDefault(typeName) ?? typeName).FirstCharToUpperOrDefault();
}

private static XmlSerializerNamespaces Convert(this XmlNamespaceManager xmlNamespaceManager)
Expand Down

0 comments on commit f66e91b

Please sign in to comment.