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 // doesn't move next
private object ParseListOrDict() private object ParseListOrDict()
{ {
@ -250,6 +253,10 @@ public class SaveParserEU4
if (value is null) if (value is null)
break; break;
// do dot add empty collections into list
if (IsEmptyCollection(value))
continue;
list.Add(value); list.Add(value);
} }
@ -326,6 +333,10 @@ public class SaveParserEU4
dict.Add(keyStr, list); dict.Add(keyStr, list);
} }
// do dot add empty collections into list
if (IsEmptyCollection(value))
continue;
list.Add(value); list.Add(value);
} }