From 4aea443038bd4e191b0fd77ef59798f7f580f579 Mon Sep 17 00:00:00 2001 From: Jonas Dellinger Date: Fri, 3 Nov 2023 22:57:55 +0100 Subject: [PATCH] use recommendations for latest .NET versions --- SpotifyAPI.Web/Models/Request/RequestParams.cs | 8 ++++---- SpotifyAPI.Web/Util/PKCEUtil.cs | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) 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 } } }