-
Notifications
You must be signed in to change notification settings - Fork 17
Description
When generating code for the following minimal schema: schema.xsd.xml
The output has missing type information (typeof(void)) on the localElementDictionary for the type Root.ElementLocalType:
private static void BuildElementDictionary()
{
localElementDictionary.Add(BaseTypeMemberXName, typeof(void));
}
The causes problems with unnecessary (and potentially invalid) xsi:type attributes being generated for these members during XML serialization. The issue seems to specifically affect anonymous types which extend a named base type that has a complexType element.
As a workaround I am using a partial class at runtime to fix the incorrect localElementDictionaries.
The issue is in XsdToTypesConverter.BuildPropertyForElement, which only adds anonymous types to the localSymbolTable if they did not come from the base type. Then the type info doesn't get populated when the anonymous types are enumerated later (in LocalSymbolTable.GetAnonymousTypes).
This patch (based on master) addresses the issue by adding all anonymous types but skipping ones from the base type in the later enumeration:
0001-Codegen-localElementDictionary-type-incorrect-for-in.patch