Summary
CloudNimble.Text.Xml.Serialization holds the types that shape how XmlSerializer maps .NET objects to XML: the attributes you put on your types, the enumerations that the options use, the base classes for custom converters, and the support types for source generation.
Usage
Import the namespace next toCloudNimble.Text.Xml, then annotate your types:
Considerations
- These aren’t the
System.Xml.Serializationattributes. Several types here have the same names as attributes inSystem.Xml.Serialization, such asXmlRootAttribute,XmlElementAttribute,XmlAttributeAttribute, andXmlIgnoreAttribute. The serializer reads only the ones in this namespace. An attribute fromSystem.Xml.Serializationon your type is ignored. - Don’t import both namespaces in one file.
[XmlElement]would be ambiguous and the file wouldn’t compile. When you move a type over, replaceusing System.Xml.Serialization;withusing CloudNimble.Text.Xml.Serialization;. See Migrate from XmlSerializer. - The same names don’t always mean the same defaults. For example, a collection has no wrapper element here unless you add
[XmlArray]or setDefaultCollectionMappingtoWrapped.XmlSerializerOptions.Bclsets the defaults that write whatSystem.Xml.Serialization.XmlSerializerwrites. - Mapping mistakes are reported on first use. A combination that can’t be mapped, such as
[XmlAttribute]on an object member or[XmlText]on a type that also has child elements, throws aNotSupportedExceptionthe first time the type is serialized or deserialized.
Related APIs
- CloudNimble.Text.Xml.XmlSerializer
- CloudNimble.Text.Xml.XmlSerializerOptions
- CloudNimble.Text.Xml.XmlNamingPolicy
- CloudNimble.Text.Xml.XmlPropertyMapping