I have an XML schema .xsd file and generate my file with all the C# classes with the xsd.exe tool. If I have a sequence of elements within an XML tag, that would be represented in C# with an array. The fail is obvious. How can I generate Lists instead of arrays?
Instead of fixed size arrays in a class, I would like to use Lists.
Book [] books = new Book[someFixSize];
List<Book> books = new List<Book>();
I have seen some older (very old) questions about this, but none of them provided a satisfied solution :/
This is the latest useful hint: http://www.stefanbader.ch/xsdcsarr2l-exe-refactor-xsd-array-to-list/
I run into the same problem trying to use the svcutil without having the contracts, for that reason I wrote the xsdcsarr2l tool. If you are interested I take the time and upload a newer version where at least the list variables are initialized automatically. On the other hand, the project is light enough, that you can take the source and improve it yourself by using the NRefactory classes.
Try using svcutil.exe
svcutil /o:myFile.cs /ct:System.Collections.Generic.List myXsd.xsd
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