Skip to content

Commit 85c7ba6

Browse files
committed
debugoutput logs and more yaml nullchecks
1 parent 13a357b commit 85c7ba6

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Source/AssetRipper.Assets/Export/Yaml/IYamlExportable.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ public static class YamlExportableExtensions
1212
{
1313
public static YamlNode ExportYaml(this IYamlExportable @this, IExportContainer container)
1414
{
15+
if (@this == null)
16+
{
17+
return null;
18+
}
1519
if (container.ExportFlags.IsRelease())
1620
{
1721
return @this.ExportYamlRelease(container);

Source/AssetRipper.Import/Structure/Assembly/Serializable/SerializableStructure.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,21 @@ internal SerializableStructure(SerializableType type, int depth)
2121
Fields = new SerializableField[type.FieldCount];
2222
}
2323

24+
private List<string> debugLines = new List<string>();
25+
2426
public void Read(ref EndianSpanReader reader, UnityVersion version, TransferInstructionFlags flags)
2527
{
28+
if (Depth == 0)
29+
{
30+
debugLines = new List<string>();
31+
}
32+
2633
for (int i = 0; i < Fields.Length; i++)
2734
{
2835
SerializableType.Field etalon = Type.GetField(i);
2936
if (IsAvailable(etalon))
3037
{
38+
debugLines.Add($"{Type.FullName} - reading {etalon.Name} ({reader.Position}/{reader.Length})");
3139
Fields[i].Read(ref reader, version, flags, Depth, etalon);
3240
}
3341
}
@@ -133,9 +141,10 @@ private void WriteDebug(ref EndianSpanReader reader)
133141
string name = Path.Combine("DebugOutputs", "MismatchedAsset_" + Type.Name);
134142
string fullName;
135143

136-
for (int i = 0; File.Exists(fullName = name + "_" + i); i++);
144+
for (int i = 0; File.Exists(fullName = name + "_" + i); i++) ;
137145

138146
File.WriteAllBytes(fullName, reader.ToArray());
147+
File.WriteAllLines(fullName + ".log", debugLines);
139148
}
140149

141150
private static void LogMonoBehaviourMismatch(SerializableStructure structure, int actual, int expected)

0 commit comments

Comments
 (0)