I'm using YAXLib to serialize my objects, I find the following bug in the YAXLib source code:
If I try to serialize a dictionary that contains a null value I got a unhandled nullReference
exception.
Dictionary<string, object> Dict= new Dictionary<string, object>();
Dict.Add("foo", null);
YAXSerializer serializer = new YAXSerializer(typeof (Dictionary<string, object>));
serializer.SerializeToFile(Dict, "path"); // << CRASH
Running deep in YAXSerializer.cs I found the following code:
foreach (object obj in dicInst) //dicInst is the Dict variable defined above
{
...
// valueObj is null
XElement addedElem = AddObjectToElement(elemChild, valueAlias, valueObj);
...
}
private XElement AddObjectToElement(XElement elem, XName alias, object obj)
{
//obj is null and so obj.GetType() crash
UdtWrapper udt = TypeWrappersPool.Pool.GetTypeWrapper(obj.GetType(), this);
...
}
Some of you faced the same problem? Is there a way to solve it?