SvcUtil and /dconly generates XSD's for data types NOT marked with the DataContract attribute

1.3k views Asked by At

Has anyone ever encountered a problem with Svcutil and the /dconly option where it generates metadata for EVERY data type in an Assembly, even if it is NOT marked with with the [DataContract()] attribute? It also appears to be generating metadata for types only referenced in the code, such as XmlDictionaryReaderQuotas even though these are not a part of the physical assembly that I generated metadata on.

Some info: Using the .NET 4.0 version of SvcUtil. Does not matter if class is empty or not. No references are specified in the command line for SvcUtil.

Command line:

"C:\In Progress Work (Prospective)\Prospective Server\Prospective Server\Management\Prospective.Server.Server.NET40.Debug.AnyCPU.dll" /nologo /t:metadata /d:"C:\In Progress Work (Prospective)\Prospective Server\Prospective Server\Management" /dconly

1

There are 1 answers

1
Adam Wilson On BEST ANSWER

The work-around is to explicitly specify which XSD's to use. In my case that could still be enough to overflow the character limit for the command line; instead I wrote some code that deletes all the extra XSD's and continue to use *.xsd on the SvcUtil command. However, this can be tricky as it requires detailed knowledge of every WCF namespace in the assembly.

I have filed a bug report with Microsoft as this behavior is not defined as correct in any of their publicly available documentation. You can view the bug report and vote it up here: http://connect.microsoft.com/wcf/feedback/details/641777/svcuil-with-datacontractonly-generates-xsds-for-all-types-in-assembly-regardless-of-datacontract-attributes