What you implemented is good. You've achieved polymorphism for a single object of derived runtime types.
What you think you want is wrong. What looks redundant to you is absolutely essential and informative. In <Message i:type="Warning">
, the tag Message
indicates the abstract base type. The attribute value Warning
indicates the instance runtime type derived from Message
. If the XML did not contain the name of the base class Message
, the Code Project mechanism would not even search for the set of known types. How the code would be supposed to “know” where to look for them?
However, the attempts to “improve” Data Contract XML by shortening the “obvious” (no, it is not obvious at all) is the entire phenomenon. Why any ad hoc approach here? Why do you think this kind of mess can improve anything? I cannot understand you guys.
You already have done a good job on your contract and produced right result, so I suggest you accept my answer and close the issue.