feat(dummies): add collection and tuple generators - #175
Merged
Conversation
Increment 3 extends the DSL from scalars to collections, composed over any element generator rather than filled by reflection. - New generators: Any.ListOf / ArrayOf / SequenceOf (materialized) / SetOf / DictionaryOf, plus Any.PairOf / TripleOf sugar over Combine. Each is a combinator that derives its random context from the element generator (falling back to the ambient source), so a seeded element keeps the whole collection reproducible. - Shared count engine CountSpec mirrors the string length algebra: WithCount / WithMinCount / WithMaxCount / WithCountBetween / NonEmpty / Empty, with eager conflict detection. Unconstrained collections hold 0..8 elements — smaller than the string spread, since elements are themselves generated values. - Distinctness follows a two-layer contract. Small element domains advertise an upper-bound cardinality (ICardinalityHint, wired through the ordinal spec and the bool/enum/char/guid pools), so a count beyond the domain fails eagerly with ConflictingAnyConstraintException; larger or unknown domains use a bounded dedup-draw and surface a genuine shortfall as AnyGenerationException naming the seed. The bound stays sound under a custom comparer, which can only merge values. - Containing(value) forces required elements into a collection (budgeted like string fragments); ContainingAny(generator) forces a drawn value in — named apart because a generator both is an IAny<T> and converts implicitly to its value. Values are built to satisfy the constraints directly, never generate-then-filter. The library stays free of FirstClassErrors and targets netstandard2.0 and net8.0. Full suite green on both legs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UhPrBqngpiSwdsF4DWvNPw
Record, as Proposed, how a distinct collection resolves a count against its element domain: eager ConflictingAnyConstraintException when the generator advertises a cardinality the count exceeds, and a bounded deduplicating draw (AnyGenerationException on shortfall, seed reported) when the domain is unbounded or unknowable. Includes the French translation and the index entry. Numbered 0013: ADR-0012 was taken by the binder-options decision merged to main in the meantime. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UhPrBqngpiSwdsF4DWvNPw
Reefact
force-pushed
the
claude/dummies-collections
branch
from
July 18, 2026 09:05
5252986 to
fef2b24
Compare
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
Extends the
DummiesDSL from scalars to collections —ListOf,ArrayOf,SequenceOf,SetOf,DictionaryOf, plusPairOf/TripleOf— as combinators over any element generator, keeping the library's build-to-satisfy, fail-eagerly contract.Type of change
Changes
Any.*, combinators deriving their random context from the element generator, ambient fallback — likeCombine):ListOf→List<T>,ArrayOf→T[],SequenceOf→IEnumerable<T>(fully materialized),SetOf→HashSet<T>,DictionaryOf→Dictionary<K,V>, plusPairOf/TripleOf→ value tuples (in-box onnetstandard2.0). Comparer overloads forSetOf/DictionaryOf, andDistinct(comparer).CountSpec, mirroring the string length algebra:WithCount/WithMinCount/WithMaxCount/WithCountBetween/NonEmpty/Empty, with eager conflict detection. An unconstrained collection holds0..8elements (smaller spread than a string's, since elements are themselves generated values).ICardinalityHintlets small-domain generators (ordinal spec + bool/enum/char/guid pools) advertise an upper-bound cardinality, so a count beyond it fails eagerly withConflictingAnyConstraintException; unknown/large domains use a bounded dedup-draw that surfaces a genuine shortfall asAnyGenerationExceptionnaming the seed. The bound stays sound under a custom comparer.Containing(value)forces required elements in (budgeted like string fragments);ContainingAny(generator)forces a drawn value in — named apart because a library generator both is anIAny<T>and converts implicitly to its value, which would make a single overload ambiguous.AnyCollectionTests(count family + conflicts, distinct eager/fallback, comparer, containing, dictionary, pair/triple, reproducibility,As/Combinecomposition); the seed reproducibility batch now spans a list and a set.Testing
dotnet build FirstClassErrors.sln— succeeded, 0 warnings (bothnetstandard2.0andnet8.0legs), re-verified after rebase ontomain.dotnet test FirstClassErrors.sln— all green (Dummies 145; FCE 423; Analyzers 85; GenDoc 155; Binder 75; Cli 64).FirstClassErrors.Analyzers.UnitTests) — ran as part of the full suite above.Documentation
doc/updated —Dummies/README.nuget.mdand ADR-0013.doc/handwritten/for-users/README.fr.md) updated if user-facing behavior changedThe handwritten EN/FR user guides are intentionally left for later, per ADR-0011's follow-up ("write the user documentation once the V1 surface stabilizes"); only the packaged NuGet readme is kept current here.
Architecture decisions
Proposed: ADR-0013Rebased onto
mainand renumbered the ADR 0012 → 0013 after ADR-0012 (binder options, #174) landed onmain.🤖 Generated with Claude Code