Is it possible to have any control over the class names that get generated with the .Net XSD.exe tool?
The XML Schema Definition (Xsd.exe) tool generates XML schema or common language runtime classes from XDR, XML, and XSD files, or from classes in a runtime assembly.
XSD can easily define parent-child relationship and basic type restrictions needed to define tables - so can be used as database schema. "MSDataSetGenerator" is the "custom tool" that builds whatever files/binaries are needed from the XSD whenever XSD is saved.
As far as I'm aware I don't think this is possible, the class names match almost exactly to whats in the schema.
Personally I would change the class names after XSD has generated the code, but to be honest I usually just stick with what XSD generates. Its then easier for someone else reading the code to understand what classes map to what parts of the XML.
Alternatively, if you have control over the schema you could update that?
Basically, no. If you were writing the classes manually, you could have:
[XmlType("bar")]
class Foo {}
however, you can't do this with the xsd-generated classes. Unfortunately, one of the things you can't do with a partial class
is rename it. Of course, you could use xsd
to generate it, change the .cs file and don't generate it again, but that is not ideal for maintenance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With