wcf
wcf copied to clipboard
Reuse of Types not working with WCF dotnet-svcutil tool for .NET Core
Common Types in assembly references are not reused
To Reproduce 1- I produced the common types from Common.xsd with xsd.exe in C# classes:
C:\Users\xxx\source\repos\BrokerSln\Broker\WSDL\uAPI_WSDLschema_Release-V19.2.0.12>xsd.exe /c common_v49_0\Common.xsd /namespace:Broker /out:..\..\..\CommonBroker\Common\
I made sure to have the namespace called Broker
2- I added the classes in the class library project called CommonBroker of target framework .Net Standard 2.0

I compiled the project with no problem.
I expect the type Broker.typeErrorInfo to be reused.

3- I added a new class library project called Broker of target framework .Net Standard 2.0
The project references the CommonBroker project

I add a new WCF reference

I also make sure the namespace is Broker

We can see the project CommonBroker is in the reused types

I generate the code

And unfortunately the type Broker.typeErrorInfo is generated again in Reference.cs

How can we make sure the tool can spot the reused types in our assembly?
Thanks for your help
I can send you the project so you can reproduce the problem
I used the xsd.exe of the .NET framework version 4.6.1055.0
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional>xsd /? Microsoft (R) Xml Schemas/DataTypes support utility [Microsoft (R) .NET Framework, Version 4.6.1055.0] Copyright (C) Microsoft Corporation. All rights reserved.
Hi Daniel, Hope you are doing ok and the quarantine is not too hard.
Could you reproduce the problem with the project?
Thanks :) Nico
It is not serious here....
@nicoclau Sorry for not responding to this sooner, and thank you for reporting it. This sounds like it most likely has the same root cause as #3812, which is that types are not reused as expected when a different namespace is specified in the type's attributes. It's slightly different because your report looks like it's using XML Serializer instead of DataContractSerializer, but in both cases there are namespaces being specified, so it seems likely that this is why the tool is unable to reuse types from this library.
We are planning to investigate #3812 as soon as we can, and as part of that investigation we can take a look at this instance of it as well. Unfortunately we don't have any workarounds to suggest at this time.
Hi, I have the same issue trying to add more than a service on the same project, dotnet-svcutil does not realize the previous types added, not even using --reference pointing to the same project or pointing to the compiled assembly.
SDK: net6.0
Steps to reproduce
dotnet tool install --global dotnet-svcutil
git clone --depth 1 --branch v0.0.1 https://github.com/mark-ind/Markind.Siat/
- delete the src folder.
- Use the generate.ps1 which generates for 4 endpoints sharing messages.
- dotnet build You will get errors because dotnet-svcutil re-created the message classes (aka dto's) for each endpoint.
Thank you all for reporting this issue!
This behavior is not a regression from svcutil.exe, see this article and doc for references.
We will treat this issue as an enhancement for future consideration.