Skip to content

Commit

Permalink
changed circular reference detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddio0141 committed Nov 17, 2023
1 parent f642757 commit 2ef5c93
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions UniTAS/Patcher/Utils/DebugHelp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ private static string PrintClass(object obj, ref int indent, List<object> foundR
return $"{initialIndent}null";
}

// circular reference
if (foundReferences.Contains(obj))
{
return $"{initialIndent}...";
}

var type = obj.GetType();
var str = $"{initialIndent}{type.Name} {{\n";
indent++;
Expand All @@ -47,13 +53,6 @@ private static string PrintClass(object obj, ref int indent, List<object> foundR

var value = field.GetValue(obj);

// circular reference
if (foundReferences.Contains(value))
{
str += "...,\n";
continue;
}

if (value is null)
{
str += "null,\n";
Expand All @@ -62,11 +61,6 @@ private static string PrintClass(object obj, ref int indent, List<object> foundR

var fieldType = field.FieldType;

if (fieldType.IsClass && fieldType != typeof(string))
{
foundReferences.Add(value);
}

// direct use cases
if (fieldType.IsPointer)
{
Expand Down

0 comments on commit 2ef5c93

Please sign in to comment.