Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MemberNotNullWhen annotation for Content / HasContent pair #1779

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</ItemGroup>

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

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Refit.GeneratorTests/Refit.GeneratorTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PackageReference Include="System.Collections.Immutable" Version="9.0.0-preview.5.24306.7" />
<PackageReference Include="Verify.DiffPlex" Version="3.1.0" />
<PackageReference Include="Verify.SourceGenerators" Version="2.3.0" />
<PackageReference Include="Verify.Xunit" Version="22.11.5" />
<PackageReference Include="Verify.Xunit" Version="26.2.0" />
<PackageReference Include="System.Reactive" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.9.2" />
Expand Down
3 changes: 1 addition & 2 deletions Refit.GeneratorTests/ReturnTypeTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Refit.GeneratorTests;
namespace Refit.GeneratorTests;

[UsesVerify]
public class ReturnTypeTests
{
[Fact]
Expand Down
2 changes: 2 additions & 0 deletions Refit.Tests/API/ApiApprovalTests.Refit.DotNet6_0.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ namespace Refit
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) { }
public string? Content { get; }
public System.Net.Http.Headers.HttpContentHeaders? ContentHeaders { get; }
[System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, "Content")]
[get: System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, "Content")]
public bool HasContent { get; }
public System.Net.Http.Headers.HttpResponseHeaders Headers { get; }
public System.Net.Http.HttpMethod HttpMethod { get; }
Expand Down
2 changes: 2 additions & 0 deletions Refit.Tests/API/ApiApprovalTests.Refit.DotNet8_0.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ namespace Refit
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) { }
public string? Content { get; }
public System.Net.Http.Headers.HttpContentHeaders? ContentHeaders { get; }
[System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, "Content")]
[get: System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, "Content")]
public bool HasContent { get; }
public System.Net.Http.Headers.HttpResponseHeaders Headers { get; }
public System.Net.Http.HttpMethod HttpMethod { get; }
Expand Down
6 changes: 5 additions & 1 deletion Refit/ApiException.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Net;
using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;

Expand Down Expand Up @@ -53,6 +54,9 @@ public class ApiException : Exception
/// <summary>
/// Does the response have content?
/// </summary>
#if NET6_0_OR_GREATER
[MemberNotNullWhen(true, nameof(Content))]
#endif
public bool HasContent => !string.IsNullOrWhiteSpace(Content);

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "7.1.2",
"version": "7.2.0",
"publicReleaseRefSpec": [
"^refs/heads/main$", // we release out of main
"^refs/heads/rel/v\\d+\\.\\d+" // we also release branches starting with vN.N
Expand Down
Loading