feat(dummies): add ContainingKey to the dictionary generator#286
Merged
Conversation
AnyDictionary was the only collection generator without a containment constraint: a test could not pin that a generated dictionary holds a particular key, and the out-of-domain cardinality-credit path for dictionary keys was unreachable through the public surface (the suite comments on the gap in ContainingOutsideDomainExtendsCardinality). Add ContainingKey(TKey): it routes to the key state's WithContaining, so the required key takes one entry's room and a key outside the key generator's domain extends the effective cardinality exactly as SetOf(...).Containing(...) does — that crediting already lives in CollectionState and is inherited for free. The entry's value is generated like any other. Named ContainingKey rather than a bare Containing so the surface reads unambiguously on a dictionary of key/value pairs. Declare it in the per-TFM PublicAPI baselines, cover it with tests inside and outside the key domain, and refresh the stale comment that noted the gap. Refs: #225 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018RduXUaM3V6tk6MuKxzVzJ
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
AnyDictionarywas the only collection generator without a containment constraint. This addsContainingKey(TKey)so a test can pin that a generated dictionary holds a particular key, and — because dictionary keys already run through the sameCollectionStateasAnySet— it inherits the out-of-domain cardinality crediting for free, closing a coverage hole the suite explicitly comments on.This is change 2 of the two independent changes described in #225 (the containment surface); the shared count facade is #285.
Type of change
Changes
AnyDictionary<TKey, TValue>.ContainingKey(TKey key): it routes to the key state'sCollectionState.WithContaining, so a required key takes one entry's room and a key outside the key generator's domain extends the effective cardinality exactly asSetOf(...).Containing(...)does — the crediting already lives inCollectionState, inherited unchanged. The entry's value is generated like any other.ContainingKeyrather than a bareContainingso the surface reads unambiguously on a dictionary, whose elements are key/value pairs.PublicAPI.Unshipped.txtbaselines (netstandard2.0andnet8.0).ContainingKeyinside and outside the key generator's domain (the out-of-domain case is the path that was previously untestable throughAnyDictionary), and refresh the stale comment inContainingOutsideDomainExtendsCardinalitythat noted the gap.Testing
dotnet build FirstClassErrors.sln— Build succeeded, 0 Warning(s), 0 Error(s) (both thenetstandard2.0andnet8.0legs of Dummies; the PublicAPI analyzer is clean).dotnet test FirstClassErrors.sln— full suite not run locally; randotnet test Dummies.UnitTestsinstead: 450 passed (2 new), 0 failed, 0 skipped.FirstClassErrors.Analyzers.UnitTests) — not run; no analyzer change in this PR.Documentation
PublicAPI.*.txtbaselines.doc/updateddoc/handwritten/for-users/README.fr.md) updated if user-facing behavior changedArchitecture decisions
Proposed: ADR-____Related issues
Refs #225 — completes the issue together with #285. Left as
Refsrather thanClosesso #225 is not auto-closed before both PRs merge.Generated by Claude Code