0

Is there a modern and regularly updated tool for generating C# v.7+ classes of XSD? The only tool I know is xsd2code but it is not free and its last update, according to the official site was "Update 4.4 (June 05, 2017)"

nmrlqa4
  • 659
  • 1
  • 9
  • 32
  • As far as I know visual studio can do this pretty good. – Stefan Sep 03 '18 at 13:10
  • I also read something, but cannot find good documentation with examples. I am running VS 2017 if that matters – nmrlqa4 Sep 03 '18 at 13:12
  • Is your xsd public? I am running vs2017 at the moment and can give it a shot – Stefan Sep 03 '18 at 13:12
  • No, unfortunately is private. – nmrlqa4 Sep 03 '18 at 13:14
  • Ok, I found a public one... I'll give it a shot. – Stefan Sep 03 '18 at 13:17
  • Hmm.... I can import he xsd (as xml) see all the properties etc. but no way tho generate the classes. There used to be a tool... it's the same one you are using: see: https://stackoverflow.com/questions/4886031/visual-studio-2010-xml-xsd-schema-to-classes-within-the-ide#15621992 – Stefan Sep 03 '18 at 13:24
  • Visual Studio and the .NET SDK already contain such tools. That's how they generate proxies for WCF (svcutil.exe) and the older ASMX web services (xsd.exe). What are you looking for? What's the problem with the built-in tools? – Panagiotis Kanavos Sep 03 '18 at 13:39

1 Answers1

0

There is an alternative tool:

xsd.exe

Run it like this:

xsd /c /namespace:myCompany /language:CS XMLFile.xsd

I have tried it with this XSD, saved it to disk, and runned the tool. It seems to work.

It's available in the VS-20XX command prompt or, in my case in:

C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.1 Tools

For more info on the path: see: where to find xsd.exe in visual studio 2013 on windows 8

Stefan
  • 17,448
  • 11
  • 60
  • 79
  • This was replaced by `svcutil` back in 2008 – Panagiotis Kanavos Sep 03 '18 at 13:37
  • ... ah nice, ... whats the syntx for generating cs classes from the xsd? – Stefan Sep 03 '18 at 13:38
  • Btw, there seems to be some limitation on svutil, and the doc are still from 2017: https://learn.microsoft.com/en-us/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe, are you sure it's truly replaced? – Stefan Sep 03 '18 at 13:40
  • 2
    svcutil is not a _replacement_ for xsd.exe, except for generating WCF Data Contracts and Service Contracts. svcutil, for instance, supports DataContractSerializer, while xsd.exe always uses XmlSerializer. Also xsd.exe only reads XML Schema, while svcutil reads WSDL files. – David Browne - Microsoft Sep 03 '18 at 13:46