Skip to content

Commit

Permalink
feat: use Meziantou.Polyfill to allow for nullable static analysis in…
Browse files Browse the repository at this point in the history
… HttpClientRequestResult
  • Loading branch information
JMolenkamp committed Jun 13, 2024
1 parent 523a045 commit 03aa612
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Atc/Atc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Meziantou.Polyfill" Version="1.0.38">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
Expand Down Expand Up @@ -70,4 +74,8 @@
</EmbeddedResource>
</ItemGroup>

<PropertyGroup>
<MeziantouPolyfill_IncludedPolyfills>T:System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute</MeziantouPolyfill_IncludedPolyfills>
</PropertyGroup>

</Project>
3 changes: 3 additions & 0 deletions src/Atc/Data/Models/HttpClientRequestResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,15 @@ public HttpClientRequestResult(

public Exception? Exception { get; set; }

[MemberNotNullWhen(true, nameof(Data))]
public bool HasData
=> Data is not null;

[MemberNotNullWhen(true, nameof(Message))]
public bool HasMessage
=> !string.IsNullOrEmpty(Message);

[MemberNotNullWhen(true, nameof(Exception))]
public bool HasException
=> Exception is not null;

Expand Down

0 comments on commit 03aa612

Please sign in to comment.