feat(dummies): add ContainingAnyKey to the dictionary generator#289
Merged
Conversation
AnyDictionary.ContainingKey(TKey) pins a concrete key, but AnyCollection also offers ContainingAny(IAny<TItem>) to force a generator-drawn value in, and the dictionary had no key equivalent — its containment surface was one method short of the collection surface. Add ContainingAnyKey(IAny<TKey>) mirroring ContainingAny: it null-guards the generator and routes to the key state's WithContaining(IAny<TKey>, ...), so the drawn key takes one entry's room and inherits the bounded dedup-draw and out-of-domain cardinality credit unchanged. Named ContainingAnyKey rather than a bare ContainingAny for the same reason ContainingKey is not a bare Containing: a dictionary's elements are key/value pairs. Declare it in both per-TFM PublicAPI baselines and cover it with a test — the draw landing outside the key generator's domain, and the null-generator guard. Refs: #287 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
AnyDictionary.ContainingKey(TKey)pins a concrete key, butAnyCollectionalso offersContainingAny(IAny<TItem>)to force a generator-drawn value into a collection — andAnyDictionaryhad no key equivalent. This addsContainingAnyKey(IAny<TKey>), bringing the dictionary containment surface to full parity with the collection surface.Type of change
Changes
AnyDictionary<TKey, TValue>.ContainingAnyKey(IAny<TKey> generator): it null-guards the generator (ArgumentNullException) and routes to the key state'sCollectionState.WithContaining(IAny<TKey>, ...)— the same overloadAnyCollection.ContainingAnyuses — so the drawn key takes one entry's room and inherits the bounded dedup-draw and out-of-domain cardinality credit unchanged. The entry's value is generated like any other.ContainingAnyKeyrather than a bareContainingAnyfor the same reasonContainingKeyis not a bareContaining: a dictionary's elements are key/value pairs, so the surface stays explicit about what it constrains.PublicAPI.Unshipped.txtbaselines (netstandard2.0andnet8.0).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: 451 passed (1 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
AnyCollection.ContainingAny.Proposed: ADR-____Related issues
Closes #287.
Generated by Claude Code