NetEvolve.Arguments.Analyser
3.3.0
Prefix Reserved
dotnet add package NetEvolve.Arguments.Analyser --version 3.3.0
NuGet\Install-Package NetEvolve.Arguments.Analyser -Version 3.3.0
<PackageReference Include="NetEvolve.Arguments.Analyser" Version="3.3.0" />
<PackageVersion Include="NetEvolve.Arguments.Analyser" Version="3.3.0" />
<PackageReference Include="NetEvolve.Arguments.Analyser" />
paket add NetEvolve.Arguments.Analyser --version 3.3.0
#r "nuget: NetEvolve.Arguments.Analyser, 3.3.0"
#:package NetEvolve.Arguments.Analyser@3.3.0
#addin nuget:?package=NetEvolve.Arguments.Analyser&version=3.3.0
#tool nuget:?package=NetEvolve.Arguments.Analyser&version=3.3.0
NetEvolve.Arguments.Analyser
A Roslyn analyzer and code-fix package that promotes usage of NetEvolve.Arguments throw-helper APIs, rewriting manual argument-validation if blocks on every target framework — including .NET Standard 2.0 and .NET Framework 4.7.2+, which predate the built-in CA1510/CA1511/CA1512/CA1513 analyzers.
Features
- 9 analyzer rules (NEA0001-NEA0009) - Covers null checks, string/collection validation, numeric ranges,
Guid, and disposed-object checks - Works everywhere - Unlike the built-in Roslyn rules, these analyzers fire regardless of target framework, since NetEvolve.Arguments polyfills the throw-helper APIs on frameworks that predate them
- No duplicate diagnostics - Rules that mirror a built-in CA rule (NEA0001, NEA0002, NEA0003, NEA0005) automatically stay silent once the compilation already exposes the real BCL member, so CA1510/CA1511/CA1512/CA1513 take over seamlessly
- One-click code fixes - Every diagnostic ships with a code fix that rewrites the offending
ifblock in place, usable per-occurrence or via Fix All in Document/Project/Solution scope - Recognizes common variants - Null checks match
is null,==,ReferenceEquals, negated forms, and null-coalescing throws (arg ?? throw ...)
Installation
NuGet Package Manager
Install-Package NetEvolve.Arguments.Analyser
.NET CLI
dotnet add package NetEvolve.Arguments.Analyser
PackageReference
<PackageReference Include="NetEvolve.Arguments.Analyser" PrivateAssets="all" />
Quick Start
using System;
public class UserService
{
public void CreateUser(string username, int age)
{
// NEA0001 suggests replacing this with ArgumentNullException.ThrowIfNull(username)
if (username is null)
{
throw new ArgumentNullException(nameof(username));
}
// NEA0003 suggests replacing this with ArgumentOutOfRangeException.ThrowIfNegative(age)
if (age < 0)
{
throw new ArgumentOutOfRangeException(nameof(age));
}
}
}
Rules
Each rule has a dedicated documentation page with the full list of recognized shapes, examples, and suppression instructions.
| Rule | Title | Mirrors |
|---|---|---|
| NEA0001 | Use ArgumentNullException.ThrowIfNull | CA1510 |
| NEA0002 | Use ArgumentException throw helper | CA1511 |
| NEA0003 | Use ArgumentOutOfRangeException throw helper | CA1512 |
| NEA0004 | Use ArgumentException.ThrowIfDefault | (NetEvolve.Arguments-only, no CA equivalent) |
| NEA0005 | Use ObjectDisposedException.ThrowIf | CA1513 |
| NEA0006 | Use ArgumentException string-length throw helper | (NetEvolve.Arguments-only, no CA equivalent) |
| NEA0007 | Use ArgumentException collection-count throw helper | (NetEvolve.Arguments-only, no CA equivalent) |
| NEA0008 | Use ArgumentException.ThrowIfContainsWhiteSpace | (NetEvolve.Arguments-only, no CA equivalent) |
| NEA0009 | Use ArgumentException.ThrowIfEmptyGuid | (NetEvolve.Arguments-only, no CA equivalent) |
Example: NEA0001 (null check)
// Before
if (argument is null) throw new ArgumentNullException(nameof(argument));
// After
ArgumentNullException.ThrowIfNull(argument);
Example: NEA0003 (range check)
// Before
if (age < 0) throw new ArgumentOutOfRangeException(nameof(age));
// After
ArgumentOutOfRangeException.ThrowIfNegative(age);
Example: NEA0007 (collection count)
// Before
if (items.Count > 100) throw new ArgumentException(nameof(items));
// After
ArgumentException.ThrowIfCountGreaterThan(items, 100);
Not covered
A few NetEvolve.Arguments throw-helpers don't have a dedicated rule, because their manual equivalents can be written in too many syntactically different ways to detect reliably without false negatives or false positives:
ArgumentException.ThrowIfNullOrEmptyfor collections (IEnumerable<T>/ICollection<T>/IReadOnlyCollection<T>/T[])ArgumentException.ThrowIfContainsDuplicatesArgumentOutOfRangeException.ThrowIfInPast/ThrowIfInFuture
See the open issues for tracking status.
Requirements
- .NET Standard 2.0 or higher for the analyzed project
- Visual Studio 2022 17.8+, Rider, or any IDE/CLI supporting Roslyn source analyzers
Related Packages
- NetEvolve.Arguments - The polyfill library this analyzer promotes usage of
Documentation
For complete solution documentation, architecture decisions, and contributing guidelines, visit the Arguments Repository.
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/arguments
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.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- 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 |
|---|---|---|
| 3.3.0 | 47 | 7/23/2026 |