JustDummies

Just dummies — but seriously powerful ones.

Documentation sections

JD005: GeneratorRenderedAsText

PropertyValue
CategoryUsage (JustDummies.Usage)
Severity🔴 Error
Enabled by defaultYes

A generator is an immutable recipe, not a value — and no JustDummies generator overrides ToString(). Rendering one as text therefore yields the builder’s CLR type name: $"{Any.String()}" produces the literal string "JustDummies.AnyString".

That string is non-empty, plausible-looking, and identical on every run. It flows into the message, the payload or the value object under test as if it were an arbitrary value, so the test goes green while exercising a constant that varies for nobody — the exact opposite of what Any is for. Nothing warns: the conversion is legal C#.

Materialize the value with Generate().

Noncompliant

string message   = $"order {Any.String().NonEmpty()}";        // JD005: "order JustDummies.AnyString"
string reference = "ORD-" + Any.String().NonEmpty();          // JD005
string quantity  = Any.Int32().Positive().ToString();         // JD005: "JustDummies.AnyInt32"

Compliant

string message   = $"order {Any.String().NonEmpty().Generate()}";
string reference = "ORD-" + Any.String().NonEmpty().Generate();
string quantity  = Any.Int32().Positive().Generate().ToString();

What it does not flag

  • A generated value — Generate() returns the value, and rendering it is the point.
  • A consumer’s own generator that meaningfully overrides ToString(): the call resolves to that override rather than to object.ToString(), and is deliberately left alone.
  • A ToString(...) overload taking a format or a culture — that is never object.ToString().

Read the source, or correct it there opens in a new tab· Mirrored from lib-v1.0.0-preview.6