feat(analyser): add NetEvolve.Arguments.Analyser project#724
Merged
Conversation
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Add a Roslyn analyzer and code-fix package (NEA0001-NEA0009) that promotes NetEvolve.Arguments throw-helper usage on every supported target framework, including those that predate the built-in CA1510/CA1511/CA1512/CA1513 analyzers. - NEA0001: ArgumentNullException.ThrowIfNull (mirrors CA1510) - NEA0002: ArgumentException.ThrowIfNullOrEmpty/ThrowIfNullOrWhiteSpace (mirrors CA1511) - NEA0003: ArgumentOutOfRangeException throw helpers, incl. combined-range ThrowIfOutOfRange (mirrors CA1512) - NEA0004: ArgumentException.ThrowIfDefault - NEA0005: ObjectDisposedException.ThrowIf (mirrors CA1513) - NEA0006: ArgumentException string-length throw helpers - NEA0007: ArgumentException collection-count throw helpers - NEA0008: ArgumentException.ThrowIfContainsWhiteSpace - NEA0009: ArgumentException.ThrowIfEmptyGuid Rules mirroring a built-in CA rule stay silent once the compilation already exposes the real BCL member, avoiding duplicate diagnostics. Wired the analyzer into NetEvolve.Arguments itself for dogfooding, and added per-rule documentation under docs/analysers.
Fix the Release-configuration build failures surfaced by CI: - Restore the exact unpadded pipe-table format AnalyzerReleases.*.md needs for RS2007 (SonarAnalyzer/editor auto-formatting had reflowed the tables into padded Markdown, which the release-tracking parser rejects). - Reword a comment that SonarAnalyzer's S125 misidentified as commented-out code. - Replace two nested ternaries flagged by S3358 with explicit if/else chains.
Add summary documentation (public and private members alike) across the analyser package's source files: descriptors, syntax helpers, and every analyzer/code-fix pair. test(analyser): broaden negative-path coverage Add negative-path tests for each rule (else clause present, wrong exception type, custom-message constructor, unrecognized condition shapes, combined-range mismatches) plus a positive case for the literal-paramName branch. Consolidated related negative cases into parametrized [Arguments] tests instead of one method per case. Raises analyser-project coverage from 84.3%/59.7% to 89.1%/73.3% (line/branch).
Add tests for parenthesized conditions, qualified ReferenceEquals, null != argument (both polarities), zero-argument/mismatched-nameof exception constructors, rejected coalesce shapes (wrong exception type, custom message), and a non-literal ArgumentOutOfRangeException bound.
ArgumentException(string? message, string? paramName) takes the message first and the parameter name second (the reverse of ArgumentNullException). Two tests had the arguments swapped.
samtrion
force-pushed
the
feature/analyser
branch
from
July 23, 2026 15:12
6e19476 to
f8fb88c
Compare
Every rule's Analyze method repeated the same else-check / single-throw / exception-type guard chain. Extract it into SyntaxHelpers.TryGetThrownException and reuse it across all 9 analyzers, and split ThrowIfOutOfRangeAnalyzer's combined-range detection into its own method. Addresses CodeFactor's cyclomatic-complexity findings on ThrowIfOutOfRangeAnalyzer.Analyze/TryGetComparison, ThrowIfEmptyGuidAnalyzer.Analyze, ThrowIfNullAnalyzer.Analyze, and ThrowIfDefaultAnalyzer.Analyze, while also removing duplicated logic across the other analyzers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NetEvolve.Arguments.Analyser, with 9 rules (NEA0001-NEA0009) that promoteNetEvolve.Argumentsthrow-helper usage across every supported target framework.ThrowIfDefault, string-length/collection-count comparisons,ThrowIfContainsWhiteSpace,ThrowIfEmptyGuid).docs/analysers/NEA0001.md-NEA0009.md.NetEvolve.Arguments.csprojitself (as anAnalyzer-onlyProjectReference) for dogfooding.NetEvolve.Arguments.Analyser.Tests.Unitwith a hand-rolledCompilationWithAnalyzers/AdhocWorkspaceharness (no official TUnit-based Roslyn testing package exists), covering all 9 rules plus the built-in-analyzer suppression gate.Not covered (documented in the README)
A few throw-helpers don't have a rule because their manual equivalents can be written in too many syntactically different ways to detect reliably:
ArgumentException.ThrowIfNullOrEmptyfor collectionsArgumentException.ThrowIfContainsDuplicatesArgumentOutOfRangeException.ThrowIfInPast/ThrowIfInFutureTest plan
dotnet build Arguments.slnx— 0 errors, 0 warningsdotnet test --solution Arguments.slnx— 1673/1673 passing across all target frameworks (net472/net48/net481/net6.0-net10.0/netstandard2.0 for the library, net10.0 for the analyzer tests)