Skip to content

feat(analyzers): read C# skips from a reviewable table (spec 015 phase 1) - #194

Merged
adrian-xping merged 2 commits into
feat/spec-015-csharp-skip-extractionfrom
phase/spec-015-csharp-skip-extraction/1-skips
Dec 4, 2026
Merged

adrian-xping merged 2 commits into
feat/spec-015-csharp-skip-extractionfrom
phase/spec-015-csharp-skip-extraction/1-skips

Conversation

@adrian-xping

Copy link
Copy Markdown
Contributor

Spec 015 (docs/specs/core/015-csharp-skip-extraction.md), phase 1: Skips.

Phase 1 of Spec 015: the analyzer now fills skip for C# tests. A new embedded table (Skips/skips.json, 46 rows for xUnit v2/v3, NUnit 3/4, MSTest 3/4) is loaded and validated by SkipPatterns (§4.5). SkipExtractor reads candidates from the test's attributes, the declaring class's attributes, named arguments (with modifier rows such as SkipWhen, Until, Reason), and skip calls and throws in the body; it decodes reasons verbatim (§6), applies reach rules (branches, lambdas, swallowing catches, §7) and picks one skip (§8). SkipFact gains cases; the catalog fixture has a [TestCase(…, Ignore = …)] test so TheFixturesUseEveryField covers it. Seven samples/skips/ folders (xunit, nunit, mstest, case-skips, reach without helpers, precedence, not-skips) pin the behaviour, with unit tests for every §14 skip test except the helper one.

Notes

  • Refactor: Spec 014's name lookup (locals, helper parameters, const/readonly fields, get-only properties) moved out of TimeValues into Timeouts/NameLookup, unchanged in behaviour; TimeValues and the new Skips/ArgumentValues (string/null/bool folding) both use it. All timeout tests still pass. Spec §15 updated.
  • skips.json has a top-level versions field as the 'header' §5 asks for (JSON has no comments); the loader accepts only rows and versions. Spec §4.1 updated.
  • Validation is slightly stricter than §4.5 listed: a modifier row must be a namedArgument row (an attribute modifier was undefined), call/throw rows can't have attributes/value/properties or be read on a class, attribute rows can't have attributes/value/throws. Spec §4.5 updated; each rule has an in-test table.
  • Assume.That(c, message): the message is read as the reason. §5.2 didn't say; updated to say so.
  • The case-skips fixture uses [SkippableTheory] for its xUnit tests: the file's NUnit TestCase is an NUnit signal, which makes a bare Theory NUnit's under Spec 012 §4.3. A comment in the fixture says why.
  • The facts-fixture check TheAnalyzerReproducesTheSkipAndDisabledPartOfEveryFactsFixture compares the skip of live tests only for now (TODO(spec) for phase 2 to add disabled tests). The new catalog test's assertion carries a hand-written valueOrigin: realCall like its neighbours (Spec 016's field).
  • await …ConfigureAwait(…) reach handling is implemented but only exercised by phase 3's helper fixture (no table row is awaitable).

Spec updated: yes

Phase row
Phase Branch suffix Covers Tests Depends on
1. Skips 1-skips §3–§8, §11 (skips): the table and loader, attributes, named arguments, case skips, runtime calls in the body, reasons, reach, precedence, SkipFact.Cases with the catalog case skip (§12; TheFixturesUseEveryField needs it in the same PR); the xunit, nunit, mstest, case-skips, precedence, not-skips folders and the reach cases without helpers. All skip tests but the helper ones. — (Spec 012)

Opened by spec-runner.

…e 1)

Add Skips/skips.json with its loader and validator, and SkipExtractor: test and data
attributes, class attributes, named arguments and modifiers, runtime skip calls and
throws in the body, verbatim reasons, reach (conditional, swallowed) and precedence.
Add SkipFact.Cases, a case skip to the facts catalog, and the samples/skips fixtures.
Move Spec 014's name lookup into Timeouts/NameLookup so both folders share it.

Spec-Runner: spec=015 phase=1 step=implement
@adrian-xping

Copy link
Copy Markdown
Contributor Author

spec-runner review, phase 1, round 1

Finding Severity Where Summary Decision Reason
R1-1 nit src/Xping.Analyzers.CSharp/Skips/SkipExtractor.cs:344 Reach() checks every catch clause that can catch the skip without regard to order. It returns Swallowed as soon as any later clause swallows, even when an earlier clause catches the skip first and rethrows it. C# hands the exception to the first matching clause only, and the later clauses of the same try never see the rethrow. fix Confirmed: Reach() in SkipExtractor.cs loops over every catch clause and returns Swallowed on any later swallowing clause, even when an earlier filterless clause that can catch the skip rethrows it. C# gives the exception to the first matching clause only. §7 rule 3 is silent on order, so state the first-match rule in §7 and stop at the first filterless clause that can catch the skip. Add a reach case for catch (IgnoreException) { throw; } catch (Exception) { }, which is conditional rather than swallowed.
R1-2 nit tests/Xping.Analyzers.CSharp.Tests/Skips/SkipPatternTests.cs:68 §14 asks for one in-test table per §4.5 rule. Four of the rules this diff adds to §4.5 have no case in AnInvalidSkipTableIsRefused: a staticCall/throw row with attributes, a staticCall/throw row with value, an attribute row with attributes, and an attribute row with value. Each shares its if with a covered condition (properties or throws), so dropping one of these conditions from Shape() leaves every test green. fix Confirmed: Shape() checks attributes and value on staticCall/throw rows and on attribute rows, but AnInvalidSkipTableIsRefused has no InlineData for those four conditions. Add one row per condition so removing any of them fails a test (§14: one case per §4.5 rule).

…r table shape rules (spec 015 phase 1)

Spec-Runner: spec=015 phase=1 step=fix-1
@adrian-xping

Copy link
Copy Markdown
Contributor Author

spec-runner review, phase 1, round 2

No findings.

@adrian-xping
adrian-xping merged commit 949f0f2 into feat/spec-015-csharp-skip-extraction Dec 4, 2026
3 checks passed
@adrian-xping
adrian-xping deleted the phase/spec-015-csharp-skip-extraction/1-skips branch December 4, 2026 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant