You're right buddy.
I trapped the code that was generated by the XmlSerializer and took a look
at it.
There's nothing about cardinality, per se. However, it looks like the
following happens:
XSD to class structure (via sxd.exe): The source cs file is created and
eventually compiled.
The XmlSerializer is instantiated and methods are created for the generatio
of the actual XML Elements (one for every hierarchicaly unique element). The
order of these method calls is identical to the order that the properties
occure in the original source file that was generated by XSD.exe.
So, do you think that I can make this assumption?
If you take the approach of:
1) Create an XSD document
2) generate a class model
3) Allow the XmlSerializer to generate its code for serialization
Then the sequence of elements will be fine, even though we all know that the
structure may or may not be valid (e.g. minOccurs, redefinition of simple
types, etc).
However, if we want to take the XmlElement attribute approach for indicating
which properties are serialized, we will have to make sure our source code is
written in the correct order for the resultant XML to be validated.