Compare commits

..

12 Commits

Author SHA1 Message Date
Jonas Dellinger
46be74abd0 fix build: switch from hub to gh cli 2023-11-03 23:52:20 +01:00
Jonas Dellinger
94b2978126 chore: also ignore outdated SDK in tests 2023-11-03 23:41:49 +01:00
Jonas Dellinger
c5be9e4bd5 fix docs: specify lock file for caching 2023-11-03 23:39:14 +01:00
Jonas Dellinger
35b13341e6 fix docs: re-order pnpm setup action 2023-11-03 23:37:11 +01:00
Jonas Dellinger
d9bf33632b fix docs: update actions 2023-11-03 23:36:08 +01:00
Jonas Dellinger
a777f759e9 fix docs: update actions, explicitly run deploy pnpm script 2023-11-03 23:34:06 +01:00
Jonas Dellinger
a2f434968a fix build: setup pnpm, update image tags and ignore out of date warning for SDK versions 2023-11-03 23:31:40 +01:00
Jonas Dellinger
74a0f266b7 fix build: remove wrong sdk version 2023-11-03 23:26:45 +01:00
Jonas Dellinger
c5400fc937 re-add .net standard 2.0 support 2023-11-03 23:23:54 +01:00
Jonas Dellinger
4aea443038 use recommendations for latest .NET versions 2023-11-03 22:57:55 +01:00
Jonas Dellinger
16d898b344 add cancellationToken to another override of PaginateAll 2023-11-03 22:50:45 +01:00
Jonas Dellinger
21d9a5ff16 switch to pnpm and update packages 2023-11-03 22:43:54 +01:00
21 changed files with 9739 additions and 8046 deletions

View File

@ -9,14 +9,14 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v4
- uses: actions/setup-dotnet@v1 - uses: actions/setup-dotnet@v3
with: with:
dotnet-version: "5.x" dotnet-version: "5.x"
- uses: actions/setup-dotnet@v1 - uses: actions/setup-dotnet@v3
with: with:
dotnet-version: "6.x" dotnet-version: "6.x"
- uses: actions/setup-dotnet@v1 - uses: actions/setup-dotnet@v3
with: with:
dotnet-version: "7.0.203" dotnet-version: "7.0.203"
- name: Set RELEASE_VERSION - name: Set RELEASE_VERSION
@ -49,25 +49,28 @@ jobs:
- name: Upload to GH Release - name: Upload to GH Release
if: startsWith( github.ref, 'refs/tags/') if: startsWith( github.ref, 'refs/tags/')
run: | run: |
zip -j SpotifyAPI.Web-netstandard2.0.zip SpotifyAPI.Web/bin/Release/netstandard2.0/*
zip -j SpotifyAPI.Web-netstandard2.1.zip SpotifyAPI.Web/bin/Release/netstandard2.1/* zip -j SpotifyAPI.Web-netstandard2.1.zip SpotifyAPI.Web/bin/Release/netstandard2.1/*
zip -j SpotifyAPI.Web-net5.0.zip SpotifyAPI.Web/bin/Release/net5.0/* zip -j SpotifyAPI.Web-net5.0.zip SpotifyAPI.Web/bin/Release/net5.0/*
zip -j SpotifyAPI.Web-net6.0.zip SpotifyAPI.Web/bin/Release/net6.0/* zip -j SpotifyAPI.Web-net6.0.zip SpotifyAPI.Web/bin/Release/net6.0/*
zip -j SpotifyAPI.Web-net7.0.zip SpotifyAPI.Web/bin/Release/net7.0/* zip -j SpotifyAPI.Web-net7.0.zip SpotifyAPI.Web/bin/Release/net7.0/*
zip -j SpotifyAPI.Web.Auth-netstandard2.0.zip SpotifyAPI.Web.Auth/bin/Release/netstandard2.0/*
zip -j SpotifyAPI.Web.Auth-netstandard2.1.zip SpotifyAPI.Web.Auth/bin/Release/netstandard2.1/* zip -j SpotifyAPI.Web.Auth-netstandard2.1.zip SpotifyAPI.Web.Auth/bin/Release/netstandard2.1/*
zip -j SpotifyAPI.Web.Auth-net5.0.zip SpotifyAPI.Web.Auth/bin/Release/net5.0/* zip -j SpotifyAPI.Web.Auth-net5.0.zip SpotifyAPI.Web.Auth/bin/Release/net5.0/*
zip -j SpotifyAPI.Web.Auth-net6.0.zip SpotifyAPI.Web.Auth/bin/Release/net6.0/* zip -j SpotifyAPI.Web.Auth-net6.0.zip SpotifyAPI.Web.Auth/bin/Release/net6.0/*
zip -j SpotifyAPI.Web.Auth-net7.0.zip SpotifyAPI.Web.Auth/bin/Release/net7.0/* zip -j SpotifyAPI.Web.Auth-net7.0.zip SpotifyAPI.Web.Auth/bin/Release/net7.0/*
hub release edit \ gh release upload "$RELEASE_VERSION" \
-a "SpotifyAPI.Web-netstandard2.1.zip" \ "SpotifyAPI.Web-netstandard2.0.zip" \
-a "SpotifyAPI.Web-net5.0.zip" \ "SpotifyAPI.Web-netstandard2.1.zip" \
-a "SpotifyAPI.Web-net6.0.zip" \ "SpotifyAPI.Web-net5.0.zip" \
-a "SpotifyAPI.Web-net7.0.zip" \ "SpotifyAPI.Web-net6.0.zip" \
-a "SpotifyAPI.Web.Auth-netstandard2.1.zip" \ "SpotifyAPI.Web-net7.0.zip" \
-a "SpotifyAPI.Web.Auth-net5.0.zip" \ "SpotifyAPI.Web.Auth-netstandard2.0.zip" \
-a "SpotifyAPI.Web.Auth-net6.0.zip" \ "SpotifyAPI.Web.Auth-netstandard2.1.zip" \
-a "SpotifyAPI.Web.Auth-net7.0.zip" \ "SpotifyAPI.Web.Auth-net5.0.zip" \
-m "" "$RELEASE_VERSION" "SpotifyAPI.Web.Auth-net6.0.zip" \
"SpotifyAPI.Web.Auth-net7.0.zip"
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -10,11 +10,17 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v4
- name: Use Node.JS - uses: pnpm/action-setup@v2
uses: actions/setup-node@v1
with: with:
node-version: 18.12.1 version: 8
- name: Use Node.JS
uses: actions/setup-node@v3
with:
node-version: v20.9.0
cache: "pnpm"
cache-dependency-path: |
SpotifyAPI.Docs/pnpm-lock.yaml
- name: Setup GitHub Deploy SSH Key - name: Setup GitHub Deploy SSH Key
uses: webfactory/ssh-agent@v0.4.1 uses: webfactory/ssh-agent@v0.4.1
with: with:

View File

@ -5,13 +5,13 @@ This website is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern
### Installation ### Installation
``` ```
$ yarn $ pnpm
``` ```
### Local Development ### Local Development
``` ```
$ yarn start $ pnpm start
``` ```
This command starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server. This command starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server.
@ -19,7 +19,7 @@ This command starts a local development server and open up a browser window. Mos
### Build ### Build
``` ```
$ yarn build $ pnpm build
``` ```
This command generates static content into the `build` directory and can be served using any static contents hosting service. This command generates static content into the `build` directory and can be served using any static contents hosting service.
@ -27,7 +27,7 @@ This command generates static content into the `build` directory and can be serv
### Deployment ### Deployment
``` ```
$ GIT_USER=<Your GitHub username> USE_SSH=true yarn deploy $ GIT_USER=<Your GitHub username> USE_SSH=true pnpm deploy
``` ```
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.

View File

@ -8,5 +8,5 @@ git config --global user.email "jonas@dellinger.dev"
git config --global user.name "GH Actions Docs Builder" git config --global user.name "GH Actions Docs Builder"
cd ./SpotifyAPI.Docs cd ./SpotifyAPI.Docs
yarn pnpm i --frozen-lockfile
USE_SSH=true GIT_USER=JohnnyCrazy yarn deploy USE_SSH=true GIT_USER=JohnnyCrazy pnpm run deploy

View File

@ -14,11 +14,12 @@
} }
}, },
"dependencies": { "dependencies": {
"@docusaurus/core": "^2.4.1", "@docusaurus/core": "^3.0.0",
"@docusaurus/preset-classic": "^2.4.1", "@docusaurus/preset-classic": "^3.0.0",
"@mdx-js/react": "^3.0.0",
"classnames": "^2.3.1", "classnames": "^2.3.1",
"react": "^17.0.2", "react": "^18.2.0",
"react-dom": "^17.0.2", "react-dom": "^18.2.0",
"react-github-btn": "^1.2.0" "react-github-btn": "^1.2.0"
}, },
"browserslist": { "browserslist": {
@ -35,7 +36,7 @@
}, },
"devDependencies": { "devDependencies": {
"import-sort-style-module": "^6.0.0", "import-sort-style-module": "^6.0.0",
"prettier": "^2.8.8", "prettier": "^3.0.3",
"prettier-plugin-import-sort": "^0.0.7" "prettier-plugin-import-sort": "^0.0.7"
} }
} }

9635
SpotifyAPI.Docs/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,12 @@
{ {
"version-5.1.1/someSidebar": [ "someSidebar": [
{ {
"type": "category", "type": "category",
"label": "SpotifyAPI-NET", "label": "SpotifyAPI-NET",
"items": [ "items": [
{ {
"type": "doc", "type": "doc",
"id": "version-5.1.1/home" "id": "home"
} }
] ]
}, },
@ -16,59 +16,59 @@
"items": [ "items": [
{ {
"type": "doc", "type": "doc",
"id": "version-5.1.1/web/getting_started" "id": "web/getting_started"
}, },
{ {
"type": "doc", "type": "doc",
"id": "version-5.1.1/web/albums" "id": "web/albums"
}, },
{ {
"type": "doc", "type": "doc",
"id": "version-5.1.1/web/artists" "id": "web/artists"
}, },
{ {
"type": "doc", "type": "doc",
"id": "version-5.1.1/web/browse" "id": "web/browse"
}, },
{ {
"type": "doc", "type": "doc",
"id": "version-5.1.1/web/follow" "id": "web/follow"
}, },
{ {
"type": "doc", "type": "doc",
"id": "version-5.1.1/web/library" "id": "web/library"
}, },
{ {
"type": "doc", "type": "doc",
"id": "version-5.1.1/web/personalization" "id": "web/personalization"
}, },
{ {
"type": "doc", "type": "doc",
"id": "version-5.1.1/web/player" "id": "web/player"
}, },
{ {
"type": "doc", "type": "doc",
"id": "version-5.1.1/web/playlists" "id": "web/playlists"
}, },
{ {
"type": "doc", "type": "doc",
"id": "version-5.1.1/web/profiles" "id": "web/profiles"
}, },
{ {
"type": "doc", "type": "doc",
"id": "version-5.1.1/web/proxy" "id": "web/proxy"
}, },
{ {
"type": "doc", "type": "doc",
"id": "version-5.1.1/web/search" "id": "web/search"
}, },
{ {
"type": "doc", "type": "doc",
"id": "version-5.1.1/web/tracks" "id": "web/tracks"
}, },
{ {
"type": "doc", "type": "doc",
"id": "version-5.1.1/web/utilities" "id": "web/utilities"
} }
] ]
}, },
@ -78,23 +78,23 @@
"items": [ "items": [
{ {
"type": "doc", "type": "doc",
"id": "version-5.1.1/auth/getting_started" "id": "auth/getting_started"
}, },
{ {
"type": "doc", "type": "doc",
"id": "version-5.1.1/auth/implicit_grant" "id": "auth/implicit_grant"
}, },
{ {
"type": "doc", "type": "doc",
"id": "version-5.1.1/auth/authorization_code" "id": "auth/authorization_code"
}, },
{ {
"type": "doc", "type": "doc",
"id": "version-5.1.1/auth/client_credentials" "id": "auth/client_credentials"
}, },
{ {
"type": "doc", "type": "doc",
"id": "version-5.1.1/auth/token_swap" "id": "auth/token_swap"
} }
] ]
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net7.0;net6.0;net5.0;netstandard2.1</TargetFrameworks> <TargetFrameworks>net7.0;net6.0;net5.0;netstandard2.1;netstandard2.0</TargetFrameworks>
<LangVersion>9.0</LangVersion> <LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<PackageId>SpotifyAPI.Web.Auth</PackageId> <PackageId>SpotifyAPI.Web.Auth</PackageId>
@ -23,6 +23,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<EmbedUntrackedSources>true</EmbedUntrackedSources> <EmbedUntrackedSources>true</EmbedUntrackedSources>
<NoWarn>1591</NoWarn> <NoWarn>1591</NoWarn>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(APPVEYOR)' == 'true'"> <PropertyGroup Condition="'$(APPVEYOR)' == 'true'">

View File

@ -4,6 +4,7 @@
<TargetFrameworks>net7.0;net6.0;net5.0</TargetFrameworks> <TargetFrameworks>net7.0;net6.0;net5.0</TargetFrameworks>
<LangVersion>9.0</LangVersion> <LangVersion>9.0</LangVersion>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -42,6 +42,7 @@ namespace SpotifyAPI.Web
CancellationToken cancel = default CancellationToken cancel = default
); );
#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
/// <summary> /// <summary>
/// Fetches all pages and returns one by one using IAsyncEnumerable /// Fetches all pages and returns one by one using IAsyncEnumerable
/// </summary> /// </summary>
@ -71,5 +72,6 @@ namespace SpotifyAPI.Web
IAPIConnector connector, IAPIConnector connector,
CancellationToken cancel = default CancellationToken cancel = default
); );
#endif
} }
} }

View File

@ -120,15 +120,18 @@ namespace SpotifyAPI.Web
/// <param name="firstPage">A first page, will be included in the output list!</param> /// <param name="firstPage">A first page, will be included in the output list!</param>
/// <param name="mapper">A function which maps response objects to the next paging object</param> /// <param name="mapper">A function which maps response objects to the next paging object</param>
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param> /// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
/// <param name="cancellationToken">The cancellation-token to allow to cancel the request.</param>
/// <typeparam name="T">The Paging-Type</typeparam> /// <typeparam name="T">The Paging-Type</typeparam>
/// <typeparam name="TNext">The Response-Type</typeparam> /// <typeparam name="TNext">The Response-Type</typeparam>
/// <returns>A list containing all fetched pages</returns> /// <returns>A list containing all fetched pages</returns>
Task<IList<T>> PaginateAll<T, TNext>( Task<IList<T>> PaginateAll<T, TNext>(
IPaginatable<T, TNext> firstPage, IPaginatable<T, TNext> firstPage,
Func<TNext, IPaginatable<T, TNext>> mapper, Func<TNext, IPaginatable<T, TNext>> mapper,
IPaginator? paginator = default! IPaginator? paginator = default!,
CancellationToken cancellationToken = default!
); );
#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
/// <summary> /// <summary>
/// Paginate through pages by using IAsyncEnumerable, introduced in C# 8 /// Paginate through pages by using IAsyncEnumerable, introduced in C# 8
/// The default paginator will fetch all available resources without a delay between requests. /// The default paginator will fetch all available resources without a delay between requests.
@ -142,7 +145,7 @@ namespace SpotifyAPI.Web
IAsyncEnumerable<T> Paginate<T>( IAsyncEnumerable<T> Paginate<T>(
IPaginatable<T> firstPage, IPaginatable<T> firstPage,
IPaginator? paginator = default!, IPaginator? paginator = default!,
CancellationToken cancel = default! CancellationToken cancel = default
); );
/// <summary> /// <summary>
@ -165,6 +168,7 @@ namespace SpotifyAPI.Web
IPaginator? paginator = default!, IPaginator? paginator = default!,
CancellationToken cancel = default! CancellationToken cancel = default!
); );
#endif
public Task<Paging<T>> NextPage<T>(Paging<T> paging); public Task<Paging<T>> NextPage<T>(Paging<T> paging);

View File

@ -69,6 +69,7 @@ namespace SpotifyAPI.Web
return results; return results;
} }
#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
public async IAsyncEnumerable<T> Paginate<T>( public async IAsyncEnumerable<T> Paginate<T>(
IPaginatable<T> firstPage, IPaginatable<T> firstPage,
IAPIConnector connector, IAPIConnector connector,
@ -125,5 +126,6 @@ namespace SpotifyAPI.Web
} }
} }
} }
#endif
} }
} }

View File

@ -109,16 +109,18 @@ namespace SpotifyAPI.Web
/// <param name="firstPage">A first page, will be included in the output list!</param> /// <param name="firstPage">A first page, will be included in the output list!</param>
/// <param name="mapper">A function which maps response objects to the next paging object</param> /// <param name="mapper">A function which maps response objects to the next paging object</param>
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param> /// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
/// <param name="cancellationToken">The cancellation-token to allow to cancel the request.</param>
/// <typeparam name="T">The Paging-Type</typeparam> /// <typeparam name="T">The Paging-Type</typeparam>
/// <typeparam name="TNext">The Response-Type</typeparam> /// <typeparam name="TNext">The Response-Type</typeparam>
/// <returns>A list containing all fetched pages</returns> /// <returns>A list containing all fetched pages</returns>
public Task<IList<T>> PaginateAll<T, TNext>( public Task<IList<T>> PaginateAll<T, TNext>(
IPaginatable<T, TNext> firstPage, IPaginatable<T, TNext> firstPage,
Func<TNext, IPaginatable<T, TNext>> mapper, Func<TNext, IPaginatable<T, TNext>> mapper,
IPaginator? paginator = null IPaginator? paginator = null,
CancellationToken cancellationToken = default
) )
{ {
return (paginator ?? DefaultPaginator).PaginateAll(firstPage, mapper, _apiConnector); return (paginator ?? DefaultPaginator).PaginateAll(firstPage, mapper, _apiConnector, cancellationToken);
} }
private Task<T> FetchPage<T>(string? nextUrl) private Task<T> FetchPage<T>(string? nextUrl)
@ -194,7 +196,7 @@ namespace SpotifyAPI.Web
return FetchPage<TNext>(paging.Previous); return FetchPage<TNext>(paging.Previous);
} }
#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
/// <summary> /// <summary>
/// Paginate through pages by using IAsyncEnumerable, introduced in C# 8 /// Paginate through pages by using IAsyncEnumerable, introduced in C# 8
/// The default paginator will fetch all available resources without a delay between requests. /// The default paginator will fetch all available resources without a delay between requests.
@ -301,5 +303,6 @@ namespace SpotifyAPI.Web
yield return item; yield return item;
} }
} }
#endif
} }
} }

View File

@ -221,7 +221,11 @@ namespace SpotifyAPI.Web.Http
{ {
if (_authenticator != null if (_authenticator != null
&& !request.Endpoint.IsAbsoluteUri && !request.Endpoint.IsAbsoluteUri
#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
|| request.Endpoint.AbsoluteUri.Contains("https://api.spotify.com", StringComparison.InvariantCulture)) || request.Endpoint.AbsoluteUri.Contains("https://api.spotify.com", StringComparison.InvariantCulture))
#else
|| request.Endpoint.AbsoluteUri.Contains("https://api.spotify.com"))
#endif
{ {
await _authenticator!.Apply(request, this).ConfigureAwait(false); await _authenticator!.Apply(request, this).ConfigureAwait(false);
} }

View File

@ -50,10 +50,10 @@ namespace SpotifyAPI.Web.Http
// We only support text stuff for now // We only support text stuff for now
using var content = responseMsg.Content; using var content = responseMsg.Content;
var headers = responseMsg.Headers.ToDictionary(header => header.Key, header => header.Value.First()); var headers = responseMsg.Headers.ToDictionary(header => header.Key, header => header.Value.First());
#if NETSTANDARD2_1 #if NET5_0_OR_GREATER
var body = await responseMsg.Content.ReadAsStringAsync().ConfigureAwait(false);
#else
var body = await responseMsg.Content.ReadAsStringAsync(cancel).ConfigureAwait(false); var body = await responseMsg.Content.ReadAsStringAsync(cancel).ConfigureAwait(false);
#else
var body = await responseMsg.Content.ReadAsStringAsync().ConfigureAwait(false);
#endif #endif
var contentType = content.Headers?.ContentType?.MediaType; var contentType = content.Headers?.ContentType?.MediaType;

View File

@ -7,7 +7,6 @@ namespace SpotifyAPI.Web.Http
{ {
private const string OnRequestFormat = "\n{0} {1} [{2}] {3}"; private const string OnRequestFormat = "\n{0} {1} [{2}] {3}";
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303")]
public void OnRequest(IRequest request) public void OnRequest(IRequest request)
{ {
Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(request, nameof(request));
@ -23,12 +22,14 @@ namespace SpotifyAPI.Web.Http
Console.WriteLine(OnRequestFormat, request.Method, request.Endpoint, parameters, request.Body); Console.WriteLine(OnRequestFormat, request.Method, request.Endpoint, parameters, request.Body);
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303")]
public void OnResponse(IResponse response) public void OnResponse(IResponse response)
{ {
Ensure.ArgumentNotNull(response, nameof(response)); Ensure.ArgumentNotNull(response, nameof(response));
#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
string? body = response.Body?.ToString()?.Replace("\n", "", StringComparison.InvariantCulture); string? body = response.Body?.ToString()?.Replace("\n", "", StringComparison.InvariantCulture);
#else
string? body = response.Body?.ToString()?.Replace("\n", "");
#endif
body = body?.Substring(0, Math.Min(50, body.Length)); body = body?.Substring(0, Math.Min(50, body.Length));
Console.WriteLine("--> {0} {1} {2}\n", response.StatusCode, response.ContentType, body); Console.WriteLine("--> {0} {1} {2}\n", response.StatusCode, response.ContentType, body);
} }

View File

@ -21,9 +21,9 @@ namespace SpotifyAPI.Web
var body = new JObject(); var body = new JObject();
var type = GetType(); 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); AddBodyParam(body, info, attribute);
} }
@ -70,9 +70,9 @@ namespace SpotifyAPI.Web
var queryParams = new Dictionary<string, string>(); var queryParams = new Dictionary<string, string>();
var type = GetType(); 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); AddQueryParam(queryParams, info, attribute);
} }

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net7.0;net6.0;net5.0;netstandard2.1</TargetFrameworks> <TargetFrameworks>net7.0;net6.0;net5.0;netstandard2.1;netstandard2.0</TargetFrameworks>
<LangVersion>9.0</LangVersion> <LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<PackageId>SpotifyAPI.Web</PackageId> <PackageId>SpotifyAPI.Web</PackageId>
@ -24,6 +24,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<EmbedUntrackedSources>true</EmbedUntrackedSources> <EmbedUntrackedSources>true</EmbedUntrackedSources>
<NoWarn>1591</NoWarn> <NoWarn>1591</NoWarn>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'"> <PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">

View File

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

View File

@ -15,7 +15,11 @@ namespace SpotifyAPI.Web
public string Value { get; } public string Value { get; }
#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
public static bool GetValue(Type enumType, Enum enumValue, [NotNullWhen(true)] out string? result) public static bool GetValue(Type enumType, Enum enumValue, [NotNullWhen(true)] out string? result)
#else
public static bool GetValue(Type enumType, Enum enumValue, out string? result)
#endif
{ {
Ensure.ArgumentNotNull(enumType, nameof(enumType)); Ensure.ArgumentNotNull(enumType, nameof(enumType));
Ensure.ArgumentNotNull(enumValue, nameof(enumValue)); Ensure.ArgumentNotNull(enumValue, nameof(enumValue));