Skip to content

Collection Count Equality#159

Merged
feO2x merged 3 commits into
mainfrom
158-collection-count-equality
Jul 14, 2026
Merged

Collection Count Equality#159
feO2x merged 3 commits into
mainfrom
158-collection-count-equality

Conversation

@feO2x

@feO2x feO2x commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Closes #158

feO2x added 2 commits July 14, 2026 23:37
Signed-off-by: Kenny Pflug <kenny.pflug@live.de>
Signed-off-by: Kenny Pflug <kenny.pflug@live.de>
@feO2x
feO2x requested a review from Copilot July 14, 2026 22:00
@feO2x feO2x self-assigned this Jul 14, 2026
@feO2x feO2x linked an issue Jul 14, 2026 that may be closed by this pull request
10 tasks

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

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>
@github-actions

Copy link
Copy Markdown

Code Coverage

Package Line Rate Branch Rate Complexity Health
Light.GuardClauses 95% 88% 2388
Light.GuardClauses.InternalRoslynAnalyzers 96% 86% 52
Light.GuardClauses.InternalRoslynAnalyzers.CodeFixes 95% 100% 8
Light.GuardClauses.SourceCodeTransformation 92% 83% 665
Summary 94% (4499 / 4772) 87% (2444 / 2811) 3113

@feO2x
feO2x merged commit cfa9ba1 into main Jul 14, 2026
2 checks passed
@feO2x
feO2x deleted the 158-collection-count-equality branch July 14, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Collection Count Equality

2 participants