Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#323 Add net 6.0 #324

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions Consul/Client_DeleteRequests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ public async Task<WriteResult<TOut>> 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)
{
Expand Down Expand Up @@ -146,7 +151,13 @@ public async Task<WriteResult> 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)
{
Expand Down Expand Up @@ -246,7 +257,13 @@ public async Task<WriteResult> 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)
{
Expand Down
24 changes: 21 additions & 3 deletions Consul/Client_GetRequests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,13 @@ public async Task<QueryResult<TOut>> 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<bool> isSpecialStatusCode = () =>
Expand Down Expand Up @@ -131,7 +137,13 @@ public async Task<QueryResult<Stream>> ExecuteStreaming(CancellationToken ct)

ParseQueryHeaders(response, result as QueryResult<TOut>);
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;

Expand Down Expand Up @@ -330,7 +342,13 @@ public async Task<QueryResult<string>> 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<bool> isSpecialStatusCode = () =>
{
Expand Down
32 changes: 28 additions & 4 deletions Consul/Client_PostRequests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ public async Task<WriteResult<TOut>> 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)
{
Expand Down Expand Up @@ -170,7 +176,13 @@ public async Task<WriteResult> 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)
{
Expand Down Expand Up @@ -271,7 +283,13 @@ public async Task<WriteResult<TOut>> 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)
{
Expand Down Expand Up @@ -361,7 +379,13 @@ public async Task<WriteResult<string>> 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)
{
Expand Down
32 changes: 28 additions & 4 deletions Consul/Client_PutRequests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ public async Task<WriteResult<TOut>> 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)
{
Expand Down Expand Up @@ -145,7 +151,13 @@ public async Task<WriteResult> 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)
{
Expand Down Expand Up @@ -245,7 +257,13 @@ public async Task<WriteResult> 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)
{
Expand Down Expand Up @@ -346,7 +364,13 @@ public async Task<WriteResult<TOut>> 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)) ||
Expand Down
8 changes: 6 additions & 2 deletions Consul/Consul.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net461;net6</TargetFrameworks>
<Authors>PlayFab,$(Authors)</Authors>
<Copyright>Copyright 2015-2018 PlayFab Inc.; $(Copyright)</Copyright>
<Description>Consul.NET is a .NET client library for the Consul HTTP API</Description>
Expand All @@ -13,11 +13,15 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="ConfigureAwaitChecker.Analyzer" Version="5.0.0.1" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.CSharp" Version="4.7.0"/>
</ItemGroup>

<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' ">
<PackageReference Include="ILRepack" Version="2.0.18" PrivateAssets="All" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0"/>
<PackageReference Update="Newtonsoft.Json" PrivateAssets="All" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.WebRequest" />
Expand Down