dotnet / dotnet/wcf

client generation with dotnet-svcutil: usage of DataTable in Service-Interface affects serialization of guid as string

Open
#4,770 2 comments 0 reactions 1 assignee Claimed by @imcarolwang View on GitHub
triaged
Dominant language
C#
Stars
1.8k
Forks
576
Avg merge
6d 9h
Merged PRs (30d)
2

Description

**Describe the bug**
We provide a wcf-service with several methods with guid-parameters and guid return types. When using dotnet-svcutil to create a client everything works like expected.

After adding a method which returns a `System.Data.DataTable` all other generated client-methods changed. Every usage of `Guid` was replaced by `string`.

`dotnet-svcutil` generated a client with `string`-parameters instead of `guid `parameters when a method with `DataTable`-returntype is present.

**To Reproduce**

Service which works correctly

```
public class Service1 : IService1
{
public int GetValue(Guid valueId)
{
throw new NotImplementedException();
}

public string GetTable(Guid section)
{
throw new NotImplementedException();
}
}
```

WSDL of service without datatable
```


























































































































```

Generated client interface (with expected guid parameters):
```

[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.3")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="IService1")]
public interface IService1
{

[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IService1/GetValue", ReplyAction="http://tempuri.org/IService1/GetValueResponse")]
System.Threading.Tasks.Task GetValueAsync(System.Guid valueId);

[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IService1/GetTable", ReplyAction="http://tempuri.org/IService1/GetTableResponse")]
System.Threading.Tasks.Task GetTableAsync(System.Guid section);
}

```

Now changing return type of GetDataTable(...)

```
public class Service1 : IService1
{
public int GetValue(Guid valueId)
{
throw new NotImplementedException();
}

public DataTable GetTable(Guid section)
{
throw new NotImplementedException();
}
}
```

the generated wsdl is as follows:

```





















































































































































```

when now generating a client with dotnet-svcutil this client interface becomes generated:
The parameter type of GetValueAsync is now string but should be guid.
```

[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.3")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="IService1")]
public interface IService1
{

[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IService1/GetValue", ReplyAction="http://tempuri.org/IService1/GetValueResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
System.Threading.Tasks.Task GetValueAsync(string valueId);

[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IService1/GetTable", ReplyAction="http://tempuri.org/IService1/GetTableResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
System.Threading.Tasks.Task GetTableAsync(GetTableRequest request);
}
```

**Expected behavior**
I expected that the usage of DataTable as return type has no side effects to the signature of other methods.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.