Skip to content

Commit

Permalink
chore: limit scope of result variable in newly introduce JsonConver…
Browse files Browse the repository at this point in the history
…ters (#569)

Co-authored-by: Konstantin <[email protected]>
  • Loading branch information
hf-kklein and Konstantin authored Oct 31, 2024
1 parent bad1f32 commit 609fd14
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ JsonSerializer serializer
return null;
}

var result = new BO4E.COM.Verwendungszweck
{
Marktrolle = ENUM.Marktrolle.LF,
Zweck = new List<ENUM.Verwendungszweck>(),
};
if (reader.TokenType == JsonToken.String)
{
var result = new BO4E.COM.Verwendungszweck
{
Marktrolle = ENUM.Marktrolle.LF,
Zweck = new List<ENUM.Verwendungszweck>(),
};
var stringValue = (string)reader.Value!;
// we don't want to interfere or re-add the famous and beloved NewtonsoftVerwendungszweckStringEnumConverter
stringValue = stringValue.Replace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ JsonSerializerOptions options
{
return null;
}

var result = new Verwendungszweck
{
Marktrolle = ENUM.Marktrolle.LF,
Zweck = new List<ENUM.Verwendungszweck>(),
};

if (reader.TokenType == JsonTokenType.String)
{
var result = new Verwendungszweck
{
Marktrolle = ENUM.Marktrolle.LF,
Zweck = new List<ENUM.Verwendungszweck>(),
};
string stringValue = reader.GetString()!;

// Adjust the string as per the Newtonsoft version
Expand Down

0 comments on commit 609fd14

Please sign in to comment.