Xsd.exe generates duplicate attributes when run on OFX2 schema

Using the command line:

"xsd.exe" "OFX 2.1.1 schema/OFX2_Protocol.xsd" /c /namespace:OFX /nologo"

      

C # original source file fails to build with these errors:

D:\blah\OFX2_Protocol.cs(19,6): error CS0579: Duplicate 'System.CodeDom.Compiler.GeneratedCodeAttribute' attribute
D:\blah\OFX2_Protocol.cs(20,6): error CS0579: Duplicate 'System.SerializableAttribute' attribute
D:\blah\OFX2_Protocol.cs(21,6): error CS0579: Duplicate 'System.Diagnostics.DebuggerStepThroughAttribute' attribute
D:\blah\OFX2_Protocol.cs(22,6): error CS0579: Duplicate 'System.ComponentModel.DesignerCategoryAttribute' attribute
D:\blah\OFX2_Protocol.cs(23,6): error CS0579: Duplicate 'System.Xml.Serialization.XmlTypeAttribute' attribute
D:\blah\OFX2_Protocol.cs(24,6): error CS0579: Duplicate 'System.Xml.Serialization.XmlRootAttribute' attribute

      

A similar XSD schema that I copied from the OFX2 schema then trimmed down to the useful bits I wanted generates a C # file that builds just fine but has all the same attributes as the full C # schema representation.

Any idea why? Is the OFX schema broken? Is xsd.exe fixed? Is C # broken? Am I broken?

+2


source to share


3 answers


Ok, this answer is taking a long time ...

I just ran into the same problem. The problem was not foo.cs, but foo.designer.cs. You need to remove duplicate attributes in the second class.



C # should either allow duplicate attributes across partial classes, or fix the xsd to omit attributes in all but the .cs file.

+7


source


The latest download of the OFX specification has "OFX3_Protocol_dotNET.xsd", which has been modified from "OFX2_Protocol.xsd" to better match the .NET code generation facilities. I generated C # from this xsd with no problem, although I haven't deserialized any XML yet.



+1


source


I had the same problem (same "duplicate attributes" problem) with different schemas. the reason was caused by two xsd schemas (2 generated files) and in each of them I had the same item "type" but with different definitions. renaming one of the types to another name solves the problem

+1


source







All Articles