Skip to content

Commit 1c56e32

Browse files
Add MemberNotNullWhen annotation for Content / HasContent pair (#1779)
* Add MemberNotNullWhen annotation for Content / HasContent pair * Add missing using statement * Update API Tests Bump Version due to API change --------- Co-authored-by: Chris Pulman <chris.pulman@yahoo.com>
1 parent c7b8301 commit 1c56e32

7 files changed

Lines changed: 13 additions & 6 deletions

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</ItemGroup>
3737

3838
<ItemGroup Condition="'$(IsTestProject)' != 'true'">
39-
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.10.48" PrivateAssets="All" />
39+
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.11.20" PrivateAssets="All" />
4040
</ItemGroup>
4141

4242
<ItemGroup>

Refit.GeneratorTests/Refit.GeneratorTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<PackageReference Include="System.Collections.Immutable" Version="9.0.0-preview.5.24306.7" />
2121
<PackageReference Include="Verify.DiffPlex" Version="3.1.0" />
2222
<PackageReference Include="Verify.SourceGenerators" Version="2.3.0" />
23-
<PackageReference Include="Verify.Xunit" Version="22.11.5" />
23+
<PackageReference Include="Verify.Xunit" Version="26.2.0" />
2424
<PackageReference Include="System.Reactive" Version="6.0.1" />
2525
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
2626
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.9.2" />

Refit.GeneratorTests/ReturnTypeTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
namespace Refit.GeneratorTests;
1+
namespace Refit.GeneratorTests;
22

3-
[UsesVerify]
43
public class ReturnTypeTests
54
{
65
[Fact]

Refit.Tests/API/ApiApprovalTests.Refit.DotNet6_0.verified.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ namespace Refit
1818
protected ApiException(string exceptionMessage, System.Net.Http.HttpRequestMessage message, System.Net.Http.HttpMethod httpMethod, string? content, System.Net.HttpStatusCode statusCode, string? reasonPhrase, System.Net.Http.Headers.HttpResponseHeaders headers, Refit.RefitSettings refitSettings, System.Exception? innerException = null) { }
1919
public string? Content { get; }
2020
public System.Net.Http.Headers.HttpContentHeaders? ContentHeaders { get; }
21+
[System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, "Content")]
22+
[get: System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, "Content")]
2123
public bool HasContent { get; }
2224
public System.Net.Http.Headers.HttpResponseHeaders Headers { get; }
2325
public System.Net.Http.HttpMethod HttpMethod { get; }

Refit.Tests/API/ApiApprovalTests.Refit.DotNet8_0.verified.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ namespace Refit
1818
protected ApiException(string exceptionMessage, System.Net.Http.HttpRequestMessage message, System.Net.Http.HttpMethod httpMethod, string? content, System.Net.HttpStatusCode statusCode, string? reasonPhrase, System.Net.Http.Headers.HttpResponseHeaders headers, Refit.RefitSettings refitSettings, System.Exception? innerException = null) { }
1919
public string? Content { get; }
2020
public System.Net.Http.Headers.HttpContentHeaders? ContentHeaders { get; }
21+
[System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, "Content")]
22+
[get: System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, "Content")]
2123
public bool HasContent { get; }
2224
public System.Net.Http.Headers.HttpResponseHeaders Headers { get; }
2325
public System.Net.Http.HttpMethod HttpMethod { get; }

Refit/ApiException.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Net;
1+
using System.Diagnostics.CodeAnalysis;
2+
using System.Net;
23
using System.Net.Http;
34
using System.Net.Http.Headers;
45

@@ -53,6 +54,9 @@ public class ApiException : Exception
5354
/// <summary>
5455
/// Does the response have content?
5556
/// </summary>
57+
#if NET6_0_OR_GREATER
58+
[MemberNotNullWhen(true, nameof(Content))]
59+
#endif
5660
public bool HasContent => !string.IsNullOrWhiteSpace(Content);
5761

5862
/// <summary>

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "7.1.2",
2+
"version": "7.2.0",
33
"publicReleaseRefSpec": [
44
"^refs/heads/main$", // we release out of main
55
"^refs/heads/rel/v\\d+\\.\\d+" // we also release branches starting with vN.N

0 commit comments

Comments
 (0)