Snippet - Small port of XmlSerializer

Small port of XmlSerializer

This is still needs some tweaks. The //TODO: and //NOTE: mention any issues.

A implementation of System.Xml.Serialization.XmlSerializer from desktop .NET to work on NETMF. This allows you to share a common data class between any .NET applications (desktop, compact and micro) and have the data in the class be serialized to and from XML it in any of those environments. Almost all primitive value types are supported. The known types that are not in parity with desktop .NET are Enums, byte[], embedded structs and embedded classes.

1 Like

Thank you JRendean.
Great !!!

@ JREndean,
I got some problem in deserialization. I suggest a modification like this:

        public object Deserialize(Stream stream)
            object instance = this.typeToSerialize.GetConstructor(new Type[0]).Invoke(null);
 // Use XmlReaderSettings
            XmlReaderSettings xmlrdr_settings = new XmlReaderSettings();
            xmlrdr_settings.IgnoreWhitespace = true; 
// I suggest this becouse .NET serializer use by default "\n" after tag so better to have "IgnoreWhitespace = true"
            using (XmlReader xmlReader = XmlReader.Create(stream, xmlrdr_settings))

After that everithing is fine.

Sure. Let me test it out and then I will revise the code. Thanks for testing it!