Skip to content

Commit ad8437a

Browse files
committed
Fix typeFilter edge cases: normalize whitespace input and hoist GetTypeTreeRoot call
Made-with: Cursor
1 parent 5a14048 commit ad8437a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

TextDumper/TextDumperTool.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ public class TextDumperTool
1616

1717
public int Dump(string path, string outputPath, bool skipLargeArrays, long objectId = 0, string typeFilter = null)
1818
{
19+
if (string.IsNullOrWhiteSpace(typeFilter))
20+
typeFilter = null;
21+
1922
m_SkipLargeArrays = skipLargeArrays;
2023

2124
try
@@ -402,6 +405,8 @@ void OutputSerializedFile(string path, long objectId, string typeFilter)
402405
if (objectId != 0 && obj.Id != objectId)
403406
continue;
404407

408+
var root = m_SerializedFile.GetTypeTreeRoot(obj.Id);
409+
405410
if (typeFilter != null)
406411
{
407412
if (filterByTypeId)
@@ -415,13 +420,12 @@ void OutputSerializedFile(string path, long objectId, string typeFilter)
415420
// GetTypeName returns the id as a string when the type is unknown;
416421
// fall back to the TypeTree root node for script types.
417422
if (typeName == obj.TypeId.ToString())
418-
typeName = m_SerializedFile.GetTypeTreeRoot(obj.Id).Type;
423+
typeName = root.Type;
419424
if (!string.Equals(typeName, typeFilter, StringComparison.OrdinalIgnoreCase))
420425
continue;
421426
}
422427
}
423428

424-
var root = m_SerializedFile.GetTypeTreeRoot(obj.Id);
425429
var offset = obj.Offset;
426430

427431
m_Writer.Write($"ID: {obj.Id} (ClassID: {obj.TypeId}) ");

0 commit comments

Comments
 (0)