Additional assertions Juli 2026#146
Merged
Merged
Conversation
Signed-off-by: Kenny Pflug <kenny.pflug@live.de>
14 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements Issue #145 by adding several new guard-clause assertion families (UUIDv7, finiteness, ASCII, ranged collection counts, additional span/memory guards, and DateTimeOffset UTC validation) while keeping the source-export pipeline, single-file distribution, benchmarks, tests, and documentation in sync.
Changes:
- Added new
Check.*predicates/guards:IsUuidVersion7/MustBeUuidVersion7,IsFinite/MustBeFinite,IsAscii/MustBeAscii,MustHaveCountIn, plus additional span/memory length and whitespace guards, andDateTimeOffsetsupport forMustBeUtc. - Introduced supporting infrastructure (e.g.,
GuidLayoutoverlay and newThrow.*helpers) and regenerated the committed single-file distribution. - Updated BenchmarkDotNet project to run .NET 10-only with memory diagnoser enabled by default (disassembly opt-in), and added/extended tests + docs + source-export whitelist coverage.
Reviewed changes
Copilot reviewed 39 out of 39 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/source-export/Light.GuardClauses.SourceCodeTransformation/SourceFileMerger.cs | Ensures generated single-file output includes interop namespace needed by UUIDv7 layout overlay. |
| tools/source-export/Light.GuardClauses.SourceCodeTransformation/settings.json | Adds new assertion families to the source-export settings catalog. |
| tools/source-export/Light.GuardClauses.SourceCodeTransformation/AssertionWhitelist.cs | Extends the whitelist model with new assertion entries for export/trimming. |
| tests/Light.GuardClauses.Tests/StringAssertions/AsciiTests.cs | Adds test coverage for ASCII predicates/guards across scalar/string/span/memory shapes. |
| tests/Light.GuardClauses.Tests/DateTimeAssertions/MustBeUtcTests.cs | Extends UTC guard tests to cover DateTimeOffset zero/non-zero offset behavior. |
| tests/Light.GuardClauses.Tests/CommonAssertions/UuidVersion7Tests.cs | Adds correctness tests for UUIDv7 structural validation and guard behavior. |
| tests/Light.GuardClauses.Tests/CommonAssertions/FiniteTests.cs | Adds finiteness tests for float/double and modern generic IEEE-754 overload availability. |
| tests/Light.GuardClauses.Tests/CollectionAssertions/MustHaveCountInTests.cs | Validates ranged collection-count guard semantics (inclusive/exclusive endpoints, null, lazy enumerables, factories/messages). |
| tests/Light.GuardClauses.Tests/CollectionAssertions/AdditionalSpanAndMemoryGuardsTests.cs | Adds span/memory parity tests for non-empty, length range, exact length (memory), and non-whitespace guards. |
| tests/Light.GuardClauses.SourceCodeTransformation.Tests/SourceFileMergerWhitelistTests.cs | Ensures new assertions retain required portable helpers and target-specific surfaces in generated source. |
| tests/Light.GuardClauses.SourceCodeTransformation.Tests/SourceFileMergerFrameworkTests.cs | Verifies net10 export includes IEEE-754 generic finiteness + optimized ASCII, while netstandard omits them. |
| src/Light.GuardClauses/GuidLayout.cs | Adds internal explicit-layout overlay struct used for allocation-free UUIDv7 inspection. |
| src/Light.GuardClauses/Exceptions/InvalidDateTimeException.cs | Updates exception documentation to cover DateTimeOffset in addition to DateTime. |
| src/Light.GuardClauses/ExceptionFactory/Throw.WhiteSpaceString.cs | Adds a span-specific whitespace throw helper to support MustNotBeEmptyOrWhiteSpace for spans. |
| src/Light.GuardClauses/ExceptionFactory/Throw.Span.cs | Adds ranged-length throw helper for spans. |
| src/Light.GuardClauses/ExceptionFactory/Throw.NotFinite.cs | Adds default throw helper for non-finite floating-point guard failures. |
| src/Light.GuardClauses/ExceptionFactory/Throw.DateTime.cs | Adds DateTimeOffset UTC-offset throw helper. |
| src/Light.GuardClauses/ExceptionFactory/Throw.CollectionCountNotInRange.cs | Adds default throw helper for ranged collection-count guard failures. |
| src/Light.GuardClauses/Check.MustNotBeEmptyOrWhiteSpace.cs | Adds throwing guard for whitespace/empty character span and memory shapes. |
| src/Light.GuardClauses/Check.MustNotBeEmpty.cs | Adds MustNotBeEmpty overloads for span/memory shapes. |
| src/Light.GuardClauses/Check.MustHaveLengthIn.cs | Adds MustHaveLengthIn overloads for span/memory shapes with ranged-length semantics. |
| src/Light.GuardClauses/Check.MustHaveLength.cs | Adds exact-length guards for Memory<T> / ReadOnlyMemory<T>. |
| src/Light.GuardClauses/Check.MustHaveCountIn.cs | Adds ranged count guard for general IEnumerable collections with factory overload. |
| src/Light.GuardClauses/Check.MustBeUuidVersion7.cs | Adds UUIDv7 throwing guard with default and factory overloads. |
| src/Light.GuardClauses/Check.MustBeUtc.cs | Adds DateTimeOffset overloads for MustBeUtc without normalizing instants. |
| src/Light.GuardClauses/Check.MustBeFinite.cs | Adds throwing finiteness guards for float/double plus modern generic IEEE-754 overloads. |
| src/Light.GuardClauses/Check.MustBeAscii.cs | Adds ASCII throwing guards for scalars, strings, and span/memory shapes. |
| src/Light.GuardClauses/Check.IsUuidVersion7.cs | Adds allocation-free UUIDv7 predicate based on GUID structural fields. |
| src/Light.GuardClauses/Check.IsFinite.cs | Adds finiteness predicates for float/double plus modern generic IEEE-754 predicate. |
| src/Light.GuardClauses/Check.IsAscii.cs | Adds ASCII predicates for scalars/strings/spans/memory, using optimized framework APIs on modern TFMs. |
| Light.GuardClauses.SingleFile.cs | Regenerates the committed netstandard2.0 single-file distribution including the new APIs/helpers. |
| docs/source-code-inclusion.md | Updates source-export docs to reflect new net10-only optimized surfaces. |
| docs/historical-performance.md | Updates benchmark targeting statement to reflect .NET 10-only benchmarks. |
| docs/contributing-and-building.md | Updates build/contribution docs for .NET 10-only benchmarks and disassembly opt-in. |
| docs/assertion-overview.md | Documents new assertion families and overload matrices (UUIDv7, finiteness, ASCII, count-in-range, span/memory parity, DateTimeOffset UTC). |
| benchmarks/Light.GuardClauses.Performance/Program.cs | Makes memory diagnoser default and disassembly diagnoser opt-in; updates to .NET 10 runtime job. |
| benchmarks/Light.GuardClauses.Performance/Light.GuardClauses.Performance.csproj | Switches benchmark project to net10.0 only. |
| benchmarks/Light.GuardClauses.Performance/CommonAssertions/UuidVersion7Benchmark.cs | Adds UUIDv7 structural validation microbenchmarks for direct vs guard-clause checks. |
| ai-plans/0145-additional-assertions.md | Adds a plan/acceptance-criteria checklist documenting the implementation scope for #145. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 #145