Create MULTIPLE class files based on an XSD

前端 未结 2 1632
别那么骄傲
别那么骄傲 2021-01-04 01:44

I may be attempting something that is not possible with the XSD tool but I wanted to ask before moving on to a simpler solution.

I have an XSD file that has multiple

相关标签:
2条回答
  • 2021-01-04 02:02

    This doesn't answer your question directly, but I wanted to throw a couple things out:

    I generally find it counter-productive to separate generated code. I always like to generally follow the "one class per file" rule, but I make an exception here, because I often deal with very large schemas. Even in their own directory, I don't want to have to diff tens (to hundreds) of files when I generate a new version of the code. I find it very convenient to have all the generated code diffable in one file.

    Now, to offer a possible solution - Resharper has the ability to pull all the classes out of a file and put them in their own files. If you right click the file in the solution explorer, you can say Refactor → Move types into matching files.... Of course, this isn't anywhere near as convenient as just generating it this way, but I don't know of a tool that will do that.

    0 讨论(0)
  • 2021-01-04 02:12

    The problem I'm trying to solve was either in separate class files or one singular, but unique classes rather than the same namespace containing multiple classes. As a result, I was looking for a similar answer and found this reference to share Getting xsd.exe To Not Create Duplicate Classes

    This is a simple fix, but it took me a long time to figure out. You have to use xsd.exe to compile all of your classes at once, so rather than running two separate commands, you just need to run one: C:\Solution\Project>xsd.exe Types.xsd Request.xsd Response.xsd /c Now you have one file, Response.xsd, with all three classes in it.

    0 讨论(0)
提交回复
热议问题