From 03a966b33111879a09f9dfbb23a91116eada2285 Mon Sep 17 00:00:00 2001 From: James Thompson Date: Sun, 12 May 2024 10:53:39 +1000 Subject: [PATCH 1/3] #323 Add net standard 2.1 --- Consul/Consul.csproj | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Consul/Consul.csproj b/Consul/Consul.csproj index 287c8177d..3d26b6d90 100644 --- a/Consul/Consul.csproj +++ b/Consul/Consul.csproj @@ -1,7 +1,7 @@ - + - netstandard2.0;net461 + netstandard2.0;net461;netstandard2.1 PlayFab,$(Authors) Copyright 2015-2018 PlayFab Inc.; $(Copyright) Consul.NET is a .NET client library for the Consul HTTP API @@ -14,6 +14,9 @@ + + + @@ -26,6 +29,7 @@ + From e20503ed863f5fd4172e2f4340edae4659a1cea9 Mon Sep 17 00:00:00 2001 From: James Thompson Date: Thu, 16 May 2024 09:46:17 +1000 Subject: [PATCH 2/3] Switch to net 6 & improve cancellation token propergation --- Consul/Client_DeleteRequests.cs | 25 +++++++++++++++++++++---- Consul/Client_GetRequests.cs | 24 +++++++++++++++++++++--- Consul/Client_PostRequests.cs | 32 ++++++++++++++++++++++++++++---- Consul/Client_PutRequests.cs | 32 ++++++++++++++++++++++++++++---- Consul/Consul.csproj | 2 +- 5 files changed, 99 insertions(+), 16 deletions(-) diff --git a/Consul/Client_DeleteRequests.cs b/Consul/Client_DeleteRequests.cs index 656aeb901..cb162c18f 100644 --- a/Consul/Client_DeleteRequests.cs +++ b/Consul/Client_DeleteRequests.cs @@ -61,8 +61,13 @@ public async Task> Execute(CancellationToken ct) var response = await Client.HttpClient.SendAsync(message, ct).ConfigureAwait(false); result.StatusCode = response.StatusCode; - - ResponseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + ResponseStream = await response.Content +#if !NET6_0_OR_GREATER + .ReadAsStreamAsync() +#else + .ReadAsStreamAsync(ct) +#endif + .ConfigureAwait(false); if (response.StatusCode != HttpStatusCode.NotFound && !response.IsSuccessStatusCode) { @@ -150,7 +155,13 @@ public async Task Execute(CancellationToken ct) result.StatusCode = response.StatusCode; - ResponseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + ResponseStream = await response.Content +#if !NET6_0_OR_GREATER + .ReadAsStreamAsync() +#else + .ReadAsStreamAsync(ct) +#endif + .ConfigureAwait(false); if (response.StatusCode != HttpStatusCode.NotFound && !response.IsSuccessStatusCode) { @@ -252,7 +263,13 @@ public async Task Execute(CancellationToken ct) result.StatusCode = response.StatusCode; - ResponseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + ResponseStream = await response.Content +#if !NET6_0_OR_GREATER + .ReadAsStreamAsync() +#else + .ReadAsStreamAsync(ct) +#endif + .ConfigureAwait(false); if (response.StatusCode != HttpStatusCode.NotFound && !response.IsSuccessStatusCode) { diff --git a/Consul/Client_GetRequests.cs b/Consul/Client_GetRequests.cs index d9ab8d3cf..91439bb35 100644 --- a/Consul/Client_GetRequests.cs +++ b/Consul/Client_GetRequests.cs @@ -79,7 +79,13 @@ public async Task> Execute(CancellationToken ct) ParseQueryHeaders(response, result); result.StatusCode = response.StatusCode; - ResponseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + ResponseStream = await response.Content +#if !NET6_0_OR_GREATER + .ReadAsStreamAsync() +#else + .ReadAsStreamAsync(ct) +#endif + .ConfigureAwait(false); Func isSpecialStatusCode = () => @@ -133,7 +139,13 @@ public async Task> ExecuteStreaming(CancellationToken ct) ParseQueryHeaders(response, result as QueryResult); result.StatusCode = response.StatusCode; - ResponseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + ResponseStream = await response.Content +#if !NET6_0_OR_GREATER + .ReadAsStreamAsync() +#else + .ReadAsStreamAsync(ct) +#endif + .ConfigureAwait(false); result.Response = ResponseStream; @@ -334,7 +346,13 @@ public async Task> Execute(CancellationToken ct) var response = await Client.HttpClient.SendAsync(message, ct).ConfigureAwait(false); result.StatusCode = response.StatusCode; - ResponseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + ResponseStream = await response.Content +#if !NET6_0_OR_GREATER + .ReadAsStreamAsync() +#else + .ReadAsStreamAsync(ct) +#endif + .ConfigureAwait(false); Func isSpecialStatusCode = () => { diff --git a/Consul/Client_PostRequests.cs b/Consul/Client_PostRequests.cs index 40852f247..6213d2b27 100644 --- a/Consul/Client_PostRequests.cs +++ b/Consul/Client_PostRequests.cs @@ -67,7 +67,13 @@ public async Task> Execute(CancellationToken ct) result.StatusCode = response.StatusCode; - ResponseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + ResponseStream = await response.Content +#if !NET6_0_OR_GREATER + .ReadAsStreamAsync() +#else + .ReadAsStreamAsync(ct) +#endif + .ConfigureAwait(false); if (response.StatusCode != HttpStatusCode.NotFound && !response.IsSuccessStatusCode) { @@ -174,7 +180,13 @@ public async Task Execute(CancellationToken ct) result.StatusCode = response.StatusCode; - ResponseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + ResponseStream = await response.Content +#if !NET6_0_OR_GREATER + .ReadAsStreamAsync() +#else + .ReadAsStreamAsync(ct) +#endif + .ConfigureAwait(false); if (response.StatusCode != HttpStatusCode.NotFound && !response.IsSuccessStatusCode) { @@ -277,7 +289,13 @@ public async Task> Execute(CancellationToken ct) result.StatusCode = response.StatusCode; - ResponseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + ResponseStream = await response.Content +#if !NET6_0_OR_GREATER + .ReadAsStreamAsync() +#else + .ReadAsStreamAsync(ct) +#endif + .ConfigureAwait(false); if (response.StatusCode != HttpStatusCode.NotFound && !response.IsSuccessStatusCode) { @@ -369,7 +387,13 @@ public async Task> Execute(CancellationToken ct) result.StatusCode = response.StatusCode; - ResponseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + ResponseStream = await response.Content +#if !NET6_0_OR_GREATER + .ReadAsStreamAsync() +#else + .ReadAsStreamAsync(ct) +#endif + .ConfigureAwait(false); if (response.StatusCode != HttpStatusCode.NotFound && !response.IsSuccessStatusCode) { diff --git a/Consul/Client_PutRequests.cs b/Consul/Client_PutRequests.cs index 05f132118..8b9a03a60 100644 --- a/Consul/Client_PutRequests.cs +++ b/Consul/Client_PutRequests.cs @@ -62,7 +62,13 @@ public async Task> Execute(CancellationToken ct) result.StatusCode = response.StatusCode; - ResponseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + ResponseStream = await response.Content +#if !NET6_0_OR_GREATER + .ReadAsStreamAsync() +#else + .ReadAsStreamAsync(ct) +#endif + .ConfigureAwait(false); if (response.StatusCode != HttpStatusCode.NotFound && !response.IsSuccessStatusCode) { @@ -149,7 +155,13 @@ public async Task Execute(CancellationToken ct) result.StatusCode = response.StatusCode; - ResponseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + ResponseStream = await response.Content +#if !NET6_0_OR_GREATER + .ReadAsStreamAsync() +#else + .ReadAsStreamAsync(ct) +#endif + .ConfigureAwait(false); if (response.StatusCode != HttpStatusCode.NotFound && !response.IsSuccessStatusCode) { @@ -251,7 +263,13 @@ public async Task Execute(CancellationToken ct) result.StatusCode = response.StatusCode; - ResponseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + ResponseStream = await response.Content +#if !NET6_0_OR_GREATER + .ReadAsStreamAsync() +#else + .ReadAsStreamAsync(ct) +#endif + .ConfigureAwait(false); if (response.StatusCode != HttpStatusCode.NotFound && !response.IsSuccessStatusCode) { @@ -354,7 +372,13 @@ public async Task> Execute(CancellationToken ct) result.StatusCode = response.StatusCode; - ResponseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + ResponseStream = await response.Content +#if !NET6_0_OR_GREATER + .ReadAsStreamAsync() +#else + .ReadAsStreamAsync(ct) +#endif + .ConfigureAwait(false); if (!response.IsSuccessStatusCode && ( (response.StatusCode != HttpStatusCode.NotFound && typeof(TOut) != typeof(TxnResponse)) || diff --git a/Consul/Consul.csproj b/Consul/Consul.csproj index 3d26b6d90..11a4adf13 100644 --- a/Consul/Consul.csproj +++ b/Consul/Consul.csproj @@ -1,7 +1,7 @@ - netstandard2.0;net461;netstandard2.1 + netstandard2.0;net461;net6 PlayFab,$(Authors) Copyright 2015-2018 PlayFab Inc.; $(Copyright) Consul.NET is a .NET client library for the Consul HTTP API From 2a3c0ad5eebde655775fd3c4da8809732a916f70 Mon Sep 17 00:00:00 2001 From: James Thompson Date: Fri, 3 Jan 2025 23:26:03 +1100 Subject: [PATCH 3/3] Update Consul.csproj Co-authored-by: Ivan Maximov --- Consul/Consul.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Consul/Consul.csproj b/Consul/Consul.csproj index 11a4adf13..ffee94d60 100644 --- a/Consul/Consul.csproj +++ b/Consul/Consul.csproj @@ -1,7 +1,7 @@ - netstandard2.0;net461;net6 + netstandard2.0;net461;net6.0 PlayFab,$(Authors) Copyright 2015-2018 PlayFab Inc.; $(Copyright) Consul.NET is a .NET client library for the Consul HTTP API