Skip to content

Commit c5400fc

Browse files
committed
re-add .net standard 2.0 support
1 parent 4aea443 commit c5400fc

12 files changed

Lines changed: 35 additions & 12 deletions

File tree

‎.github/workflows/cicd.yaml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ jobs:
1010
steps:
1111
- name: Checkout
1212
uses: actions/checkout@v2
13+
- uses: actions/setup-dotnet@v1
14+
with:
15+
dotnet-version: "4.8.1"
1316
- uses: actions/setup-dotnet@v1
1417
with:
1518
dotnet-version: "5.x"
@@ -49,21 +52,25 @@ jobs:
4952
- name: Upload to GH Release
5053
if: startsWith( github.ref, 'refs/tags/')
5154
run: |
55+
zip -j SpotifyAPI.Web-netstandard2.0.zip SpotifyAPI.Web/bin/Release/netstandard2.0/*
5256
zip -j SpotifyAPI.Web-netstandard2.1.zip SpotifyAPI.Web/bin/Release/netstandard2.1/*
5357
zip -j SpotifyAPI.Web-net5.0.zip SpotifyAPI.Web/bin/Release/net5.0/*
5458
zip -j SpotifyAPI.Web-net6.0.zip SpotifyAPI.Web/bin/Release/net6.0/*
5559
zip -j SpotifyAPI.Web-net7.0.zip SpotifyAPI.Web/bin/Release/net7.0/*
5660
61+
zip -j SpotifyAPI.Web.Auth-netstandard2.0.zip SpotifyAPI.Web.Auth/bin/Release/netstandard2.0/*
5762
zip -j SpotifyAPI.Web.Auth-netstandard2.1.zip SpotifyAPI.Web.Auth/bin/Release/netstandard2.1/*
5863
zip -j SpotifyAPI.Web.Auth-net5.0.zip SpotifyAPI.Web.Auth/bin/Release/net5.0/*
5964
zip -j SpotifyAPI.Web.Auth-net6.0.zip SpotifyAPI.Web.Auth/bin/Release/net6.0/*
6065
zip -j SpotifyAPI.Web.Auth-net7.0.zip SpotifyAPI.Web.Auth/bin/Release/net7.0/*
6166
6267
hub release edit \
68+
-a "SpotifyAPI.Web-netstandard2.0.zip" \
6369
-a "SpotifyAPI.Web-netstandard2.1.zip" \
6470
-a "SpotifyAPI.Web-net5.0.zip" \
6571
-a "SpotifyAPI.Web-net6.0.zip" \
6672
-a "SpotifyAPI.Web-net7.0.zip" \
73+
-a "SpotifyAPI.Web.Auth-netstandard2.0.zip" \
6774
-a "SpotifyAPI.Web.Auth-netstandard2.1.zip" \
6875
-a "SpotifyAPI.Web.Auth-net5.0.zip" \
6976
-a "SpotifyAPI.Web.Auth-net6.0.zip" \

‎SpotifyAPI.Web.Auth/SpotifyAPI.Web.Auth.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net7.0;net6.0;net5.0;netstandard2.1</TargetFrameworks>
3+
<TargetFrameworks>net7.0;net6.0;net5.0;netstandard2.1;netstandard2.0</TargetFrameworks>
44
<LangVersion>9.0</LangVersion>
55
<Nullable>enable</Nullable>
66
<PackageId>SpotifyAPI.Web.Auth</PackageId>

‎SpotifyAPI.Web/Clients/Interfaces/IPaginator.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Task<IList<T>> PaginateAll<T, TNext>(
4242
CancellationToken cancel = default
4343
);
4444

45+
#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
4546
/// <summary>
4647
/// Fetches all pages and returns one by one using IAsyncEnumerable
4748
/// </summary>
@@ -71,5 +72,6 @@ IAsyncEnumerable<T> Paginate<T, TNext>(
7172
IAPIConnector connector,
7273
CancellationToken cancel = default
7374
);
75+
#endif
7476
}
7577
}

‎SpotifyAPI.Web/Clients/Interfaces/ISpotifyClient.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ Task<IList<T>> PaginateAll<T, TNext>(
131131
CancellationToken cancellationToken = default!
132132
);
133133

134+
#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
134135
/// <summary>
135136
/// Paginate through pages by using IAsyncEnumerable, introduced in C# 8
136137
/// The default paginator will fetch all available resources without a delay between requests.
@@ -167,6 +168,7 @@ IAsyncEnumerable<T> Paginate<T, TNext>(
167168
IPaginator? paginator = default!,
168169
CancellationToken cancel = default!
169170
);
171+
#endif
170172

171173
public Task<Paging<T>> NextPage<T>(Paging<T> paging);
172174

‎SpotifyAPI.Web/Clients/SimplePaginator.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public async Task<IList<T>> PaginateAll<T, TNext>(
6969
return results;
7070
}
7171

72+
#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
7273
public async IAsyncEnumerable<T> Paginate<T>(
7374
IPaginatable<T> firstPage,
7475
IAPIConnector connector,
@@ -125,5 +126,6 @@ public async IAsyncEnumerable<T> Paginate<T, TNext>(
125126
}
126127
}
127128
}
129+
#endif
128130
}
129131
}

‎SpotifyAPI.Web/Clients/SpotifyClient.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public Task<TNext> PreviousPage<T, TNext>(Paging<T, TNext> paging)
196196
return FetchPage<TNext>(paging.Previous);
197197
}
198198

199-
199+
#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
200200
/// <summary>
201201
/// Paginate through pages by using IAsyncEnumerable, introduced in C# 8
202202
/// The default paginator will fetch all available resources without a delay between requests.
@@ -303,5 +303,6 @@ public async IAsyncEnumerable<T> Paginate<T, TNext>(
303303
yield return item;
304304
}
305305
}
306+
#endif
306307
}
307308
}

‎SpotifyAPI.Web/Http/APIConnector.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,11 @@ private async Task ApplyAuthenticator(IRequest request)
221221
{
222222
if (_authenticator != null
223223
&& !request.Endpoint.IsAbsoluteUri
224+
#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
224225
|| request.Endpoint.AbsoluteUri.Contains("https://api.spotify.com", StringComparison.InvariantCulture))
226+
#else
227+
|| request.Endpoint.AbsoluteUri.Contains("https://api.spotify.com"))
228+
#endif
225229
{
226230
await _authenticator!.Apply(request, this).ConfigureAwait(false);
227231
}

‎SpotifyAPI.Web/Http/NetHttpClient.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ private static async Task<IResponse> BuildResponse(HttpResponseMessage responseM
5050
// We only support text stuff for now
5151
using var content = responseMsg.Content;
5252
var headers = responseMsg.Headers.ToDictionary(header => header.Key, header => header.Value.First());
53-
#if NETSTANDARD2_1
54-
var body = await responseMsg.Content.ReadAsStringAsync().ConfigureAwait(false);
55-
#else
53+
#if NET5_0_OR_GREATER
5654
var body = await responseMsg.Content.ReadAsStringAsync(cancel).ConfigureAwait(false);
55+
#else
56+
var body = await responseMsg.Content.ReadAsStringAsync().ConfigureAwait(false);
5757
#endif
5858
var contentType = content.Headers?.ContentType?.MediaType;
5959

‎SpotifyAPI.Web/Http/SimpleConsoleHTTPLogger.cs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ public class SimpleConsoleHTTPLogger : IHTTPLogger
77
{
88
private const string OnRequestFormat = "\n{0} {1} [{2}] {3}";
99

10-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303")]
1110
public void OnRequest(IRequest request)
1211
{
1312
Ensure.ArgumentNotNull(request, nameof(request));
@@ -23,12 +22,14 @@ public void OnRequest(IRequest request)
2322
Console.WriteLine(OnRequestFormat, request.Method, request.Endpoint, parameters, request.Body);
2423
}
2524

26-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303")]
2725
public void OnResponse(IResponse response)
2826
{
2927
Ensure.ArgumentNotNull(response, nameof(response));
28+
#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
3029
string? body = response.Body?.ToString()?.Replace("\n", "", StringComparison.InvariantCulture);
31-
30+
#else
31+
string? body = response.Body?.ToString()?.Replace("\n", "");
32+
#endif
3233
body = body?.Substring(0, Math.Min(50, body.Length));
3334
Console.WriteLine("--> {0} {1} {2}\n", response.StatusCode, response.ContentType, body);
3435
}

‎SpotifyAPI.Web/SpotifyAPI.Web.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net7.0;net6.0;net5.0;netstandard2.1</TargetFrameworks>
4+
<TargetFrameworks>net7.0;net6.0;net5.0;netstandard2.1;netstandard2.0</TargetFrameworks>
55
<LangVersion>9.0</LangVersion>
66
<Nullable>enable</Nullable>
77
<PackageId>SpotifyAPI.Web</PackageId>

0 commit comments

Comments
 (0)