From a8c4361512cd44c5ce6e966f219515be4e1fd19d Mon Sep 17 00:00:00 2001 From: Timerix Date: Sun, 6 Apr 2025 00:37:12 +0500 Subject: [PATCH] do dot add empty collections into list --- ParadoxSaveParser.Lib/SaveParserEU4.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ParadoxSaveParser.Lib/SaveParserEU4.cs b/ParadoxSaveParser.Lib/SaveParserEU4.cs index 005f262..899f67d 100644 --- a/ParadoxSaveParser.Lib/SaveParserEU4.cs +++ b/ParadoxSaveParser.Lib/SaveParserEU4.cs @@ -215,6 +215,9 @@ public class SaveParserEU4 } } + private static bool IsEmptyCollection(object value) + => value is Dictionary> { Count: 0 } or List { 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); }