Serialization class that inherits from IList, ICollection with additional properties
See original GitHub issueHello again!
In the last few days I worked very intensive with XML serializing. For my Tests I used the default XmlSerializer and the ExtendedXmlSerialize to be able to compare the advantages and disadvantages of both. By my Tests I noticed two issues of the ExtendedXmlSerializer, which I want to tell you.
- when a class derives from Collections, the ExtendedXmlSerializer is not able to serialize it. Then a NullReferences Exception will be thrown.
Example class: public class ListOfTest : List<Test> { public string name { get; set; } }
The default XmlSerializer can do this, but there are also some Problems with it: -) List<T> only works when T is not an Interface -) only the List get serialized and deserialized, all other Properties don’t. (from example the property “name” would not get serialized)
- if a Property has the Datatype “object” the ExtendedXmlSerializer serialize it, but is not able to deserialize it. After deserializing the XML all Properties which have the Datatype “object”, would have the string “System.Object” as value.
Example: public class Test { public object testProperty { get; set; } }
TestData: Test t = new Test() { testProperty = 1234; } Test t2 = new Test() { testProperty = “name”; }
Xml-Output would look like this:
<?xml version="1.0" encoding="utf-8"?>
<Test>
<testProperty>
1234
</testProperty>
</Test>
<Test>
<testProperty>
name
</testProperty>
</Test>
TestData after deserialize: t.testProperty == “System.Object”; t2.testProperty == “System.Object”;
I hope this information will help you by bugfixing and by upgrading the ExtendedXmlSerializer.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top GitHub Comments
Properties need to have set accesory. In your case try: public Collection<ITask> Tasks { get; set; } = new Collection<ITask>(); }
Yes, this should be fixed now. I just need to wire it up. 😃