NetEvolve.Analyzer
0.14.9
Prefix Reserved
dotnet add package NetEvolve.Analyzer --version 0.14.9
NuGet\Install-Package NetEvolve.Analyzer -Version 0.14.9
<PackageReference Include="NetEvolve.Analyzer" Version="0.14.9"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="NetEvolve.Analyzer" Version="0.14.9" />
<PackageReference Include="NetEvolve.Analyzer"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add NetEvolve.Analyzer --version 0.14.9
#r "nuget: NetEvolve.Analyzer, 0.14.9"
#:package NetEvolve.Analyzer@0.14.9
#addin nuget:?package=NetEvolve.Analyzer&version=0.14.9
#tool nuget:?package=NetEvolve.Analyzer&version=0.14.9
NetEvolve.Analyzer
Roslyn analyzers and code fixes for .NET, organized by the standard Microsoft diagnostic categories. It enforces consistent file organization and safer null-check idioms in C# code, with an automatic fix offered for every rule that has one.
Features
- File organization - one type per file, namespace matches folder structure, single namespace per file
- Null-check idioms -
is null/is not nullpatterns instead of== null,!= null, oris object - Code fixes - a fix is registered for every rule, gated to the language version it requires
- Batch fixes - a shared sequential Fix-All provider applies fixes across a document, project, or solution
- Configurable - MSBuild properties tune or fully disable the file-organization rules
- Zero footprint - a development dependency only; no runtime assembly is added to your project
Installation
NuGet Package Manager
Install-Package NetEvolve.Analyzer
.NET CLI
dotnet add package NetEvolve.Analyzer
PackageReference
<PackageReference Include="NetEvolve.Analyzer" Version="x.x.x" PrivateAssets="all" />
The package ships the analyzer assembly built separately against four Roslyn API versions (see
Supported Roslyn versions) and adds no runtime dependencies to your
project; PrivateAssets="all" keeps it from flowing to your own package consumers.
Quick Start
No code changes are required. Once the package reference is added, the analyzers run on every build
and report diagnostics under the NE prefix, for example:
warning NE0004: Use the 'is null' pattern instead of '== null'
Apply the offered code fix in your editor, or fix every occurrence at once with dotnet format:
dotnet format analyzers --diagnostics NE0004
Usage
Basic example
Given:
if (value == null)
{
return;
}
NE0004 reports the comparison and offers a code fix that rewrites it to:
if (value is null)
{
return;
}
File organization example
NE0001 and NE0002 keep a file's name and namespace aligned with its type and folder. A file at
Shapes/Circle.cs declaring namespace Geometry.Polygons; is flagged by NE0002 with a fix that
rewrites the namespace to Geometry.Shapes (the folder-derived value, anchored at RootNamespace).
Configuration
All configuration is done through standard MSBuild properties in your project file — no .editorconfig
entries are required.
<PropertyGroup>
<NetEvolveAnalyzerGroupGenericOverloads>true</NetEvolveAnalyzerGroupGenericOverloads>
<NetEvolveAnalyzerDisableFileOrganizationRules>true</NetEvolveAnalyzerDisableFileOrganizationRules>
</PropertyGroup>
The file-organization rules are also disabled automatically for single-file deployments
(PublishSingleFile=true).
To suppress an individual diagnostic instead:
#pragma warning disable NE0001
#pragma warning restore NE0001
Diagnostics
Every rule uses the NE identifier prefix and is documented under
docs/rules, with its cause, rule
description, fix guidance, and configuration options.
| Rule | Category | Description | Code fix |
|---|---|---|---|
| NE0001 | Maintainability | Declare one type per file with a matching file name | Yes |
| NE0002 | Maintainability | Namespace should match the folder structure | Yes |
| NE0003 | Maintainability | Declare a single namespace per file | Yes |
| NE0004 | Usage | Use the is null pattern instead of == null |
Yes |
| NE0005 | Usage | Use the is not null pattern instead of != null |
Yes |
| NE0006 | Usage | Use the is not null pattern instead of is object |
Yes |
| NE0007 | Documentation | Use <see langword="..."/> instead of <c>...</c> or <code>...</code> for C# keywords |
Yes |
| NE0008 | Documentation | Use <see cref="..."/> instead of <c>...</c> or <code>...</code> for native type names |
Yes |
| NE0009 | Usage | Check for cancellation at the start of a method with a CancellationToken parameter | Yes |
| NE0010 | Usage | Accept a CancellationToken parameter on a Task/ValueTask/IAsyncEnumerable-returning method | Yes |
| NE0011 | Style | Avoid #region directives |
Yes |
A DiagnosticSuppressor (NES0001) also ships alongside NE0007: it suppresses Meziantou.Analyzer's MA0154
wherever NE0007 already reports the same location, so a consumer running both analyzers doesn't get the
same violation twice — see docs/rules/NE0007.md.
See AnalyzerReleases.Shipped.md for the list of rules included in the
current release, and AnalyzerReleases.Unshipped.md for rules staged
for the next one.
Requirements
- A project compiling with a Roslyn-based compiler (any currently supported .NET SDK)
- No target-framework restriction on the consuming project — the analyzer runs against the compiler, not your project's target framework
Supported Roslyn versions
The analyzer's source is built separately against four Roslyn API (Microsoft.CodeAnalysis.CSharp)
versions — 4.4.0, 4.7.0, 4.14.0, and the latest, 5.6.0 — each packed into its own
analyzers/dotnet/roslynX.Y/cs folder. .NET SDKs from 8.0.400 onward select the highest version they
support automatically; you don't need to configure anything.
SDKs that predate this selection feature don't load any analyzer build from this package (rather than an incorrect or duplicated one) — in practice this only affects unpatched, out-of-support SDKs, since the selection logic lives in the NuGet client bundled with the SDK and has been serviced into every currently maintained release, including older LTS versions like .NET 6.
Documentation
For the full solution documentation, see the repository README.
Contributing
Contributions are welcome! Please read the Contributing Guidelines before submitting a pull request.
Support
- Issues: Report bugs or request features on GitHub Issues
- Documentation: Read the full documentation at https://github.com/dailydevops/analyzer
License
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by the NetEvolve Team Visit us at https://www.daily-devops.net for more information about our services and solutions.
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.