internal static void CheckLegality(object obj, Dictionary<object, object> parents)
{
if(obj == null)
{
return;
}
var type = obj.GetType();
// containing type is a hint in case of
if(IsTypeIllegal(type))
{
var path = new StringBuilder();
var current = obj;
while(parents.ContainsKey(current))
{
path.Insert(0, " => ");
path.Insert(0, current.GetType().Name);
current = parents[current];
}
path.Insert(0, " => ");
path.Insert(0, current.GetType().Name);
throw new InvalidOperationException("Pointer or ThreadLocal or SpinLock encountered during serialization. The classes path that lead to it was: " + path);
}
}