Check out XmlSchemaClassGenerator, an open source console application that includes PascalCasing among its features. (I found this after the 15-day trial of xsd2code expired.)
- Map XML namespaces to C# namespaces, either explicitly or through a (configurable) function
- Generate C# XML comments from schema annotations
- Generate DataAnnotations
attributes from schema restrictions
- Use
Collection<T>
properties (initialized in constructor and with private setter)
- Use either int, long, decimal, or string for xs:integer and derived types
- Automatic properties
- Pascal case for classes and properties
- Generate nullable adapter properties for optional elements and attributes without default values (see below)
- Optional support for PCL
- Optional support for
INotifyPropertyChanged
In my case, before I could get the console app to work, I had to modify the xsd document to include a targetNamespace
field as follows:
Original:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1">
Modified:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="gateway" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1">
My final usage looked something like this:
XmlSchemaClassGenerator.Console -n "http://www.w3.org/2001/XMLSchema=gateway" -o "C:\{output-folder}" {xsd-file-name}.xsd