ZeroAlloc.Analyzers.Package
1.0.0
dotnet add package ZeroAlloc.Analyzers.Package --version 1.0.0
NuGet\Install-Package ZeroAlloc.Analyzers.Package -Version 1.0.0
<PackageReference Include="ZeroAlloc.Analyzers.Package" Version="1.0.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="ZeroAlloc.Analyzers.Package" Version="1.0.0" />
<PackageReference Include="ZeroAlloc.Analyzers.Package"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add ZeroAlloc.Analyzers.Package --version 1.0.0
#r "nuget: ZeroAlloc.Analyzers.Package, 1.0.0"
#:package ZeroAlloc.Analyzers.Package@1.0.0
#addin nuget:?package=ZeroAlloc.Analyzers.Package&version=1.0.0
#tool nuget:?package=ZeroAlloc.Analyzers.Package&version=1.0.0
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.
Work in progress — not yet published to NuGet.
Installation
<PackageReference Include="ZeroAlloc.Analyzers.Package" 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 |
| 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 |
| 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 |
| 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 |
| 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 35 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-ZA0107, ZA0201-ZA0203, ZA0301, ZA0302, ZA0501, ZA0502, ZA0504, ZA0601-ZA0605, ZA0801-ZA0803, ZA0901, ZA1101, ZA1102, ZA1401, ZA1501, ZA1502 |
| < net5.0 | ZA0105-ZA0107, ZA0201, ZA0202, ZA0301, ZA0302, ZA0501, ZA0502, ZA0504, ZA0601-ZA0605, ZA0802, ZA0803, ZA0901, ZA1101, ZA1102, ZA1501, ZA1502 |
License
MIT
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 |
|---|