Skip to content

Commit

Permalink
Add .NET 9 support
Browse files Browse the repository at this point in the history
  • Loading branch information
dnperfors committed Nov 15, 2024
1 parent 0913eb2 commit 1e54bb6
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ A clear and concise description of what you expected to happen.

**Background (please complete the following information):**
- Version of library: [e.g. 0.10]
- Version of .NET: [e.g. 7.0]
- Version of .NET: [e.g. 8.0]

**Additional context**
Add any other context about the problem here.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
dotnet-version: |
6.0.x
8.0.x
9.0.x
include-prerelease: true
- name: Dump .NET info
run: dotnet --info
Expand Down Expand Up @@ -79,6 +80,7 @@ jobs:
dotnet-version: |
6.0.x
8.0.x
9.0.x
include-prerelease: true
- name: Dump .NET info
run: dotnet --info
Expand All @@ -100,7 +102,7 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
8.0.x
9.0.x
include-prerelease: true
- uses: actions/download-artifact@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
9.0.x
include-prerelease: true
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand All @@ -37,6 +37,6 @@ jobs:
languages: csharp
config-file: ./.github/codeql-config.yml
- name: Build source code
run: dotnet build --configuration Release --framework net6.0
run: dotnet build --configuration Release --framework net8.0
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.12] - unplanned
### Added
- Support for .NET 9.0

## [0.11] - 2024-06-15
### Removed
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<LangVersion>12.0</LangVersion>
<LangVersion>13.0</LangVersion>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020-2022 David Perfors
Copyright (c) 2020-2024 David Perfors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ The following versions are being actively tested and thus supported:
- .NET Framework 4.6, 4.7 and 4.8
- .NET 6.0
- .NET 8.0
- .NET 9.0

These versions are supported as long as Microsoft supports them, we do our best to test and support newer versions as soon as possible.

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.100",
"version": "9.0.100",
"allowPrerelease": false,
"rollForward": "latestMajor"
}
Expand Down
5 changes: 3 additions & 2 deletions src/TestableHttpClient/TestableHttpClient.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net8.0;net9.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -33,7 +33,8 @@

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.Json" Version="4.6.0" />
<PackageReference Include="System.Text.Json" Version="4.7.2" />
<PackageReference Include="System.Text.Encodings.Web" Version="4.7.2" />
<PackageReference Include="Perfors.UnreachableException" Version="1.0.0" />
<PackageReference Include="PolyKit.Embedded" Version="3.0.9" />
</ItemGroup>
Expand Down
14 changes: 9 additions & 5 deletions test/TestableHttpClient.IntegrationTests/ConfigureResponses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,16 @@ public async Task UsingTestHandlerWithCustomResponseFactory_AllowsForAdvancedUse
{
using TestableHttpMessageHandler testHandler = new();

static IResponse PathBasedResponse(HttpResponseContext context) => context.HttpRequestMessage switch
static IResponse PathBasedResponse(HttpResponseContext context)
{
_ when context.HttpRequestMessage.RequestUri?.AbsolutePath == "/status/200" => StatusCode(HttpStatusCode.OK),
_ when context.HttpRequestMessage.RequestUri?.AbsolutePath == "/status/400" => StatusCode(HttpStatusCode.BadRequest),
_ => StatusCode(HttpStatusCode.NotFound)
};
return context.HttpRequestMessage switch
{
_ when context.HttpRequestMessage.RequestUri?.AbsolutePath == "/status/200" => StatusCode(HttpStatusCode.OK),
_ when context.HttpRequestMessage.RequestUri?.AbsolutePath == "/status/400" => StatusCode(HttpStatusCode.BadRequest),
_ => StatusCode(HttpStatusCode.NotFound)
};
}

testHandler.RespondWith(SelectResponse(PathBasedResponse));

using HttpClient httpClient = new(testHandler);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net462;net47;net48;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net462;net47;net48;net6.0;net8.0;net9.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<PackageReference Include="System.Net.Http.Json" Version="[3.1.*,5.0.0)" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Net.Http.Json" Version="[8.0.*,)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
Expand All @@ -15,11 +16,17 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="[8.0.*,)" />
<PackageReference Include="Microsoft.Extensions.Http" Version="[8.0.*,)" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="[8.0.*,)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="[8.0.*,9.0.0)" />
<PackageReference Include="Microsoft.Extensions.Http" Version="[8.0.*,9.0.0)" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="[8.0.*,9.0.0)" />
</ItemGroup>


<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="[9.0.*,)" />
<PackageReference Include="Microsoft.Extensions.Http" Version="[9.0.*,)" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="[9.0.*,)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\TestableHttpClient\TestableHttpClient.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace TestableHttpClient.Tests.HttpRequestMessagesCheckExtensionsTests;

public static class Args
internal static class Args
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Non-substitutable member", "NS1004:Argument matcher used with a non-virtual member of a class.", Justification = "This is a custom matcher.")]
public static ref Func<HttpRequestMessage, bool> AnyPredicate() => ref Arg.Any<Func<HttpRequestMessage, bool>>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace TestableHttpClient.Tests.Response;

public static class ResponseTestHelpers
internal static class ResponseTestHelpers
{
public static Task<HttpResponseMessage> TestAsync(this IResponse response) => TestAsync(response, "http://httpbin.org");
public static Task<HttpResponseMessage> TestAsync(this IResponse response, string url)
Expand Down
4 changes: 2 additions & 2 deletions test/TestableHttpClient.Tests/TestableHttpClient.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net462;net47;net48;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net462;net47;net48;net6.0;net8.0;net9.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<PackageReference Include="System.Net.Http.Json" Version="6.0.1" />
<PackageReference Include="System.Net.Http.Json" Version="6.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 1e54bb6

Please sign in to comment.