Collection Count Equality#159
Merged
Merged
Conversation
Signed-off-by: Kenny Pflug <kenny.pflug@live.de>
Signed-off-by: Kenny Pflug <kenny.pflug@live.de>
10 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new cross-collection guard clause, MustHaveSameCountAs, so callers can enforce “parallel collections must have equal counts” with the library’s standard null handling, caller-expression capture, exception contract, and fluent return behavior.
Changes:
- Introduces
Check.MustHaveSameCountAs<TCollection, TOtherCollection>(default + custom-exception-factory overload) with single-pass counting and same-instance fast exit. - Adds a dedicated throw helper (
Throw.CollectionCountsNotEqual) to report both precomputed counts without re-enumerating inputs. - Updates docs, source-export whitelist/settings, and adds comprehensive unit + source-export trimming/reachability tests.
Reviewed changes
Copilot reviewed 9 out of 9 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 | Whitelists MustHaveSameCountAs for source export (incl. factory overload). |
| tools/source-export/Light.GuardClauses.SourceCodeTransformation/AssertionWhitelist.cs | Adds MustHaveSameCountAs entry to the whitelist catalog. |
| tests/Light.GuardClauses.Tests/CollectionAssertions/MustHaveSameCountAsTests.cs | Adds behavioral tests for equal/unequal counts, null handling, caller expression, fast paths, and lazy/single-use enumerables. |
| tests/Light.GuardClauses.SourceCodeTransformation.Tests/SourceFileMergerWhitelistTests.cs | Adds focused source-export tests ensuring required helpers are retained/trimmed appropriately. |
| src/Light.GuardClauses/ExceptionFactory/Throw.CollectionCountsNotEqual.cs | Adds a throw helper that uses already observed counts to avoid re-enumeration. |
| src/Light.GuardClauses/Check.MustHaveSameCountAs.cs | Implements the new guard with correct null validation, same-instance short-circuit, and count comparison. |
| Light.GuardClauses.SingleFile.cs | Regenerates the single-file distribution to include the new guard and throw helper (plus incidental stream-guard boolean simplifications). |
| docs/assertion-overview.md | Documents the new assertion and its enumeration/exception characteristics. |
| ai-plans/0158-collection-count-equality.md | Adds the implementation plan and checked acceptance criteria for #158. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ion project This allows symbols to be resolved properly. Signed-off-by: Kenny Pflug <kenny.pflug@live.de>
|
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.
Closes #158