use recommendations for latest .NET versions

This commit is contained in:
Jonas Dellinger 2023-11-03 22:57:55 +01:00
parent 16d898b344
commit 4aea443038
2 changed files with 8 additions and 4 deletions

View File

@ -21,9 +21,9 @@ namespace SpotifyAPI.Web
var body = new JObject();
var type = GetType();
if (!_bodyParamsCache.IsEmpty && _bodyParamsCache.ContainsKey(type))
if (!_bodyParamsCache.IsEmpty && _bodyParamsCache.TryGetValue(type, out var bodyParamsCached))
{
foreach (var (info, attribute) in _bodyParamsCache[type])
foreach (var (info, attribute) in bodyParamsCached)
{
AddBodyParam(body, info, attribute);
}
@ -70,9 +70,9 @@ namespace SpotifyAPI.Web
var queryParams = new Dictionary<string, string>();
var type = GetType();
if (!_queryParamsCache.IsEmpty && _queryParamsCache.ContainsKey(type))
if (!_queryParamsCache.IsEmpty && _queryParamsCache.TryGetValue(type, out var queryParamsCached))
{
foreach (var (info, attribute) in _queryParamsCache[type])
foreach (var (info, attribute) in queryParamsCached)
{
AddQueryParam(queryParams, info, attribute);
}

View File

@ -63,8 +63,12 @@ namespace SpotifyAPI.Web
private static byte[] ComputeSHA256(string value)
{
#if NETSTANDARD2_1_OR_GREATER
using var hash = SHA256.Create();
return hash.ComputeHash(Encoding.UTF8.GetBytes(value));
#else
return SHA256.HashData(Encoding.UTF8.GetBytes(value));
#endif
}
}
}