do dot add empty collections into list

This commit is contained in:
Timerix 2025-04-06 00:37:12 +05:00
parent 1efd50210c
commit a8c4361512

View File

@ -215,6 +215,9 @@ public class SaveParserEU4
}
}
private static bool IsEmptyCollection(object value)
=> value is Dictionary<string, List<object>> { Count: 0 } or List<object> { Count: 0 };
// doesn't move next
private object ParseListOrDict()
{
@ -249,6 +252,10 @@ public class SaveParserEU4
_searchExprCurrent = searchExprPrev;
if (value is null)
break;
// do dot add empty collections into list
if (IsEmptyCollection(value))
continue;
list.Add(value);
}
@ -326,6 +333,10 @@ public class SaveParserEU4
dict.Add(keyStr, list);
}
// do dot add empty collections into list
if (IsEmptyCollection(value))
continue;
list.Add(value);
}