diff --git a/SpotifyAPI.Web/Models/Request/RequestParams.cs b/SpotifyAPI.Web/Models/Request/RequestParams.cs index 4a34c85e..d12622ed 100644 --- a/SpotifyAPI.Web/Models/Request/RequestParams.cs +++ b/SpotifyAPI.Web/Models/Request/RequestParams.cs @@ -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(); 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); } diff --git a/SpotifyAPI.Web/Util/PKCEUtil.cs b/SpotifyAPI.Web/Util/PKCEUtil.cs index 02eec991..8611ce2c 100644 --- a/SpotifyAPI.Web/Util/PKCEUtil.cs +++ b/SpotifyAPI.Web/Util/PKCEUtil.cs @@ -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 } } }