Skip to content

Commit 04b30d4

Browse files
Merge pull request #1171 from maxineal/develop
Fix WSDL schema generator with non-annotated System.Object
2 parents 2447b14 + 3674888 commit 04b30d4

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace SoapCore.Tests.Wsdl.Services;
2+
3+
public class ComplexTypeWithSystemObject
4+
{
5+
public object SystemObject { get; set; }
6+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.ServiceModel;
3+
4+
namespace SoapCore.Tests.Wsdl.Services
5+
{
6+
[ServiceContract]
7+
public interface IComplexTypeWithSystemObjectService
8+
{
9+
[OperationContract]
10+
ComplexTypeWithSystemObject Test();
11+
}
12+
13+
public class ComplexTypeWithSystemObjectService : IComplexTypeWithSystemObjectService
14+
{
15+
public ComplexTypeWithSystemObject Test() => throw new NotImplementedException();
16+
}
17+
}

src/SoapCore.Tests/Wsdl/WsdlTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,6 +1407,25 @@ public async Task CheckComplexGenericTypeWithMultipleArgumentsWsdl(SoapSerialize
14071407
Assert.AreEqual($"tns:{genericTypeName}Of{genericTypeArgumentName}{genericTypeArgumentName}", typeName);
14081408
}
14091409

1410+
[DataTestMethod]
1411+
[DataRow(SoapSerializer.XmlSerializer)]
1412+
public async Task CheckComplexTypeWithSystemObjectWsdl(SoapSerializer soapSerializer)
1413+
{
1414+
var wsdl = await GetWsdlFromMetaBodyWriter<ComplexTypeWithSystemObjectService>(soapSerializer);
1415+
Trace.TraceInformation(wsdl);
1416+
Assert.IsNotNull(wsdl);
1417+
1418+
var root = XElement.Parse(wsdl);
1419+
1420+
var systemObjectElement = GetElements(root, _xmlSchema + "element")
1421+
.SingleOrDefault(a => a.Attribute("name")?.Value.Equals(nameof(ComplexTypeWithSystemObject.SystemObject)) == true);
1422+
1423+
Assert.IsNotNull(systemObjectElement);
1424+
1425+
var typeAttribute = systemObjectElement.Attribute("type");
1426+
Assert.IsNull(typeAttribute);
1427+
}
1428+
14101429
[TestMethod]
14111430
public void CheckSchemeOverride()
14121431
{

src/SoapCore/Meta/MetaBodyWriter.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,11 @@ private void AddSchemaType(XmlDictionaryWriter writer, TypeToBuild toBuild, stri
12731273
_complexTypeToBuild.Enqueue(newTypeToBuild);
12741274
}
12751275
}
1276+
else if (type == typeof(object))
1277+
{
1278+
writer.WriteAttributeString("name", name);
1279+
WriteQualification(writer, isUnqualified);
1280+
}
12761281
else if (toBuild.IsAnonumous)
12771282
{
12781283
if (string.IsNullOrEmpty(name))

0 commit comments

Comments
 (0)