tags:

views:

838

answers:

2

Is it possible to have any control over the class names that get generated with the .Net XSD.exe tool?

+3  A: 

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.

Marc Gravell
+2  A: 

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?

KevB