I am creating an XSD document from a C# class.
This class has a property with type UInt32
that I expect to map to xs:unsignedInt
based on this article:
Mapping XML Data Types to CLR Types
The code for generating the .xsd is:
XmlReader reader = XmlReader.Create("class.xml");
XmlSchemaSet schemaSet = new XmlSchemaSet();
XmlSchemaInference schema = new XmlSchemaInference();
schemaSet = schema.InferSchema(reader);
However, in the xsd I see the element to be inferred to:
<xsd:element name="u32Value" type="xsd:unsignedByte" />
Why is the type not what I expect?
Based on the comments I discovered that I needed to initialize the Property to a value to help the XmlSchemaInference.InferSchema infer the proper type.
I originally planned on using xsd.exe to create the xsd file, but upon getting errors, decided to generate it programmatically through XmlSchemaInference.InferSchema. I neglected to consider the nuance you pointed out. When I initialize the property to UInt32.MaxValue, I get the expected results.