Numeric Sign Guards - #149
Merged
Merged
Conversation
Signed-off-by: Kenny Pflug <kenny.pflug@live.de>
Signed-off-by: Kenny Pflug <kenny.pflug@live.de>
Contributor
There was a problem hiding this comment.
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, andMustNotBeZeroguards (including .NET 10INumber<T>overloads) plus default-throw helpers inThrow.*. - 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.
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 #147
Also introduces ordering for Single Source File export.