From ea3a4b52ebeb219c3fa35f3337add2e23fc2ab2f Mon Sep 17 00:00:00 2001 From: konstantin Date: Wed, 15 Jan 2025 17:05:56 +0100 Subject: [PATCH] fix: temporarily remove converter, even if it's not the same instance (#642) avoids stackoverflow exceptions Co-authored-by: Konstantin --- .../LenientSystemTextJsonEnumListConverter.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/BO4E/meta/LenientConverters/LenientSystemTextJsonEnumListConverter.cs b/BO4E/meta/LenientConverters/LenientSystemTextJsonEnumListConverter.cs index cdc8fffd..b5211b90 100644 --- a/BO4E/meta/LenientConverters/LenientSystemTextJsonEnumListConverter.cs +++ b/BO4E/meta/LenientConverters/LenientSystemTextJsonEnumListConverter.cs @@ -145,6 +145,19 @@ JsonSerializerOptions options // avoid stack overflow/infinity recursion optionsWithoutThisConverter.Converters.Remove(this); } + + if ( + optionsWithoutThisConverter.Converters.FirstOrDefault(c => + c.GetType() + == typeof(LenientSystemTextJsonEnumListConverter) + ) is + { } sameTypeConverter + ) + { + optionsWithoutThisConverter.Converters.Remove( + sameTypeConverter + ); + } var helperJsonList = "[" + element.GetRawText() + "]"; var subResultList = System.Text.Json.JsonSerializer.Deserialize( helperJsonList,