Repository navigation
feat!: mark IsNotBetween as GuaranteesNotNull - #1092
Merged
Merged
Conversation
vbreuss
enabled auto-merge (squash)
September 14, 2026 09:01
vbreuss
force-pushed
the
feat/isnotbetween-guarantees-not-null
branch
from
September 14, 2026 09:02
17d0ef4 to
e89b406
Compare
Contributor
Test Results 23 files - 27 23 suites - 27 9m 54s ⏱️ +35s Results for commit 6aeb246. ± Comparison against base commit 6d14d7a. This pull request removes 3233 and adds 3199 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Contributor
👽 Mutation ResultsaweXpectDetails
The final mutation score is 93.74%Coverage Thresholds: high:80 low:60 break:0aweXpect.CoreDetails
The final mutation score is NaN%Coverage Thresholds: high:80 low:60 break:0 |
Contributor
🚀 Benchmark ResultsDetails
|
Every range constraint except the numeric one derives from `WithNotNullValue`, which forces the failure before the inversion is applied, so a null subject fails the negated form just as it fails the normal one. `IsBetween` said so in each of those files and `IsNotBetween` did not, although the two share a constraint and differ only by `Invert`. `ThatNumber` was the exception that kept the name in the exemption list of `GuaranteesNotNullTests`, and it was not a deliberate one: its nullable range constraint derived from `WithEqualToValue` and passed the lower bound as the `isExpectedNull` flag, so a null subject failed or passed depending on whether the minimum happened to be null. `IsNotBetween(1).And(3)` passed while `IsNotBetween(null).And(null)` failed - the opposite of what a strict negation of `IsBetween` would give, and the only negated numeric expectation a null subject passed at all, next to `IsNotNaN` and `IsNotInfinite` which both fail. That base class answers a question about equality, where `IsEqualTo(null)` on a null subject should hold; a range has no such reading. It now derives from `WithNotNullValue` like the others, and the name leaves the exemption list. The overloads taking a non-nullable subject gain nothing from the attribute, but their `IsBetween` twin already carries it, and marking only one half of each file would preserve the asymmetry this removes. **BREAKING CHANGE:** a null subject now fails `IsNotBetween` for numbers instead of passing.
vbreuss
force-pushed
the
feat/isnotbetween-guarantees-not-null
branch
from
September 14, 2026 11:20
e89b406 to
6aeb246
Compare
|
github-actions Bot
added a commit
that referenced
this pull request
Sep 14, 2026
…esNotNull` (#1092) by Valentin Breuß
github-actions Bot
added a commit
that referenced
this pull request
Sep 14, 2026
…esNotNull` (#1092) by Valentin Breuß
vbreuss
added a commit
that referenced
this pull request
Sep 14, 2026
… anything The attribute has one mechanical effect: `IsNotNullSuppressor` reads it and drops a CS8600, CS8602, CS8604 or CS8629 on the subject. A subject that cannot be `null` - `ImmutableArray<T>`, `TimeSpan`, `DateTime`, `bool`, a `TNumber` constrained to `struct`, or a concrete `float`/`double` overload - never raises one, so 226 of the 769 markings did nothing. They were also invisible to the sweep, which skips a subject it cannot make `null`, so they were neither invoked nor verified. At nearly a third of all markings that dilutes the signal, and it shifts how the attribute reads: from a suppression directive into documentation that an expectation rejects `null`. That drift is how a marking reaches a reference type it does not hold for, and there the cost is a real CS8602 dropped in a user's code. `EveryMarkedExpectation_ShouldHaveASubjectThatCanBeNull` now rejects such a marking, which makes the rule self-enforcing. It asks about the subject rather than the receiver, because a receiver like `ThatSubject<T>` is a struct that wraps a subject which can be `null` - `Is` and `IsExactly` are marked for exactly that reason. The non-nullable `IsNotBetween` overloads that #1092 marked to keep each file symmetrical are covered by it too.
This was referenced Oct 12, 2026
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.



Every range constraint except the numeric one derives from
WithNotNullValue, which forces the failure before the inversion is applied, so a null subject fails the negated form just as it fails the normal one.IsBetweensaid so in each of those files andIsNotBetweendid not, although the two share a constraint and differ only byInvert.ThatNumberwas the exception that kept the name in the exemption list ofGuaranteesNotNullTests, and it was not a deliberate one: its nullable range constraint derived fromWithEqualToValueand passed the lower bound as theisExpectedNullflag, so a null subject failed or passed depending on whether the minimum happened to be null.IsNotBetween(1).And(3)passed whileIsNotBetween(null).And(null)failed - the opposite of what a strict negation ofIsBetweenwould give, and the only negated numeric expectation a null subject passed at all, next toIsNotNaNandIsNotInfinitewhich both fail. That base class answers a question about equality, whereIsEqualTo(null)on a null subject should hold; a range has no such reading. It now derives fromWithNotNullValuelike the others, and the name leaves the exemption list.The overloads taking a non-nullable subject gain nothing from the attribute, but their
IsBetweentwin already carries it, and marking only one half of each file would preserve the asymmetry this removes.BREAKING CHANGE:
a null subject now fails
IsNotBetweenfor numbers instead of passing.