How to prevent xsd.exe from creating uncompileable C#

Viewed 94

I am currently trying to generate C# code using xsd.exe in order to use it with System.Xml.Serialization.

The command i am using is the next one:

xsd.exe path\to\eExact-XML.xsd /c /namespace:Namespace.Models /o:path\to\Namespace\Models

Alas, the generated code is not compileable due to the next generated snippet:

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public object System {
    get {
        return this.systemField;
    }
    set {
        this.systemField = value;
    }
}

One of the generated classes contains a property called System, which renders the following compiler error within the XmlElementAttribute:

eExact-XML.cs(25799, 60): [CS0120] An object reference is required for the non-static field, method, or property 'GLTransactionLineIntraStat.System'

My current solution is to simple remove the culprit from the generated class, but I don't find this an elegant solution.

Is there any way to tell xsd.exe to rename certain properties, or leave out parts of the xsd spec?

0 Answers
Related