ZeroAlloc.Analyzers 1.11.3

dotnet add package ZeroAlloc.Analyzers --version 1.11.3
                    
NuGet\Install-Package ZeroAlloc.Analyzers -Version 1.11.3
                    
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="ZeroAlloc.Analyzers" Version="1.11.3">
  <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="ZeroAlloc.Analyzers" Version="1.11.3" />
                    
Directory.Packages.props
<PackageReference Include="ZeroAlloc.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 ZeroAlloc.Analyzers --version 1.11.3
                    
#r "nuget: ZeroAlloc.Analyzers, 1.11.3"
                    
#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 ZeroAlloc.Analyzers@1.11.3
                    
#: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=ZeroAlloc.Analyzers&version=1.11.3
                    
Install as a Cake Addin
#tool nuget:?package=ZeroAlloc.Analyzers&version=1.11.3
                    
Install as a Cake Tool

ZeroAlloc.Analyzers

NuGet Build codecov License: MIT AOT GitHub Sponsors

Roslyn analyzers that catch allocations and NativeAOT breakers at compile time: 64 rules for the performance patterns the built-in .NET analyzers miss, each silenced automatically where your target framework can't use the fix.

Why ZeroAlloc.Analyzers

  • Find allocations in the build, not in a profiler. Boxing in string concatenation, LINQ in loops, double dictionary lookups, closures, uncached delegates and missed FrozenDictionary opportunities show up as warnings where you write the code.
  • Catch NativeAOT breakers early. The ZA17xx rules flag Expression.Compile, Reflection.Emit, reflection-based serializers, dynamic and assembly-scanning registration before a trimmed or AOT publish fails.
  • Every diagnostic is actionable. Rules that need .NET 5, 6, 7, 8 or 9, or a newer C# version, are silenced on older targets, so you never see a fix for an API you can't call.
  • A few percent of build time. On a 240-file sample, a median of +2.1% for a full net8.0 build and +2.9% for a one-file edit; a build with no changes runs no analyzers at all.

Install

dotnet add package ZeroAlloc.Analyzers

It is a development dependency: nothing flows to your consumers, and there is no runtime assembly.

Quick start

Build, and the diagnostics appear in dotnet build, Visual Studio, Rider and VS Code with C# Dev Kit:

public sealed class PriceCache
{
    private readonly Dictionary<string, decimal> _prices = new();

    public decimal Get(string sku)
    {
        // warning ZA0105: Use 'TryGetValue' instead of 'ContainsKey' followed by indexer access
        if (_prices.ContainsKey(sku))
            return _prices[sku];
        return 0m;
    }
}

Apply the code fix from the lightbulb, or with dotnet format, and the two lookups become one:

        if (_prices.TryGetValue(sku, out var value))
            return value;

What you get

Performance

Build overhead on a 240-file, 18,000-line sample, relative to the same project built without the package; median of 15 interleaved pairs.

Target Full build One-file edit
net8.0 +2.1% +2.9%
net8.0 + netstandard2.0 +4.3% +5.4%
netstandard2.0 +10.5% +23.0%

A build with no changes does not run the compiler, so the analyzers add no work. The overhead is largest on netstandard2.0, where the SDK's own analyzers don't run and the build is smaller.

How many rules run per target, the spread, the environment, the harness to reproduce it and tips for fast local builds: docs/performance.md.

Learn more

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has 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
1.11.3 42 10/23/2026
1.11.2 12,881 10/16/2026
1.11.1 3,064 10/15/2026
1.11.0 17,380 10/10/2026
1.10.0 192 10/10/2026
1.9.0 1,397 10/9/2026
1.8.0 189 10/9/2026
1.7.0 242 10/9/2026
1.6.0 135 10/9/2026
1.5.6 971 10/9/2026
1.5.5 239 10/9/2026
1.5.4 20,952 9/25/2026
1.5.3 5,351 9/20/2026
1.5.2 1,071 9/19/2026
1.5.1 152 9/19/2026
1.5.0 11,776 6/27/2026
1.4.0 212 6/27/2026
1.3.15 4,426 4/29/2026
1.3.14 432 4/28/2026
1.3.13 390 4/20/2026
Loading failed