Skip to content

Commit 47c2fbb

Browse files
committed
feat: add support for system.text.json
update to .NET 6.0
1 parent 487f154 commit 47c2fbb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+966
-222
lines changed

GitVersion.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,14 @@ commits-since-version-source-padding: 3
88
commit-message-incrementing: Enabled
99
branches:
1010
master:
11-
tag: alpha
11+
tag: alpha
12+
pull-request:
13+
mode: ContinuousDelivery
14+
tag: PullRequest
15+
increment: None
16+
prevent-increment-of-merged-branch-version: false
17+
tag-number-pattern: '[/-](?<number>\d+)[-/]'
18+
track-merge-target: false
19+
regex: (pull|pull\-requests|pr|[0-9]+)[/-]
20+
tracks-release-branches: false
21+
is-release-branch: false

src/.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,4 @@ dotnet_naming_rule.public_constant_fields_rule.severity = warning
228228
dotnet_naming_rule.public_static_readonly_fields_rule.symbols = public_static_readonly_fields
229229
dotnet_naming_rule.public_static_readonly_fields_rule.style = pascal_case
230230
dotnet_naming_rule.public_static_readonly_fields_rule.severity = warning
231+
dotnet_diagnostic.CA2000.severity=silent

src/Directory.Build.props

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,25 @@
2121
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
2222
<Deterministic>true</Deterministic>
2323
</PropertyGroup>
24-
24+
2525
<ItemGroup Condition="$(IsTestProject) != 'true'">
2626
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json">
2727
<Link>stylecop.json</Link>
2828
</AdditionalFiles>
29-
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="16.6.13" PrivateAssets="all"/>
30-
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0" PrivateAssets="all"/>
31-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.0-beta-20204-02" PrivateAssets="all"/>
29+
<!--<PackageReference Include="Microsoft.CodeAnalysis." Version="3.3.1" PrivateAssets="all"/>-->
30+
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.0.64" PrivateAssets="all"/>
31+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.0" PrivateAssets="all"/>
3232
<PackageReference Include="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.59" PrivateAssets="all" />
33-
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.164" PrivateAssets="all" />
33+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.354" PrivateAssets="all" />
34+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0" />
3435
</ItemGroup>
3536

36-
<ItemGroup Condition="$(IsTestProject) == 'true'">
37-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.4" />
38-
<PackageReference Include="nunit" Version="3.12.0" />
39-
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0-beta.1" PrivateAssets="all"/>
40-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
41-
<PackageReference Include="NUnit.Analyzers" Version="0.2.0" PrivateAssets="all"/>
37+
<ItemGroup Condition="'$(IsTestProject)' == 'true'">
38+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0" />
39+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
40+
<PackageReference Include="NUnit" Version="3.13.2" />
41+
<PackageReference Include="NUnit.Analyzers" Version="3.2.0" />
42+
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0" />
4243
</ItemGroup>
4344

4445
<PropertyGroup>
@@ -47,7 +48,7 @@
4748
CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
4849
VSTHRD200:Use "Async" suffix in names of methods that return an awaitable type. -->
4950
<TestNoWarn>1701,1702,CS1591</TestNoWarn>
50-
<NoWarn>NU5105</NoWarn>
51+
<NoWarn>NU5105,CS0400,CS1591</NoWarn>
5152
</PropertyGroup>
5253

5354
</Project>

src/Directory.Build.targets

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- Workaround. Remove once we're on 3.1.300+
22
https://github.com/dotnet/sourcelink/issues/572 -->
33
<Project>
4-
<PropertyGroup Condition="$(IsTestProject) != 'true'">
4+
<!--<PropertyGroup Condition="$(IsTestProject) != 'true'">
55
<TargetFrameworkMonikerAssemblyAttributesPath>$([System.IO.Path]::Combine('$(IntermediateOutputPath)','$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)'))</TargetFrameworkMonikerAssemblyAttributesPath>
66
<GitVersionInformationPath>$([System.IO.Path]::Combine('$(IntermediateOutputPath)','GitVersionInformation.g$(DefaultLanguageSourceExtension)'))</GitVersionInformationPath>
77
</PropertyGroup>
@@ -11,7 +11,7 @@ https://github.com/dotnet/sourcelink/issues/572 -->
1111
<EmbeddedFiles Include="$(GitVersionInformationPath)"/>
1212
</ItemGroup>
1313
14-
<!-- Workaround for https://github.com/dotnet/sdk/issues/11105 -->
14+
--><!-- Workaround for https://github.com/dotnet/sdk/issues/11105 --><!--
1515
<ItemGroup>
1616
<SourceRoot Include="$(NuGetPackageRoot)" />
1717
</ItemGroup>
@@ -23,6 +23,6 @@ https://github.com/dotnet/sourcelink/issues/572 -->
2323
<ItemGroup>
2424
<_LocalTopLevelSourceRoot Include="@(SourceRoot)" Condition="'%(SourceRoot.NestedRoot)' == ''"/>
2525
</ItemGroup>
26-
</Target>
26+
</Target>-->
2727

2828
</Project>

src/Speedygeek.ZendeskAPI.IntegrationTests/Speedygeek.ZendeskAPI.IntegrationTests.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-
<TargetFramework>netcoreapp2.1</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<IsTestProject>true</IsTestProject>
77
</PropertyGroup>

src/Speedygeek.ZendeskAPI.UnitTests/Base/ResponseSaver.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
2323

2424
if (!File.Exists(filePath) | FileName == DEFAULTFILENAME)
2525
{
26-
var content = await resp.Content.ReadAsStringAsync().ConfigureAwait(false);
26+
var content = await resp.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
2727
content = Regex.Replace(content, @"\s+", " ");
28-
await File.WriteAllTextAsync(filePath, content);
28+
await File.WriteAllTextAsync(filePath, content, cancellationToken);
2929
}
3030
return resp;
3131
}

src/Speedygeek.ZendeskAPI.UnitTests/Configuration/CredentialsProviderTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@ public void ApiTokenAuthApiTokenNull()
4040
[Test]
4141
public void ApiTokenAuthNullClient()
4242
{
43-
Assert.That(() => { new APITokenCredentials(Settings.AdminUserName, Settings.ApiToken).ConfigureHttpClientAsync(null).ConfigureAwait(false); },
43+
Assert.That(() => { new APITokenCredentials(Settings.AdminUserName, Settings.ApiToken).ConfigureHttpClient(null); },
4444
Throws.ArgumentNullException);
4545
}
4646

4747
[Test]
4848
public void OAuthTokenAuthNullClient()
4949
{
50-
Assert.That(() => { new OAuthAccessTokenCredentials(Settings.AdminOAuthToken).ConfigureHttpClientAsync(null).ConfigureAwait(false); },
50+
Assert.That(() => { new OAuthAccessTokenCredentials(Settings.AdminOAuthToken).ConfigureHttpClient(null); },
5151
Throws.ArgumentNullException);
5252
}
5353

5454
[Test]
5555
public void BasicAuthNullClient()
5656
{
57-
Assert.That(() => { new BasicCredentials(Settings.AdminUserName, Settings.AdminPassword).ConfigureHttpClientAsync(null).ConfigureAwait(false); },
57+
Assert.That(() => { new BasicCredentials(Settings.AdminUserName, Settings.AdminPassword).ConfigureHttpClient(null); },
5858
Throws.ArgumentNullException);
5959
}
6060

@@ -80,12 +80,12 @@ public void OAuthTokenAuthNullEndUserId()
8080
}
8181

8282
[Test]
83-
public async Task ApiTokenAuthBuildHeader()
83+
public void ApiTokenAuthBuildHeader()
8484
{
8585
using var client = new HttpClient();
8686
var cred = new APITokenCredentials(Settings.AdminUserName, Settings.ApiToken);
8787

88-
await cred.ConfigureHttpClientAsync(client).ConfigureAwait(false);
88+
cred.ConfigureHttpClient(client);
8989

9090
var headerScheme = client.DefaultRequestHeaders.Authorization.Scheme;
9191
var headerParameter = client.DefaultRequestHeaders.Authorization.Parameter;
@@ -95,12 +95,12 @@ public async Task ApiTokenAuthBuildHeader()
9595
}
9696

9797
[Test]
98-
public async Task BasicAuthBuildHeader()
98+
public void BasicAuthBuildHeader()
9999
{
100100
using var client = new HttpClient();
101101
var cred = new BasicCredentials(Settings.AdminUserName, Settings.AdminPassword);
102102

103-
await cred.ConfigureHttpClientAsync(client).ConfigureAwait(false);
103+
cred.ConfigureHttpClient(client);
104104

105105
var headerScheme = client.DefaultRequestHeaders.Authorization.Scheme;
106106
var headerParameter = client.DefaultRequestHeaders.Authorization.Parameter;
@@ -110,13 +110,13 @@ public async Task BasicAuthBuildHeader()
110110
}
111111

112112
[Test]
113-
public async Task OAuthOnBehalfOfAuthBuildHeader()
113+
public void OAuthOnBehalfOfAuthBuildHeader()
114114
{
115115
using var client = new HttpClient();
116116
var endUserId = "[email protected]";
117117
var cred = new OAuthAccessTokenCredentials(Settings.AdminOAuthToken, endUserId);
118118

119-
await cred.ConfigureHttpClientAsync(client).ConfigureAwait(false);
119+
cred.ConfigureHttpClient(client);
120120

121121
var headerValue = client.DefaultRequestHeaders.GetValues("X-On-Behalf-Of").FirstOrDefault();
122122

src/Speedygeek.ZendeskAPI.UnitTests/Configuration/ServiceCollectionExtensionsTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ namespace Speedygeek.ZendeskAPI.UnitTests.Configuration
66
[TestFixture]
77
public class ServiceCollectionExtensionsTest
88
{
9-
109
[Test]
1110
public void BasicAuthSubDomainNull()
1211
{

src/Speedygeek.ZendeskAPI.UnitTests/Serialization/CollaboratorConverterTest.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using Speedygeek.ZendeskAPI.Serialization;
77

88

9-
namespace Speedygeek.ZendeskAPI.UnitTests
9+
namespace Speedygeek.ZendeskAPI.UnitTests.Serialization
1010
{
1111
[TestFixture]
1212
public class CollaboratorConverterTest
@@ -25,20 +25,20 @@ public void SetUp()
2525
[Test]
2626
public void ConvertMixedTypes()
2727
{
28-
var json = @"{ ""Ticket"": { ""id"": 1002, ""collaborators"": [ 562562562, ""[email protected]"", { ""name"": ""Someone Else"", ""email"": ""[email protected]"" } ]}}";
28+
var json = @"{ ""id"": 1002, ""collaborators"": [ 562562562, ""[email protected]"", { ""name"": ""Someone Else"", ""email"": ""[email protected]"" } ]}";
2929

30-
TicketResponse resp = null;
31-
using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(json)))
30+
Ticket resp = null;
31+
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(json)))
3232
{
33-
resp = _serializer.Deserialize<TicketResponse>(stream);
33+
resp = _serializer.Deserialize<Ticket>(stream);
3434
}
3535

36-
Assert.That(resp.Ticket, Is.Not.Null);
37-
Assert.That(resp.Ticket.Collaborators[0].Id, Is.Not.Zero);
38-
Assert.That(resp.Ticket.Collaborators[1].Email, Is.EqualTo("[email protected]"));
36+
Assert.That(resp, Is.Not.Null);
37+
Assert.That(resp.Collaborators[0].Id, Is.Not.Zero);
38+
Assert.That(resp.Collaborators[1].Email, Is.EqualTo("[email protected]"));
3939

40-
Assert.That(resp.Ticket.Collaborators[2].Email, Is.EqualTo("[email protected]"));
41-
Assert.That(resp.Ticket.Collaborators[2].Name, Is.EqualTo("Someone Else"));
40+
Assert.That(resp.Collaborators[2].Email, Is.EqualTo("[email protected]"));
41+
Assert.That(resp.Collaborators[2].Name, Is.EqualTo("Someone Else"));
4242
}
4343
}
4444
}

src/Speedygeek.ZendeskAPI.UnitTests/Serialization/ListResponseBaseTest.cs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,37 @@ public void SetUp()
2222
}
2323

2424

25+
//[Test]
26+
//public void PageNumber()
27+
//{
28+
// var json = @"{ ""next_page"":""https://csharpapi.zendesk.com/api/v2/tickets.json?page=3"",""previous_page"":""https://csharpapi.zendesk.com/api/v2/tickets.json?page=1"",""count"":1365}";
29+
30+
// TicketListResponse resp = null;
31+
// using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(json)))
32+
// {
33+
// resp = _serializer.Deserialize<TicketListResponse>(stream);
34+
// }
35+
36+
// Assert.That(resp.Page, Is.EqualTo(2));
37+
//}
38+
39+
2540
[Test]
26-
public void PageNumber()
41+
public void Meta()
2742
{
28-
var json = @"{ ""next_page"":""https://csharpapi.zendesk.com/api/v2/tickets.json?page=3"",""previous_page"":""https://csharpapi.zendesk.com/api/v2/tickets.json?page=1"",""count"":1365}";
29-
43+
var json = @"{ ""meta"": {""has_more"": true, ""after_cursor"": ""100"", ""before_cursor"": ""200"" },
44+
""links"": {
45+
""next"": ""https://example.zendesk.com/api/v2/tickets.json?page[size]=100&page[after]=101"",
46+
""prev"": ""https://example.zendesk.com/api/v2/tickets.json?page[size]=100&page[before]=200""
47+
}
48+
}";
3049
TicketListResponse resp = null;
31-
using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(json)))
50+
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(json)))
3251
{
3352
resp = _serializer.Deserialize<TicketListResponse>(stream);
3453
}
3554

36-
Assert.That(resp.Page, Is.EqualTo(2));
55+
Assert.That(resp.Meta.HasMore, Is.True);
3756
}
38-
39-
4057
}
4158
}

0 commit comments

Comments
 (0)