11

Is it so that svcutil tool is recommended over xsd tool? I didn't see that as a confirmed statement, but it did seem so. The reason that I am confused over this is that I generated a class using both the tools. But, I got a better class using xsd. The XSD schema consists of DataContracts only.

I used the following command for svcutil:

svcutil path-to\xyz.xsd /language:C# /dataContractOnly /importxmltypes /out:path-to\class.cs

This generated the desired classes. But, it contained only XmlNode[] objects for the fields.

Then, I used the following command for xsd:

xsd.exe /c path-to\xyz.xsd /out:path-to\class.cs

It generated much better classes than svcutil did. Most of the fields were converted as desired.

Should I have any reason to believe that I should use svcutil over xsd then?

bhootjb
  • 1,501
  • 1
  • 21
  • 33

2 Answers2

5

As far as I know, there are some limitations with XSD.exe; for instance when there is a Dictionary<,> in the class, XSD.exe can not generate a proper XSD; as Dictionary does not implement IXmlSerializable.

davmos
  • 9,324
  • 4
  • 40
  • 43
daryal
  • 14,643
  • 4
  • 38
  • 54
  • ok. I have several other schema, which I would convert using the tools, and see what is better for my usage. I will select the appropriate tool accordingly. – bhootjb Mar 23 '12 at 11:51
3

svcutil does not support xml attributes. If you need to use them in your schema, you are probably better off with xsd.exe.

I personally prefer to use svcutil over xsd and I've learned how to form my schemas to output the class structure I want, but I'm also primarily working with schemas that I am developing from scratch, as opposed to consuming predefined ones.

Colin Young
  • 3,018
  • 1
  • 22
  • 46