CallgraphClosure.MustNotBlock 0.1.0-preview1

This is a prerelease version of CallgraphClosure.MustNotBlock.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package CallgraphClosure.MustNotBlock --version 0.1.0-preview1
                    
NuGet\Install-Package CallgraphClosure.MustNotBlock -Version 0.1.0-preview1
                    
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="CallgraphClosure.MustNotBlock" Version="0.1.0-preview1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CallgraphClosure.MustNotBlock" Version="0.1.0-preview1" />
                    
Directory.Packages.props
<PackageReference Include="CallgraphClosure.MustNotBlock" />
                    
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 CallgraphClosure.MustNotBlock --version 0.1.0-preview1
                    
#r "nuget: CallgraphClosure.MustNotBlock, 0.1.0-preview1"
                    
#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 CallgraphClosure.MustNotBlock@0.1.0-preview1
                    
#: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=CallgraphClosure.MustNotBlock&version=0.1.0-preview1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=CallgraphClosure.MustNotBlock&version=0.1.0-preview1&prerelease
                    
Install as a Cake Tool

CallgraphClosure.MustNotBlock

A Roslyn analyzer (plus optional Cecil IL post-pass) that enforces a [MustNotBlock] contract on annotated methods. Flags Thread.Sleep, Task.Wait/.Result, sync-over-async patterns, and unannotated calls reachable through the transitive call closure.

Pre-release. Early-stage package; APIs may change. See the repo's docs/ROADMAP.md for known limits.

Install

dotnet add package CallgraphClosure.MustNotBlock --prerelease

Use

using CallgraphClosure.Attributes;

internal sealed class Ticker
{
    [MustNotBlock]
    public int Tick()
    {
        Thread.Sleep(10);              // CGC003: synchronous block
        return ComputeAsync().Result;  // CGC003: sync-over-async + CGC001: unannotated callee
    }

    private async Task<int> ComputeAsync() => await Task.FromResult(42);
}

Diagnostics:

ID Meaning
CGC001 Annotated method calls an unannotated method — annotate the callee or stop calling it
CGC002 Annotated method calls an external method whose status the analyzer can't verify; resolved by the IL post-pass
CGC003 Annotated method directly performs a blocking operation

Repo

github.com/pawlos/covenant — full design notes, IL post-pass details, and sibling property analyzers (MustNotAllocate, MustNotThrow, MustNotRecurse).

MIT licensed.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on CallgraphClosure.MustNotBlock:

Package Downloads
CallgraphClosure

Meta-package for the CallgraphClosure family of property analyzers. Installing this pulls in all four current properties (MustNotAllocate, MustNotThrow, MustNotBlock, MustNotRecurse). Pre-release.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-preview2 60 5/25/2026
0.1.0-preview1 64 5/18/2026