BareWire.Analyzers 2.0.4

dotnet add package BareWire.Analyzers --version 2.0.4
                    
NuGet\Install-Package BareWire.Analyzers -Version 2.0.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BareWire.Analyzers" Version="2.0.4">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BareWire.Analyzers" Version="2.0.4" />
                    
Directory.Packages.props
<PackageReference Include="BareWire.Analyzers">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BareWire.Analyzers --version 2.0.4
                    
#r "nuget: BareWire.Analyzers, 2.0.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BareWire.Analyzers@2.0.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BareWire.Analyzers&version=2.0.4
                    
Install as a Cake Addin
#tool nuget:?package=BareWire.Analyzers&version=2.0.4
                    
Install as a Cake Tool

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
There are no supported framework assets in this package.

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.

Version Downloads Last Updated
2.0.4 141 6/29/2026
2.0.3 118 6/28/2026
2.0.2 114 6/28/2026
2.0.1 114 6/28/2026
2.0.0 121 6/27/2026
1.5.1 115 6/23/2026