Skip to content

refactor: drop the GuaranteesNotNull markings that can never suppress anything - #1097

Merged
vbreuss merged 1 commit into
mainfrom
refactor/drop-inert-guarantees-not-null
Sep 14, 2026
Merged

vbreuss merged 1 commit into
mainfrom
refactor/drop-inert-guarantees-not-null

Conversation

@vbreuss

@vbreuss vbreuss commented Sep 14, 2026

Copy link
Copy Markdown
Member

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 209 of the 735 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 more than a quarter 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.

@vbreuss vbreuss self-assigned this Sep 14, 2026
@vbreuss
vbreuss added this pull request to stack #1098 September 14, 2026 13:25
@vbreuss
vbreuss removed this pull request from stack #1098 September 14, 2026 13:25
@vbreuss
vbreuss added this pull request to stack #1099 September 14, 2026 13:26
@vbreuss
vbreuss removed this pull request from stack #1099 September 14, 2026 13:29
@vbreuss
vbreuss added this pull request to stack #1101 September 14, 2026 13:32
@vbreuss
vbreuss force-pushed the refactor/drop-inert-guarantees-not-null branch from 23a8fdf to c834e5d Compare September 14, 2026 13:34
@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

     23 files       23 suites   9m 38s ⏱️
 20 490 tests  20 488 ✅ 2 💤 0 ❌
106 169 runs  106 167 ✅ 2 💤 0 ❌

Results for commit 6060750.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.5 LTS (Noble Numbat)
AMD EPYC 7763 2.60GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.303
[Host] : .NET 8.0.31 (8.0.31, 8.0.3126.42015), X64 RyuJIT x86-64-v3

Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15
LaunchCount=1 WarmupCount=10

Method Mean Error StdDev Gen0 Gen1 Allocated
Bool_aweXpect 248.7 ns 9.34 ns 8.74 ns 0.0415 - 696 B
Bool_FluentAssertions 240.4 ns 8.03 ns 7.51 ns 0.0567 - 952 B
Equivalency_aweXpect 377,563.3 ns 2,244.74 ns 2,099.73 ns 32.2266 1.4648 542084 B
Equivalency_FluentAssertions 2,788,003.2 ns 58,371.03 ns 54,600.30 ns 289.0625 46.8750 4841651 B
Int_GreaterThan_aweXpect 275.3 ns 6.45 ns 6.03 ns 0.0515 - 864 B
Int_GreaterThan_FluentAssertions 257.3 ns 3.52 ns 2.94 ns 0.0730 - 1224 B
ItemsCount_AtLeast_aweXpect 511.5 ns 4.70 ns 4.39 ns 0.0811 - 1360 B
ItemsCount_AtLeast_FluentAssertions 493.8 ns 17.28 ns 16.16 ns 0.1192 - 2008 B
String_aweXpect 451.9 ns 5.53 ns 5.17 ns 0.0672 - 1128 B
String_FluentAssertions 1,244.4 ns 27.06 ns 25.31 ns 0.2346 - 3944 B
StringArray_aweXpect 1,894.5 ns 11.29 ns 10.56 ns 0.1564 - 2624 B
StringArray_FluentAssertions 1,355.6 ns 7.35 ns 6.51 ns 0.2480 - 4152 B
StringArrayInAnyOrder_aweXpect 2,501.2 ns 9.10 ns 7.60 ns 0.1678 - 2816 B
StringArrayInAnyOrder_FluentAssertions 27,175.9 ns 149.53 ns 139.87 ns 1.9836 0.0610 33471 B

@vbreuss
vbreuss force-pushed the refactor/drop-inert-guarantees-not-null branch from c834e5d to 2bd1de8 Compare September 14, 2026 14:26
Base automatically changed from refactor/nullable-non-generic-enumerable-subject to main September 14, 2026 14:27
… 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.
@vbreuss
vbreuss force-pushed the refactor/drop-inert-guarantees-not-null branch from 2bd1de8 to 6060750 Compare September 14, 2026 14:38
@sonarqubecloud

Copy link
Copy Markdown

@vbreuss
vbreuss merged commit 5fa9d81 into main Sep 14, 2026
14 checks passed
@vbreuss
vbreuss deleted the refactor/drop-inert-guarantees-not-null branch September 14, 2026 15:27
github-actions Bot added a commit that referenced this pull request Sep 14, 2026
…rkings that can never suppress anything (#1097) by Valentin Breuß
github-actions Bot added a commit that referenced this pull request Sep 14, 2026
…rkings that can never suppress anything (#1097) by Valentin Breuß
@github-actions

Copy link
Copy Markdown
Contributor

👽 Mutation Results

Mutation testing badge

aweXpect

Details
File Score Killed Survived Timeout No Coverage Ignored Compile Errors Runtime Errors Total Detected Total Undetected Total Mutants
That/Booleans/ThatBool.Implies.cs 100.00% 16 0 0 0 5 6 0 16 0 27
That/Booleans/ThatBool.IsFalse.cs 100.00% 1 0 0 0 0 0 0 1 0 1
That/Booleans/ThatBool.IsTrue.cs 100.00% 1 0 0 0 0 0 0 1 0 1
That/Collections/ThatEnumerable.AreAllUnique.cs 87.80% 72 10 0 0 20 34 0 72 10 136
That/Collections/ThatEnumerable.Contains.cs 77.19% 264 54 0 24 99 84 0 264 78 525
That/Collections/ThatEnumerable.EndsWith.cs 82.68% 105 12 0 10 40 46 0 105 22 213
That/Collections/ThatEnumerable.HasCount.cs 100.00% 12 0 0 0 0 0 0 12 0 12
That/Collections/ThatEnumerable.HasItem.cs 81.01% 142 27 3 7 60 80 0 145 34 319
That/Collections/ThatEnumerable.HasItemThat.cs 82.50% 65 12 1 2 22 30 0 66 14 132
That/Collections/ThatEnumerable.HasSingle.cs 91.25% 73 5 0 2 33 24 0 73 7 137
That/Collections/ThatEnumerable.IsContainedIn.cs 53.57% 15 13 0 0 14 0 0 15 13 42
That/Collections/ThatEnumerable.IsInAscendingOrder.cs 100.00% 12 0 0 0 12 0 0 12 0 24
That/Collections/ThatEnumerable.IsInDescendingOrder.cs 100.00% 12 0 0 0 12 0 0 12 0 24
That/Collections/ThatEnumerable.StartsWith.cs 79.65% 90 13 0 10 38 44 0 90 23 195
That/DateOnlys/ThatDateOnly.IsAfter.cs 100.00% 22 0 0 0 5 6 0 22 0 33
That/DateOnlys/ThatDateOnly.IsBefore.cs 100.00% 22 0 0 0 5 6 0 22 0 33
That/DateOnlys/ThatDateOnly.IsBetween.cs 100.00% 35 0 0 0 6 8 0 35 0 49
That/DateOnlys/ThatDateOnly.IsOnOrAfter.cs 100.00% 22 0 0 0 5 6 0 22 0 33
That/DateOnlys/ThatDateOnly.IsOnOrBefore.cs 100.00% 22 0 0 0 5 6 0 22 0 33
That/DateTimeOffsets/ThatDateTimeOffset.IsAfter.cs 100.00% 22 0 0 0 5 6 0 22 0 33
That/DateTimeOffsets/ThatDateTimeOffset.IsBefore.cs 100.00% 22 0 0 0 5 6 0 22 0 33
That/DateTimeOffsets/ThatDateTimeOffset.IsBetween.cs 100.00% 35 0 0 0 6 8 0 35 0 49
That/DateTimeOffsets/ThatDateTimeOffset.IsOnOrAfter.cs 100.00% 22 0 0 0 5 6 0 22 0 33
That/DateTimeOffsets/ThatDateTimeOffset.IsOnOrBefore.cs 100.00% 22 0 0 0 5 6 0 22 0 33
That/DateTimes/ThatDateTime.IsAfter.cs 100.00% 22 0 0 0 5 6 0 22 0 33
That/DateTimes/ThatDateTime.IsBefore.cs 100.00% 22 0 0 0 5 6 0 22 0 33
That/DateTimes/ThatDateTime.IsBetween.cs 100.00% 35 0 0 0 6 8 0 35 0 49
That/DateTimes/ThatDateTime.IsOnOrAfter.cs 100.00% 22 0 0 0 5 6 0 22 0 33
That/DateTimes/ThatDateTime.IsOnOrBefore.cs 100.00% 22 0 0 0 5 6 0 22 0 33
That/Enums/ThatEnum.HasValue.cs 100.00% 12 0 0 0 4 4 0 12 0 20
That/Enums/ThatEnum.IsDefined.cs 100.00% 7 0 0 0 2 4 0 7 0 13
That/Numbers/ThatNumber.IsBetween.cs 94.23% 49 3 0 0 12 16 0 49 3 80
That/Numbers/ThatNumber.IsFinite.cs 100.00% 18 0 0 0 4 8 0 18 0 30
That/Numbers/ThatNumber.IsGreaterThan.cs 86.21% 25 4 0 0 8 12 0 25 4 49
That/Numbers/ThatNumber.IsGreaterThanOrEqualTo.cs 86.21% 25 4 0 0 8 12 0 25 4 49
That/Numbers/ThatNumber.IsInfinite.cs 100.00% 12 0 0 0 4 8 0 12 0 24
That/Numbers/ThatNumber.IsLessThan.cs 86.21% 25 4 0 0 8 12 0 25 4 49
That/Numbers/ThatNumber.IsLessThanOrEqualTo.cs 86.21% 25 4 0 0 8 12 0 25 4 49
That/Numbers/ThatNumber.IsNaN.cs 100.00% 12 0 0 0 4 8 0 12 0 24
That/Numbers/ThatNumber.IsNegative.cs 100.00% 16 0 0 0 4 8 0 16 0 28
That/Numbers/ThatNumber.IsPositive.cs 100.00% 16 0 0 0 4 8 0 16 0 28
That/TimeOnlys/ThatTimeOnly.IsAfter.cs 100.00% 23 0 0 0 5 6 0 23 0 34
That/TimeOnlys/ThatTimeOnly.IsBefore.cs 100.00% 23 0 0 0 5 6 0 23 0 34
That/TimeOnlys/ThatTimeOnly.IsBetween.cs 100.00% 35 0 0 0 6 8 0 35 0 49
That/TimeOnlys/ThatTimeOnly.IsOnOrAfter.cs 100.00% 23 0 0 0 5 6 0 23 0 34
That/TimeOnlys/ThatTimeOnly.IsOnOrBefore.cs 100.00% 23 0 0 0 5 6 0 23 0 34
That/TimeSpans/ThatTimeSpan.IsBetween.cs 100.00% 35 0 0 0 6 8 0 35 0 49
That/TimeSpans/ThatTimeSpan.IsGreaterThan.cs 100.00% 24 0 0 0 5 6 0 24 0 35
That/TimeSpans/ThatTimeSpan.IsGreaterThanOrEqualTo.cs 100.00% 24 0 0 0 5 6 0 24 0 35
That/TimeSpans/ThatTimeSpan.IsLessThan.cs 100.00% 24 0 0 0 5 6 0 24 0 35
That/TimeSpans/ThatTimeSpan.IsLessThanOrEqualTo.cs 100.00% 24 0 0 0 5 6 0 24 0 35
That/TimeSpans/ThatTimeSpan.IsNegative.cs 100.00% 9 0 0 0 2 4 0 9 0 15
That/TimeSpans/ThatTimeSpan.IsPositive.cs 100.00% 9 0 0 0 2 4 0 9 0 15

The final mutation score is 88.95%

Coverage Thresholds: high:80 low:60 break:0

aweXpect.Core

Details
File Score Killed Survived Timeout No Coverage Ignored Compile Errors Runtime Errors Total Detected Total Undetected Total Mutants

The final mutation score is NaN%

Coverage Thresholds: high:80 low:60 break:0

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.

1 participant