Closed frankinstien111 closed 8 months ago
The object lookup in the dictionary is by the hash returned by .net object, it probably to do with that.
But this is how the look-up is built in the ParseDictionary, it uses a counter to create the index:
` if (d.TryGetValue("$i", out tn)) { object v = null; _cirrev.TryGetValue((int)(long)tn, out v); return v; }
if (_circobj.TryGetValue(o, out circount) == false)
{
circount = _circobj.Count + 1;
_circobj.Add(o, circount);
_cirrev.Add(circount, o);
}
`
I was able to set up an environment where I'm not multi-threading and test just one root object serialization and deserialization after being modified with a complex nested class and it works. So, I will continue to troubleshoot this on my end of the code.
thx for your suggestions.
I take it back the serialization did not work in the non-threaded environment, sorry for the confusion.
Turns out you were right. I changed the overridden Gethashcode to use the base Gethashcode if the fields in the class were not initialized.
When an object is serialized it gets an index if the object is referenced to an identical instance. But when it deserializes the indexes don't match in the _cirrev dictionary. Example:
"GeneralizedType": { "$type": "6", "IsComposite": false, "Parent": { "$i": 27 }, "Key": "organic", "Numeral": 10, "Description": " ", "PofSp": "NN" }
When the $i is looked up it's pointing at the wrong data type, the actual data type index when deserializing is 25
Do you have any idea why that could happen?
Appreciate any help, thx.