Skip to content

Commit

Permalink
Fixed the remaining trim warning. Everything seems to be working fine…
Browse files Browse the repository at this point in the history
… for now.
  • Loading branch information
eduardobragaxz committed Dec 2, 2023
1 parent abdd2ac commit eb2adf6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Mastonet/BaseHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ protected async Task<string> PatchMedia(string route, IEnumerable<KeyValuePair<s
private static T TryDeserialize<T>(string json)
{
#if NET6_0_OR_GREATER

if (json[0] == '{')
{
var error = JsonSerializer.Deserialize(json, ErrorContext.Default.Error);
Expand All @@ -314,8 +315,10 @@ private static T TryDeserialize<T>(string json)
throw new ServerErrorException(error);
}
}
return JsonSerializer.Deserialize<T>(json, TryDeserializeContextOptions);

return (T?)JsonSerializer.Deserialize(json, typeof(T), TryDeserializeContext.Default)!;
#else

if (json[0] == '{')
{
var error = JsonSerializer.Deserialize<Error>(json);
Expand All @@ -326,13 +329,11 @@ private static T TryDeserialize<T>(string json)
}
}

return JsonSerializer.Deserialize<T>(json);
return JsonSerializer.Deserialize<T>(json)!;

#endif
}

private static readonly JsonSerializerOptions TryDeserializeContextOptions = new() { TypeInfoResolver = TryDeserializeContext.Default };

protected static string AddQueryStringParam(string queryParams, string queryStringParam, string? value)
{
// Empty parm? Exit
Expand Down

0 comments on commit eb2adf6

Please sign in to comment.