Skip to content

Commit

Permalink
15th release (#13)
Browse files Browse the repository at this point in the history
* Upgrade .NET version of test projects to 8.0

* Upgrade to newer version of System.Text.Json package

* Fix some typos in the documentation

---------

Co-authored-by: Kambiz Khojasteh <kambiz.khojasteh@gmail.com>
  • Loading branch information
kampute and Khojasteh authored Jul 27, 2024
1 parent 6f01e83 commit 796081a
Show file tree
Hide file tree
Showing 17 changed files with 43 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Title>Kampute.HttpClient.DataContract</Title>
<Description>This package is an extension package for Kampute.HttpClient, enhancing it to manage application/xml content types, using DataContractSerializer for serialization and deserialization of XML responses and payloads.</Description>
<Authors>Kambiz Khojasteh</Authors>
<Version>2.3.0</Version>
<Version>2.3.1</Version>
<Company>Kampute</Company>
<Copyright>Copyright (c) 2024 Kampute</Copyright>
<LangVersion>latest</LangVersion>
Expand All @@ -27,7 +27,7 @@
</PropertyGroup>

<PropertyGroup Condition="Exists('../../SigningKey.snk')">
<SignAssembly >true</SignAssembly>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../../SigningKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

Expand Down
6 changes: 3 additions & 3 deletions src/Kampute.HttpClient.Json/Kampute.HttpClient.Json.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Title>Kampute.HttpClient.Json</Title>
<Description>This package is an extension package for Kampute.HttpClient, enhancing it to manage application/json content types, using System.Text.Json library for serialization and deserialization of JSON responses and payloads.</Description>
<Authors>Kambiz Khojasteh</Authors>
<Version>2.3.0</Version>
<Version>2.3.1</Version>
<Company>Kampute</Company>
<Copyright>Copyright (c) 2024 Kampute</Copyright>
<LangVersion>latest</LangVersion>
Expand All @@ -27,7 +27,7 @@
</PropertyGroup>

<PropertyGroup Condition="Exists('../../SigningKey.snk')">
<SignAssembly >true</SignAssembly>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../../SigningKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

Expand All @@ -36,7 +36,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="8.0.3" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Title>Kampute.HttpClient.NewtonsoftJson</Title>
<Description>This package is an extension package for Kampute.HttpClient, enhancing it to manage application/json content types, using Newtonsoft.Json library for serialization and deserialization of JSON responses and payloads.</Description>
<Authors>Kambiz Khojasteh</Authors>
<Version>2.3.0</Version>
<Version>2.3.1</Version>
<Company>Kampute</Company>
<Copyright>Copyright (c) 2024 Kampute</Copyright>
<LangVersion>latest</LangVersion>
Expand All @@ -27,7 +27,7 @@
</PropertyGroup>

<PropertyGroup Condition="Exists('../../SigningKey.snk')">
<SignAssembly >true</SignAssembly>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../../SigningKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/Kampute.HttpClient.Xml/Kampute.HttpClient.Xml.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Title>Kampute.HttpClient.Xml</Title>
<Description>This package is an extension package for Kampute.HttpClient, enhancing it to manage application/xml content types, using XmlSerializer for serialization and deserialization of XML responses and payloads.</Description>
<Authors>Kambiz Khojasteh</Authors>
<Version>2.3.0</Version>
<Version>2.3.1</Version>
<Company>Kampute</Company>
<Copyright>Copyright (c) 2024 Kampute</Copyright>
<LangVersion>latest</LangVersion>
Expand All @@ -27,7 +27,7 @@
</PropertyGroup>

<PropertyGroup Condition="Exists('../../SigningKey.snk')">
<SignAssembly >true</SignAssembly>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../../SigningKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class HttpError503Handler : IHttpErrorHandler
/// <item>
/// <term>context</term>
/// <description>
/// Provides context about the HTTP responce indicating a '503 Service Unavailable' error. It is encapsulated within
/// Provides context about the HTTP response indicating a '503 Service Unavailable' error. It is encapsulated within
/// an <see cref="HttpResponseErrorContext"/> instance, allowing for an informed decision on the retry strategy.
/// </description>
/// </item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public IReadOnlyCollection<string> GetSupportedMediaTypes(Type modelType, Type e
}

/// <summary>
/// Clears the chace.
/// Clears the cache.
/// </summary>
public void Clear()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Kampute.HttpClient/HttpErrorHandlerCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public sealed class HttpErrorHandlerCollection : ICollection<IHttpErrorHandler>
/// Retrieves all <see cref="IHttpErrorHandler"/> instances in the collection that support handling a specific HTTP status code.
/// </summary>
/// <param name="statusCode">The HTTP status code to query.</param>
/// <returns>An enumrable of <see cref="IHttpErrorHandler"/> that can handle the specified status code.</returns>
/// <returns>An enumerable of <see cref="IHttpErrorHandler"/> that can handle the specified status code.</returns>
public IEnumerable<IHttpErrorHandler> GetHandlersFor(HttpStatusCode statusCode)
{
return _collection.Where(errorHandler => errorHandler.CanHandle(statusCode));
Expand Down
2 changes: 1 addition & 1 deletion src/Kampute.HttpClient/Kampute.HttpClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Title>Kampute.HttpClient</Title>
<Description>Kampute.HttpClient is a versatile and lightweight .NET library that simplifies RESTful API communication. Its core HttpRestClient class provides a streamlined approach to HTTP interactions, offering advanced features such as flexible serialization/deserialization, robust error handling, configurable backoff strategies, and detailed request-response processing. Striking a balance between simplicity and extensibility, Kampute.HttpClient empowers developers with a powerful yet easy-to-use client for seamless API integration across a wide range of .NET applications.</Description>
<Authors>Kambiz Khojasteh</Authors>
<Version>2.3.0</Version>
<Version>2.3.1</Version>
<Company>Kampute</Company>
<Copyright>Copyright (c) 2024 Kampute</Copyright>
<LangVersion>latest</LangVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<LangVersion>latest</LangVersion>
Expand All @@ -10,10 +10,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<LangVersion>latest</LangVersion>
Expand All @@ -10,10 +10,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
7 changes: 5 additions & 2 deletions tests/Kampute.HttpClient.Json.Test/TestModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;

public class TestModel
public partial class TestModel
{
public string? Name { get; set; }

Expand All @@ -28,7 +28,7 @@ static string ToJson(string? value)
if (value is null)
return "null";

var escaped = Regex.Replace(value, @"[\u0000-\u001F\\""]", match =>
var escaped = SpecialCharacters().Replace(value, match =>
{
var c = match.Value[0];
return c switch
Expand All @@ -52,5 +52,8 @@ static string ToJson(string? value)
{
UnmappedMemberHandling = JsonUnmappedMemberHandling.Disallow
};

[GeneratedRegex(@"[\u0000-\u001F\\""]")]
private static partial Regex SpecialCharacters();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<LangVersion>latest</LangVersion>
Expand All @@ -10,10 +10,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
7 changes: 5 additions & 2 deletions tests/Kampute.HttpClient.NewtonsoftJson.Test/TestModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Text.RegularExpressions;

public class TestModel
public partial class TestModel
{
public string? Name { get; set; }

Expand All @@ -27,7 +27,7 @@ static string ToJson(string? value)
if (value is null)
return "null";

var escaped = Regex.Replace(value, @"[\u0000-\u001F\\""]", match =>
var escaped = SpecialCharacters().Replace(value, match =>
{
var c = match.Value[0];
return c switch
Expand All @@ -52,5 +52,8 @@ static string ToJson(string? value)
NullValueHandling = NullValueHandling.Include,
MissingMemberHandling = MissingMemberHandling.Error,
};

[GeneratedRegex(@"[\u0000-\u001F\\""]")]
private static partial Regex SpecialCharacters();
}
}
6 changes: 3 additions & 3 deletions tests/Kampute.HttpClient.Test/Kampute.HttpClient.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<LangVersion>latest</LangVersion>
Expand All @@ -10,10 +10,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
9 changes: 3 additions & 6 deletions tests/Kampute.HttpClient.Test/TestHelpers/MockExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ internal static class MockExtensions
{
public static void MockHttpResponse(this Mock<HttpMessageHandler> mockMessageHandler, Func<HttpRequestMessage, HttpResponseMessage> responseFactory)
{
if (mockMessageHandler is null)
throw new ArgumentNullException(nameof(mockMessageHandler));
if (responseFactory is null)
throw new ArgumentNullException(nameof(responseFactory));
ArgumentNullException.ThrowIfNull(mockMessageHandler);
ArgumentNullException.ThrowIfNull(responseFactory);

mockMessageHandler.Protected()
.Setup<Task<HttpResponseMessage>>
Expand All @@ -34,8 +32,7 @@ public static void MockHttpResponse(this Mock<HttpMessageHandler> mockMessageHan

public static void MockHttpResponse(this Mock<HttpMessageHandler> mockMessageHandler, HttpStatusCode statusCode, HttpContent? content = null)
{
if (mockMessageHandler is null)
throw new ArgumentNullException(nameof(mockMessageHandler));
ArgumentNullException.ThrowIfNull(mockMessageHandler);

mockMessageHandler.MockHttpResponse(_ => new HttpResponseMessage(statusCode) { Content = content });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ public bool CanDeserialize(string mediaType, Type? modelType)

public async Task<object?> DeserializeAsync(HttpContent content, Type modelType, CancellationToken cancellationToken = default)
{
if (content is null)
throw new ArgumentNullException(nameof(content));
if (modelType is null)
throw new ArgumentNullException(nameof(modelType));
ArgumentNullException.ThrowIfNull(content);
ArgumentNullException.ThrowIfNull(modelType);

var str = await content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
return (typeof(TestErrorResponse) == modelType) ? new TestErrorResponse(str) : Convert.ChangeType(str, modelType);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<LangVersion>latest</LangVersion>
Expand All @@ -10,10 +10,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down

0 comments on commit 796081a

Please sign in to comment.