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

feat: use Meziantou.Polyfill to allow for nullable static analysis in HttpClientRequestResult #319

Merged
merged 1 commit into from
Jun 13, 2024
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
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