Skip to content

Commit ba7698e

Browse files
authored
.NET 8 support
Closes #241
1 parent 3ba1438 commit ba7698e

Some content is hidden

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

48 files changed

+574
-523
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"dotnet-sonarscanner": {
6-
"version": "5.13.1",
6+
"version": "5.14.0",
77
"commands": [
88
"dotnet-sonarscanner"
99
]

.github/workflows/ci.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ jobs:
2727
with:
2828
dotnet-version: |
2929
6.0.x
30-
7.0.103
30+
7.0.x
31+
8.0.x
32+
include-prerelease: true
3133
- name: Dump .NET info
3234
run: dotnet --info
3335
- name: Restore dotnet tools
@@ -77,7 +79,9 @@ jobs:
7779
with:
7880
dotnet-version: |
7981
6.0.x
80-
7.0.306
82+
7.0.x
83+
8.0.x
84+
include-prerelease: true
8185
- name: Dump .NET info
8286
run: dotnet --info
8387
- name: Restore dependencies
@@ -98,7 +102,8 @@ jobs:
98102
uses: actions/setup-dotnet@v1
99103
with:
100104
dotnet-version: |
101-
7.0.x
105+
8.0.x
106+
include-prerelease: true
102107
- uses: actions/download-artifact@v2
103108
with:
104109
name: artifacts

.github/workflows/codeql.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828
dotnet-version: |
2929
6.0.x
3030
7.0.x
31+
8.0.x
32+
include-prerelease: true
3133
- name: Initialize CodeQL
3234
uses: github/codeql-action/init@v2
3335
with:

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
99
- `ShouldHaveMadeRequestsTo(this TestableHttpMessageHandler, string, bool)` and `ShouldHaveMadeRequestsTo(this TestableHttpMessageHandler, string, bool, int)` have been removed. CaseInsensitivity is controlled by the `UriPatternMatchingOptions` that can be set on the `TestableHttpMessageHandler`.
1010
- `WithRequestUri(this IHttpRequestMessagesCheck, string, bool)` and `WithRequestUri(this IHttpRequestMessagesCheck, string, bool, int)` have been removed. CaseInsensitivity is controlled by the `UriPatternMatchingOptions` that can be set on the `TestableHttpMessageHandler`.
1111
- `WithQueryString` has been removed, since `ShouldHaveMadeRequestTo` and `WithRequestUri` now properly support querystrings.
12+
13+
### Changed
1214
- Replaced Moq with NSubstitute in test project because of the SponsorLink dependencies.
1315

16+
### Added
17+
- Support for .NET 8
18+
1419
## [0.10] - 2022-12-03
1520
### Deprecated
1621
- `ShouldHaveMadeRequestsTo(this TestableHttpMessageHandler, string, bool)` and `ShouldHaveMadeRequestsTo(this TestableHttpMessageHandler, string, bool, int)` have been deprecated. CaseInsensitivity is controlled by the `UriPatternMatchingOptions` that can be set on the `TestableHttpMessageHandler`.

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<LangVersion>11.0</LangVersion>
3+
<LangVersion>12.0</LangVersion>
44
<Nullable>enable</Nullable>
55
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
66
<EnableNETAnalyzers>true</EnableNETAnalyzers>

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ The following versions are being actively tested and thus supported:
8484
- .NET Framework 4.6, 4.7 and 4.8
8585
- .NET 6.0
8686
- .NET 7.0
87+
- .NET 8.0
8788

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

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"sdk": {
3-
"version": "7.0.100",
4-
"allowPrerelease": false,
3+
"version": "8.0.100-rc.1",
4+
"allowPrerelease": true,
55
"rollForward": "latestMajor"
66
}
77
}

src/TestableHttpClient/HttpRequestMessageAsserter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private void Assert(int? expectedCount = null)
4747
/// Asserts whether requests comply with a specific filter.
4848
/// </summary>
4949
/// <param name="requestFilter">The filter to filter requests with before asserting.</param>
50-
/// <param name="condition">The name of the conditon, used in the exception message.</param>
50+
/// <param name="condition">The name of the condition, used in the exception message.</param>
5151
/// <returns>The <seealso cref="IHttpRequestMessagesCheck"/> for further assertions.</returns>
5252
[AssertionMethod]
5353
public IHttpRequestMessagesCheck WithFilter(Func<HttpRequestMessage, bool> requestFilter, string condition) => WithFilter(requestFilter, null, condition);
@@ -56,7 +56,7 @@ private void Assert(int? expectedCount = null)
5656
/// Asserts whether requests comply with a specific filter.
5757
/// </summary>
5858
/// <param name="requestFilter">The filter to filter requests with before asserting.</param>
59-
/// <param name="condition">The name of the conditon, used in the exception message.</param>
59+
/// <param name="condition">The name of the condition, used in the exception message.</param>
6060
/// <returns>The <seealso cref="IHttpRequestMessagesCheck"/> for further assertions.</returns>
6161
[AssertionMethod]
6262
public IHttpRequestMessagesCheck WithFilter(Func<HttpRequestMessage, bool> requestFilter, int expectedNumberOfRequests, string condition) => WithFilter(requestFilter, (int?)expectedNumberOfRequests, condition);

src/TestableHttpClient/HttpRequestMessageExtensions.cs

Lines changed: 21 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,8 @@ internal static class HttpRequestMessageExtensions
1313
/// <returns>true when the HttpVersion matches; otherwise, false.</returns>
1414
internal static bool HasHttpVersion(this HttpRequestMessage httpRequestMessage, Version httpVersion)
1515
{
16-
if (httpRequestMessage == null)
17-
{
18-
throw new ArgumentNullException(nameof(httpRequestMessage));
19-
}
20-
21-
if (httpVersion == null)
22-
{
23-
throw new ArgumentNullException(nameof(httpVersion));
24-
}
16+
Guard.ThrowIfNull(httpRequestMessage);
17+
Guard.ThrowIfNull(httpVersion);
2518

2619
return httpRequestMessage.Version == httpVersion;
2720
}
@@ -34,15 +27,8 @@ internal static bool HasHttpVersion(this HttpRequestMessage httpRequestMessage,
3427
/// <returns>true when the HttpVersion matches; otherwise, false.</returns>
3528
internal static bool HasHttpVersion(this HttpRequestMessage httpRequestMessage, string httpVersion)
3629
{
37-
if (httpRequestMessage == null)
38-
{
39-
throw new ArgumentNullException(nameof(httpRequestMessage));
40-
}
41-
42-
if (string.IsNullOrEmpty(httpVersion))
43-
{
44-
throw new ArgumentNullException(nameof(httpVersion));
45-
}
30+
Guard.ThrowIfNull(httpRequestMessage);
31+
Guard.ThrowIfNullOrEmpty(httpVersion);
4632

4733
return httpRequestMessage.HasHttpVersion(new Version(httpVersion));
4834
}
@@ -55,15 +41,8 @@ internal static bool HasHttpVersion(this HttpRequestMessage httpRequestMessage,
5541
/// <returns>true when the HttpMethod matches; otherwise, false.</returns>
5642
internal static bool HasHttpMethod(this HttpRequestMessage httpRequestMessage, HttpMethod httpMethod)
5743
{
58-
if (httpRequestMessage == null)
59-
{
60-
throw new ArgumentNullException(nameof(httpRequestMessage));
61-
}
62-
63-
if (httpMethod == null)
64-
{
65-
throw new ArgumentNullException(nameof(httpMethod));
66-
}
44+
Guard.ThrowIfNull(httpRequestMessage);
45+
Guard.ThrowIfNull(httpMethod);
6746

6847
return httpRequestMessage.Method == httpMethod;
6948
}
@@ -76,15 +55,8 @@ internal static bool HasHttpMethod(this HttpRequestMessage httpRequestMessage, H
7655
/// <returns>true when the HttpMethod matches; otherwise, false.</returns>
7756
internal static bool HasHttpMethod(this HttpRequestMessage httpRequestMessage, string httpMethod)
7857
{
79-
if (httpRequestMessage == null)
80-
{
81-
throw new ArgumentNullException(nameof(httpRequestMessage));
82-
}
83-
84-
if (string.IsNullOrEmpty(httpMethod))
85-
{
86-
throw new ArgumentNullException(nameof(httpMethod));
87-
}
58+
Guard.ThrowIfNull(httpRequestMessage);
59+
Guard.ThrowIfNullOrEmpty(httpMethod);
8860

8961
return httpRequestMessage.HasHttpMethod(new HttpMethod(httpMethod));
9062
}
@@ -98,15 +70,8 @@ internal static bool HasHttpMethod(this HttpRequestMessage httpRequestMessage, s
9870
/// <returns>true when the request contains a header with the specified name; otherwise, false.</returns>
9971
internal static bool HasRequestHeader(this HttpRequestMessage httpRequestMessage, string headerName)
10072
{
101-
if (httpRequestMessage == null)
102-
{
103-
throw new ArgumentNullException(nameof(httpRequestMessage));
104-
}
105-
106-
if (string.IsNullOrEmpty(headerName))
107-
{
108-
throw new ArgumentNullException(nameof(headerName));
109-
}
73+
Guard.ThrowIfNull(httpRequestMessage);
74+
Guard.ThrowIfNullOrEmpty(headerName);
11075

11176
return httpRequestMessage.Headers.HasHeader(headerName);
11277
}
@@ -121,20 +86,9 @@ internal static bool HasRequestHeader(this HttpRequestMessage httpRequestMessage
12186
/// <returns>true when the request contains a header with the specified name and value; otherwise, false.</returns>
12287
internal static bool HasRequestHeader(this HttpRequestMessage httpRequestMessage, string headerName, string headerValue)
12388
{
124-
if (httpRequestMessage == null)
125-
{
126-
throw new ArgumentNullException(nameof(httpRequestMessage));
127-
}
128-
129-
if (string.IsNullOrEmpty(headerName))
130-
{
131-
throw new ArgumentNullException(nameof(headerName));
132-
}
133-
134-
if (string.IsNullOrEmpty(headerValue))
135-
{
136-
throw new ArgumentNullException(nameof(headerValue));
137-
}
89+
Guard.ThrowIfNull(httpRequestMessage);
90+
Guard.ThrowIfNullOrEmpty(headerName);
91+
Guard.ThrowIfNullOrEmpty(headerValue);
13892

13993
return httpRequestMessage.Headers.HasHeader(headerName, headerValue);
14094
}
@@ -148,15 +102,8 @@ internal static bool HasRequestHeader(this HttpRequestMessage httpRequestMessage
148102
/// <returns>true when the request contains a header with the specified name; otherwise, false.</returns>
149103
internal static bool HasContentHeader(this HttpRequestMessage httpRequestMessage, string headerName)
150104
{
151-
if (httpRequestMessage == null)
152-
{
153-
throw new ArgumentNullException(nameof(httpRequestMessage));
154-
}
155-
156-
if (string.IsNullOrEmpty(headerName))
157-
{
158-
throw new ArgumentNullException(nameof(headerName));
159-
}
105+
Guard.ThrowIfNull(httpRequestMessage);
106+
Guard.ThrowIfNullOrEmpty(headerName);
160107

161108
if (httpRequestMessage.Content == null)
162109
{
@@ -176,20 +123,9 @@ internal static bool HasContentHeader(this HttpRequestMessage httpRequestMessage
176123
/// <returns>true when the request contains a header with the specified name and value; otherwise, false.</returns>
177124
internal static bool HasContentHeader(this HttpRequestMessage httpRequestMessage, string headerName, string headerValue)
178125
{
179-
if (httpRequestMessage == null)
180-
{
181-
throw new ArgumentNullException(nameof(httpRequestMessage));
182-
}
183-
184-
if (string.IsNullOrEmpty(headerName))
185-
{
186-
throw new ArgumentNullException(nameof(headerName));
187-
}
188-
189-
if (string.IsNullOrEmpty(headerValue))
190-
{
191-
throw new ArgumentNullException(nameof(headerValue));
192-
}
126+
Guard.ThrowIfNull(httpRequestMessage);
127+
Guard.ThrowIfNullOrEmpty(headerName);
128+
Guard.ThrowIfNullOrEmpty(headerValue);
193129

194130
if (httpRequestMessage.Content == null)
195131
{
@@ -206,10 +142,7 @@ internal static bool HasContentHeader(this HttpRequestMessage httpRequestMessage
206142
/// <returns>true when the request has content; otherwise, false.</returns>
207143
internal static bool HasContent(this HttpRequestMessage httpRequestMessage)
208144
{
209-
if (httpRequestMessage == null)
210-
{
211-
throw new ArgumentNullException(nameof(httpRequestMessage));
212-
}
145+
Guard.ThrowIfNull(httpRequestMessage);
213146

214147
return httpRequestMessage.Content != null;
215148
}
@@ -222,15 +155,8 @@ internal static bool HasContent(this HttpRequestMessage httpRequestMessage)
222155
/// <returns>true when the request content matches the pattern; otherwise, false.</returns>
223156
internal static bool HasContent(this HttpRequestMessage httpRequestMessage, string pattern)
224157
{
225-
if (httpRequestMessage == null)
226-
{
227-
throw new ArgumentNullException(nameof(httpRequestMessage));
228-
}
229-
230-
if (pattern == null)
231-
{
232-
throw new ArgumentNullException(nameof(pattern));
233-
}
158+
Guard.ThrowIfNull(httpRequestMessage);
159+
Guard.ThrowIfNull(pattern);
234160

235161
if (httpRequestMessage.Content == null)
236162
{

0 commit comments

Comments
 (0)