BareWire.Analyzers
2.0.4
dotnet add package BareWire.Analyzers --version 2.0.4
NuGet\Install-Package BareWire.Analyzers -Version 2.0.4
<PackageReference Include="BareWire.Analyzers" Version="2.0.4"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="BareWire.Analyzers" Version="2.0.4" />
<PackageReference Include="BareWire.Analyzers"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add BareWire.Analyzers --version 2.0.4
#r "nuget: BareWire.Analyzers, 2.0.4"
#:package BareWire.Analyzers@2.0.4
#addin nuget:?package=BareWire.Analyzers&version=2.0.4
#tool nuget:?package=BareWire.Analyzers&version=2.0.4
BareWire.Analyzers
Roslyn analyzers that enforce coding conventions from CONSTITUTION.md at compile time.
Rules
BW1001 — CancellationToken propagation
Severity: Warning
Category: BareWire.Async
Every public method returning Task, ValueTask, Task<T>, or ValueTask<T> must accept
CancellationToken as its last parameter. This allows callers to cancel long-running
operations and propagate cancellation across the call stack.
Before (triggers BW1001)
public class OrderService
{
// BW1001: public async method missing CancellationToken
public async Task PlaceOrderAsync(string orderId)
{
await Task.Delay(100);
}
}
After (compliant)
public class OrderService
{
public async Task PlaceOrderAsync(string orderId, CancellationToken cancellationToken = default)
{
await Task.Delay(100, cancellationToken);
}
}
Code fix
A code fix is provided. Apply it from the lightbulb menu in your IDE to automatically append
CancellationToken cancellationToken = default to the method's parameter list and add the
using System.Threading; import if needed.
Suppression
To suppress the warning for a specific method when CancellationToken is genuinely not applicable:
#pragma warning disable BW1001
public Task FireAndForgetAsync() { ... }
#pragma warning restore BW1001
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.