Skip to content

docs: state the null rule that extension authors must follow - #1100

Merged
vbreuss merged 1 commit into
mainfrom
docs/null-rule-for-extension-authors
Sep 14, 2026
Merged

vbreuss merged 1 commit into
mainfrom
docs/null-rule-for-extension-authors

Conversation

@vbreuss

@vbreuss vbreuss commented Sep 14, 2026

Copy link
Copy Markdown
Member

The author rule still said the exception is "those that compare it against a value the caller supplied", which is the formulation the sweep disproved: HasValue(2) takes a supplied value and fails for null, and an ordering or a range gives null no meaning on either side even though both take one. Only equality and identity do, so that is what the rule now names, together with the negated case that DoesNotComplyWith exposes.

The worked example contradicted the paragraph three lines above it by using WithValue<string> for an expectation that inspects a string - the exact mistake that let a null subject satisfy the negated form of HasItem and Implies. It now uses WithNotNullValue<string> and the inherited It, with a note about CS9107, because an author who follows the rule and switches base hits that error with no warning.

The three base classes differ only in how they treat a null actual, and that was the one thing their own documentation did not say. WithEqualToValue in particular encoded the decision as IsNegated == isExpectedNull with no explanation; the four cases are now spelled out.

The author rule still said the exception is "those that compare it against a value the caller supplied", which is the formulation the sweep disproved: `HasValue(2)` takes a supplied value and fails for `null`, and an ordering or a range gives `null` no meaning on either side even though both take one. Only equality and identity do, so that is what the rule now names, together with the negated case that `DoesNotComplyWith` exposes.

The worked example contradicted the paragraph three lines above it by using `WithValue<string>` for an expectation that inspects a string - the exact mistake that let a null subject satisfy the negated form of `HasItem` and `Implies`. It now uses `WithNotNullValue<string>` and the inherited `It`, with a note about CS9107, because an author who follows the rule and switches base hits that error with no warning.

The three base classes differ only in how they treat a `null` actual, and that was the one thing their own documentation did not say. `WithEqualToValue` in particular encoded the decision as `IsNegated == isExpectedNull` with no explanation; the four cases are now spelled out.
@vbreuss vbreuss self-assigned this Sep 14, 2026
@vbreuss vbreuss added the documentation Improvements or additions to documentation label Sep 14, 2026
@vbreuss
vbreuss added this pull request to stack #1101 September 14, 2026 13:32
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

     23 files   -  27       23 suites   - 27   9m 24s ⏱️ +14s
 20 497 tests  -  36   20 495 ✅  -  36  2 💤 ±0  0 ❌ ±0 
106 169 runs   - 108  106 167 ✅  - 108  2 💤 ±0  0 ❌ ±0 

Results for commit c8f3dc5. ± Comparison against base commit 48275fc.

This pull request removes 3228 and adds 3192 tests. Note that renamed tests count towards both.
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ InnerException_ShouldBeSet(message: "message0353d174-0b23-4686-8a62-9d81f65a6e7e")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ InnerException_ShouldBeSet(message: "message6f722d1c-e614-4560-8227-c3e1491747f4")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ InnerException_ShouldBeSet(message: "message8ab9b8b8-8448-4676-885e-34cf7e56c4e1")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ InnerException_ShouldBeSet(message: "messageb952d359-68bb-4f59-9436-adf90f0828ae")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ InnerException_ShouldBeSet(message: "messageba831426-c83d-4843-afa6-2a566f16d801")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ InnerException_ShouldBeSet(message: "messaged95f250e-6a6e-43b5-af72-fb04416d2eec")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message3e6cdece-76da-46f7-896e-1817f379ad5b")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message4627c171-f42e-4179-b3b4-b15671769932")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message64501b62-7717-46b8-8628-7768e7712759")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "messagef2705f4c-7e04-47e2-a713-0cbf79beae51")
…
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ InnerException_ShouldBeSet(message: "message45f6c59a-b7af-4423-a662-8b0b2e577517")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ InnerException_ShouldBeSet(message: "message7dd00fc7-a7dc-4ee6-93af-68947819975c")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ InnerException_ShouldBeSet(message: "messageb8ee245c-5abe-4186-a78e-3c51a5a60a88")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ InnerException_ShouldBeSet(message: "messagee536007a-531d-4582-9f5e-5eeed0fde8d0")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ InnerException_ShouldBeSet(message: "messageecf0dc79-7c56-485d-bd22-927b81c838b2")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ InnerException_ShouldBeSet(message: "messagef539fc62-dc87-41bc-8f5b-d78601a9671f")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message1bfa66c5-5b6a-4d76-9b36-4720a8935473")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message29970d67-b344-43d5-852e-2528829f1a03")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message51b32910-2ee6-45f4-88b2-560e39276f42")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message91e25aff-721e-4274-9060-72a0c4052a56")
…

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.5 LTS (Noble Numbat)
AMD EPYC 9V74 3.67GHz, 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-v4

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

Method Mean Error StdDev Gen0 Gen1 Allocated
Bool_aweXpect 193.1 ns 0.85 ns 0.71 ns 0.0415 - 696 B
Bool_FluentAssertions 190.6 ns 0.58 ns 0.55 ns 0.0567 - 952 B
Equivalency_aweXpect 281,759.3 ns 1,046.18 ns 978.60 ns 32.2266 1.4648 542084 B
Equivalency_FluentAssertions 1,753,692.7 ns 2,140.12 ns 1,787.10 ns 289.0625 50.7813 4841647 B
Int_GreaterThan_aweXpect 206.0 ns 0.40 ns 0.36 ns 0.0515 - 864 B
Int_GreaterThan_FluentAssertions 188.9 ns 0.66 ns 0.55 ns 0.0730 - 1224 B
ItemsCount_AtLeast_aweXpect 342.8 ns 1.41 ns 1.32 ns 0.0811 - 1360 B
ItemsCount_AtLeast_FluentAssertions 365.1 ns 0.76 ns 0.64 ns 0.1197 - 2008 B
String_aweXpect 355.6 ns 1.20 ns 1.07 ns 0.0672 - 1128 B
String_FluentAssertions 846.1 ns 3.29 ns 2.92 ns 0.2356 0.0010 3944 B
StringArray_aweXpect 1,407.7 ns 4.24 ns 3.76 ns 0.1564 - 2624 B
StringArray_FluentAssertions 1,002.3 ns 8.36 ns 7.41 ns 0.2480 - 4152 B
StringArrayInAnyOrder_aweXpect 1,884.3 ns 2.17 ns 2.03 ns 0.1678 - 2816 B
StringArrayInAnyOrder_FluentAssertions 15,360.2 ns 40.20 ns 35.64 ns 1.9836 0.0610 33471 B

@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

The final mutation score is NaN%

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
Core/Constraints/ConstraintResult.WithEqualToValue.cs 100.00% 20 0 0 0 12 2 0 20 0 34
Core/Constraints/ConstraintResult.WithNotNullValue.cs 100.00% 17 0 0 0 12 2 0 17 0 31
Core/Constraints/ConstraintResult.WithValue.cs 100.00% 13 0 0 0 10 2 0 13 0 25

The final mutation score is 100.00%

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

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant