Skip to content

Dictionary Keys Guards - #150

Merged
feO2x merged 3 commits into
mainfrom
148-dictionary-keys-guards
Jul 14, 2026
Merged

Dictionary Keys Guards#150
feO2x merged 3 commits into
mainfrom
148-dictionary-keys-guards

Conversation

@feO2x

@feO2x feO2x commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Closes #148

feO2x added 3 commits July 14, 2026 11:04
Signed-off-by: Kenny Pflug <kenny.pflug@live.de>
Signed-off-by: Kenny Pflug <kenny.pflug@live.de>
Signed-off-by: Kenny Pflug <kenny.pflug@live.de>
@feO2x feO2x self-assigned this Jul 14, 2026
@feO2x
feO2x requested a review from Copilot July 14, 2026 09:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reintroduces dictionary key guard clauses (MustContainKey / MustNotContainKey) to Light.GuardClauses using the v4-era conventions, including new exception types, throw helpers, source-export support, documentation, and test coverage.

Changes:

  • Added MustContainKey / MustNotContainKey guards for IReadOnlyDictionary<TKey, TValue> plus shape-preserving overloads for Dictionary<TKey, TValue>.
  • Introduced MissingKeyException / ExistingKeyException and corresponding Throw.MissingKey / Throw.ExistingKey helpers.
  • Updated source-export whitelists/settings, regenerated the .NET Standard single-file distribution, expanded docs, and added comprehensive automated tests.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tools/source-export/Light.GuardClauses.SourceCodeTransformation/settings.json Adds the new assertion families to the source-export configuration.
tools/source-export/Light.GuardClauses.SourceCodeTransformation/AssertionWhitelist.cs Extends the whitelist model with MustContainKey / MustNotContainKey entries.
src/Light.GuardClauses/Check.MustContainKey.cs Implements MustContainKey guards for IReadOnlyDictionary and Dictionary (shape-preserving) with factory overloads.
src/Light.GuardClauses/Check.MustNotContainKey.cs Implements MustNotContainKey guards for IReadOnlyDictionary and Dictionary (shape-preserving) with factory overloads.
src/Light.GuardClauses/Exceptions/MissingKeyException.cs Adds the new exception type thrown when a key is missing.
src/Light.GuardClauses/Exceptions/ExistingKeyException.cs Adds the new exception type thrown when a key unexpectedly exists.
src/Light.GuardClauses/ExceptionFactory/Throw.MissingKey.cs Provides the default exception construction/message for missing-key failures (including key listing).
src/Light.GuardClauses/ExceptionFactory/Throw.ExistingKey.cs Provides the default exception construction/message for existing-key failures.
tests/Light.GuardClauses.Tests/CollectionAssertions/MustContainKeyTests.cs Adds behavioral, null-handling, comparer-sensitivity, factory, message, and binding tests for MustContainKey.
tests/Light.GuardClauses.Tests/CollectionAssertions/MustNotContainKeyTests.cs Adds behavioral, null-handling, comparer-sensitivity, factory, message, and binding tests for MustNotContainKey.
tests/Light.GuardClauses.SourceCodeTransformation.Tests/SourceFileMergerWhitelistTests.cs Verifies source-export whitelist output includes the new guards/exceptions/throw helpers and trims factory overloads when disabled.
Light.GuardClauses.SingleFile.cs Regenerates the .NET Standard single-file distribution to include the new guards and exceptions.
docs/assertion-overview.md Documents the new dictionary key guards and the IDictionary<TKey, TValue> limitation/workaround.
ai-plans/0148-dictionary-key-guards.md Adds the implementation plan/acceptance criteria record for issue #148.
AGENTS.md Removes a previously recorded “notes” entry from the “Here is Your Space” section.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@feO2x
feO2x merged commit 1c0891f into main Jul 14, 2026
2 checks passed
@feO2x
feO2x deleted the 148-dictionary-keys-guards branch July 14, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dictionary Key Guards

2 participants