| Property | Value |
|---|---|
| Category | Constraints (JustDummies.Constraints) |
| Severity | 🟠 Warning |
| Enabled by default | Yes |
The argument is a compile-time constant the generator’s own guard refuses, so the call throws every time it runs. Nothing is decided at run time that is not already decided at the call site — yet the failure surfaces only when that arrange line executes, often inside a helper shared by many tests, where it reads as a library problem rather than as the transposition typo it usually is.
Between(10, 5) is the archetype: both parameters are int, both orders compile, and the mistake survives review because the call reads plausibly.
Noncompliant
Any.Int32().Between(10, 5) // the minimum must be ≤ the maximum — transposed
Any.String().WithLengthBetween(10, 5) // same
Any.String().WithLength(-1) // a size must not be negative
Any.String().WithLength(2_000_000) // above the largest producible size
Any.String().WithMaxLength(2_000_000) // a ceiling steers the draw too, so it is capped as well
Any.Int32().MultipleOf(0) // the multiple must be strictly positive
Any.Decimal().WithScale(29) // the scale must be in [0, 28]
Any.String().StartingWith("") // the fragment must not be empty
Any.String().WithChars("") // the character pool must not be empty
Any.String().OneOf() // at least one value is required
Any.DateTime().WithGranularity(TimeSpan.Zero) // the granularity must be strictly positive
Compliant
Any.Int32().Between(5, 10)
Any.String().WithLength(12)
Any.Int32().MultipleOf(7)
Any.String().StartingWith("ORD-")
Scope
One rule over one table, rather than a rule per method: the library validates these in one place, with one message shape, and a reader who learns “a constant the guard rejects” has learned all of them. The table mirrors SizeGuard and the per-generator guards exactly — where it cannot be certain, it stays silent.
What it does not flag
- A non-constant argument. That is the run-time guard’s business, and it keeps it: this rule front-loads only the subset the compiler can already see.
- A conflict-asserting negative test —
Check.ThatCode(() => Any.Int32().Between(10, 5))— where the illegal call is the whole body of a lambda argument. This repository writes hundreds of them. - A same-named method on a type that is not a JustDummies generator.
Containing(item)on a collection, which is not the string overload.