ZeroAlloc.Analyzers
1.3.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package ZeroAlloc.Analyzers --version 1.3.0
NuGet\Install-Package ZeroAlloc.Analyzers -Version 1.3.0
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.3.0"> <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.3.0" />
<PackageReference Include="ZeroAlloc.Analyzers"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
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.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ZeroAlloc.Analyzers, 1.3.0"
#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.3.0
#: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.3.0
#tool nuget:?package=ZeroAlloc.Analyzers&version=1.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ZeroAlloc Analyzers
Roslyn analyzers for modern .NET performance patterns with multi-TFM awareness. Detects allocation-heavy patterns that existing analyzers miss and suggests zero/low-allocation alternatives.
Installation
<PackageReference Include="ZeroAlloc.Analyzers" Version="1.0.0" PrivateAssets="all" />
Rules
| ID | Description | Severity | Min TFM |
|---|---|---|---|
| ZA01xx — Collections | |||
| ZA0101 | Use FrozenDictionary for read-only dictionary | Info | net8.0 |
| ZA0102 | Use FrozenSet for read-only set | Info | net8.0 |
| ZA0103 | Use CollectionsMarshal.AsSpan for List iteration | Info | net5.0 |
| ZA0104 | Use SearchValues/FrozenSet for repeated lookups | Info | net8.0 |
| ZA0105 | Use TryGetValue instead of ContainsKey + indexer | Warning | Any |
| ZA0106 | Avoid premature ToList/ToArray before LINQ | Warning | Any |
| ZA0107 | Pre-size collections when capacity is known | Info | Any |
| ZA0108 | Avoid redundant ToList/ToArray materialization | Warning | Any |
| ZA0109 | Avoid zero-length array allocation, use Array.Empty<T>() | Warning | Any |
| ZA02xx — Strings | |||
| ZA0201 | Avoid string concatenation in loops | Warning | Any |
| ZA0202 | Avoid chained string.Replace calls | Info | Any |
| ZA0203 | Use AsSpan instead of Substring | Info | net5.0 |
| ZA0204 | Use string.Create instead of string.Format | Info | net6.0 |
| ZA0205 | Use CompositeFormat for repeated format strings | Info | net8.0 |
| ZA0206 | Avoid span.ToString() before Parse | Info | net6.0 |
| ZA0208 | Avoid string.Join overload that boxes non-string elements | Warning | Any |
| ZA0209 | Avoid value type boxing in string concatenation | Warning | Any |
| ZA03xx — Memory | |||
| ZA0301 | Use stackalloc for small fixed-size arrays | Info | Any |
| ZA0302 | Use ArrayPool for large temporary arrays | Info | Any |
| ZA04xx — Logging | |||
| ZA0401 | Use LoggerMessage source generator | Info | net6.0 |
| ZA05xx — Boxing | |||
| ZA0501 | Avoid boxing value types in loops | Warning | Any |
| ZA0502 | Avoid closure allocations in loops | Info | Any |
| ZA0504 | Avoid defensive copies on in/readonly structs | Info | Any |
| ZA06xx — LINQ & Params | |||
| ZA0601 | Avoid LINQ methods in loops | Warning | Any |
| ZA0602 | Avoid params calls in loops | Info | Any |
| ZA0603 | Use .Count/.Length instead of LINQ .Count() | Info | Any |
| ZA0604 | Use .Count > 0 instead of LINQ .Any() | Info | Any |
| ZA0605 | Use indexer instead of LINQ .First()/.Last() | Info | Any |
| ZA0606 | Avoid foreach over interface-typed collection variable | Warning | Any |
| ZA0607 | Avoid multiple enumeration of IEnumerable<T> | Warning | Any |
| ZA07xx — Regex | |||
| ZA0701 | Use GeneratedRegex for compile-time regex | Info | net7.0 |
| ZA08xx — Enums | |||
| ZA0801 | Avoid Enum.HasFlag (boxing on < net7.0) | Info | < net7.0 |
| ZA0802 | Avoid Enum.ToString() allocations | Info | Any |
| ZA0803 | Cache Enum.GetName/GetValues in loops | Info | Any |
| ZA09xx — Sealing | |||
| ZA0901 | Consider sealing classes for devirtualization | Info | Any |
| ZA10xx — Serialization | |||
| ZA1001 | Use JSON source generation instead of reflection | Info | net7.0 |
| ZA11xx — Async | |||
| ZA1101 | Elide async/await on simple tail calls | Info | Any |
| ZA1102 | Dispose CancellationTokenSource | Info | Any |
| ZA1104 | Avoid Span<T> in async methods, use Memory<T> instead | Warning | Any |
| ZA14xx — Delegates | |||
| ZA1401 | Use static lambda when no capture needed | Info | net5.0 |
| ZA15xx — Value Types | |||
| ZA1501 | Override GetHashCode on struct dictionary keys | Info | Any |
| ZA1502 | Avoid finalizers, use IDisposable | Info | Any |
TFM Compatibility
Rules are automatically enabled/disabled based on your project's TargetFramework. The package includes a .props file that flows TargetFramework to the analyzers via CompilerVisibleProperty.
| TFM | Active Rules |
|---|---|
| net8.0+ | All 42 rules |
| net7.0 | All except ZA0101, ZA0102, ZA0104, ZA0205, ZA0801 |
| net6.0 | All except ZA0101, ZA0102, ZA0104, ZA0205, ZA0701, ZA0801, ZA1001 |
| net5.0 | ZA0103, ZA0105-ZA0109, ZA0201-ZA0203, ZA0208, ZA0209, ZA0301, ZA0302, ZA0501, ZA0502, ZA0504, ZA0601-ZA0607, ZA0801-ZA0803, ZA0901, ZA1101, ZA1102, ZA1104, ZA1401, ZA1501, ZA1502 |
| < net5.0 | ZA0105-ZA0109, ZA0201, ZA0202, ZA0208, ZA0209, ZA0301, ZA0302, ZA0501, ZA0502, ZA0504, ZA0601-ZA0607, ZA0802, ZA0803, ZA0901, ZA1101, ZA1102, ZA1104, ZA1501, ZA1502 |
License
MIT
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.3.12 | 0 | 3/22/2026 |
| 1.3.11 | 41 | 3/20/2026 |
| 1.3.10 | 28 | 3/20/2026 |
| 1.3.9 | 34 | 3/20/2026 |
| 1.3.8 | 35 | 3/19/2026 |
| 1.3.7 | 37 | 3/19/2026 |
| 1.3.6 | 112 | 3/17/2026 |
| 1.3.5 | 79 | 3/16/2026 |
| 1.3.4 | 76 | 3/16/2026 |
| 1.3.3 | 82 | 3/16/2026 |
| 1.3.2 | 81 | 3/15/2026 |
| 1.3.1 | 284 | 3/13/2026 |
| 1.3.0 | 79 | 3/13/2026 |
| 1.2.0 | 81 | 3/13/2026 |
| 1.1.0 | 81 | 3/10/2026 |
| 1.0.3 | 122 | 3/9/2026 |
| 1.0.2 | 248 | 3/8/2026 |
| 1.0.1 | 82 | 3/8/2026 |