Skip to content

Numeric Sign Guards - #149

Merged
feO2x merged 2 commits into
mainfrom
147-numeric-sign-guards
Jul 14, 2026
Merged

Numeric Sign Guards#149
feO2x merged 2 commits into
mainfrom
147-numeric-sign-guards

Conversation

@feO2x

@feO2x feO2x commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Closes #147

Also introduces ordering for Single Source File export.

feO2x added 2 commits July 14, 2026 09:23
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 08:12
@feO2x feO2x self-assigned this Jul 14, 2026

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 pull request adds the “numeric sign guard” assertion families to Light.GuardClauses (portable overloads plus .NET 10 INumber<T> generic overloads), along with the supporting exception factories, source-export whitelisting, documentation, and tests. It also makes the single-source export output deterministic by sorting input source files during merge.

Changes:

  • Added MustBePositive, MustBeNegative, MustNotBePositive, MustNotBeNegative, and MustNotBeZero guards (including .NET 10 INumber<T> overloads) plus default-throw helpers in Throw.*.
  • Added comprehensive tests for the new guard families and updated the source-export whitelist/settings plus focused whitelist tests.
  • Updated documentation and plan artifacts; made source-export merge ordering deterministic.

Reviewed changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tools/source-export/Light.GuardClauses.SourceCodeTransformation/SourceFileMerger.cs Sorts discovered *.cs files by name before merging to stabilize generated single-file output.
tools/source-export/Light.GuardClauses.SourceCodeTransformation/settings.json Adds the five new assertion families to the source-export settings catalog.
tools/source-export/Light.GuardClauses.SourceCodeTransformation/AssertionWhitelist.cs Adds AssertionEntry properties for the five new sign-guard families.
tests/Light.GuardClauses.Tests/ComparableAssertions/MustNotBeZeroTests.cs New test coverage for MustNotBeZero across concrete + generic overloads (incl. NaN/negative-zero boundaries).
tests/Light.GuardClauses.Tests/ComparableAssertions/MustNotBePositiveTests.cs New test coverage for MustNotBePositive across supported types and generic overloads.
tests/Light.GuardClauses.Tests/ComparableAssertions/MustNotBeNegativeTests.cs New test coverage for MustNotBeNegative across supported types and generic overloads.
tests/Light.GuardClauses.Tests/ComparableAssertions/MustBePositiveTests.cs New test coverage for MustBePositive across supported types and generic overloads.
tests/Light.GuardClauses.Tests/ComparableAssertions/MustBeNegativeTests.cs New test coverage for MustBeNegative across supported types and generic overloads.
tests/Light.GuardClauses.SourceCodeTransformation.Tests/SourceFileMergerWhitelistTests.cs Adds targeted source-export validation for the new sign-guard whitelist entries and target-specific API.
src/Light.GuardClauses/ExceptionFactory/Throw.MustNotBeZero.cs Adds default ArgumentOutOfRangeException creation for MustNotBeZero.
src/Light.GuardClauses/ExceptionFactory/Throw.MustNotBePositive.cs Adds default ArgumentOutOfRangeException creation for MustNotBePositive.
src/Light.GuardClauses/ExceptionFactory/Throw.MustNotBeNegative.cs Adds default ArgumentOutOfRangeException creation for MustNotBeNegative.
src/Light.GuardClauses/ExceptionFactory/Throw.MustBePositive.cs Adds default ArgumentOutOfRangeException creation for MustBePositive.
src/Light.GuardClauses/ExceptionFactory/Throw.MustBeNegative.cs Adds default ArgumentOutOfRangeException creation for MustBeNegative.
src/Light.GuardClauses/Check.MustNotBeZero.cs Implements MustNotBeZero guards for concrete numeric types + TimeSpan, with INumber<T> overloads on modern TFMs.
src/Light.GuardClauses/Check.MustNotBePositive.cs Implements MustNotBePositive guards for concrete numeric types + TimeSpan, with INumber<T> overloads on modern TFMs.
src/Light.GuardClauses/Check.MustNotBeNegative.cs Implements MustNotBeNegative guards for concrete numeric types + TimeSpan, with INumber<T> overloads on modern TFMs.
src/Light.GuardClauses/Check.MustBePositive.cs Implements MustBePositive guards for concrete numeric types + TimeSpan, with INumber<T> overloads on modern TFMs.
src/Light.GuardClauses/Check.MustBeNegative.cs Implements MustBeNegative guards for concrete numeric types + TimeSpan, with INumber<T> overloads on modern TFMs.
docs/assertion-overview.md Documents the new sign-guard families and their NaN/negative-zero semantics and generic overload availability.
ai-plans/0147-numeric-sign-guards.md Adds the plan/acceptance-criteria document for issue #147.
AGENTS.md Notes the rationale for deterministic single-source export ordering (avoids filesystem-dependent reshuffles).

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

@feO2x
feO2x merged commit 810fc51 into main Jul 14, 2026
2 checks passed
@feO2x
feO2x deleted the 147-numeric-sign-guards branch July 14, 2026 09:03
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.

Numeric Sign Guards

2 participants