Skip to content

refactor: generate the built-in predicate expectations with [GenerateExpectation] - #1831

Merged
vbreuss merged 2 commits into
mainfrom
refactor/use-generate-expectation
Oct 15, 2026
Merged

vbreuss merged 2 commits into
mainfrom
refactor/use-generate-expectation

Conversation

@vbreuss

@vbreuss vbreuss commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

The internal CreateExpectationOn generator duplicated what the public generator in aweXpect.Core now does, so the char, Guid, string and TimeSpan expectations move to it and the internal one is removed. The analyzers of aweXpect.Core now also reach the consumers of aweXpect, so the generator runs in a test project that only references aweXpect.

  • the generated API, its null guarantees and its documentation are unchanged

@vbreuss vbreuss self-assigned this Oct 15, 2026
@vbreuss
vbreuss force-pushed the refactor/use-generate-expectation branch from 546b736 to 43207a3 Compare October 15, 2026 03:51
Base automatically changed from feat/generate-expectation to main October 15, 2026 13:05
@vbreuss
vbreuss force-pushed the refactor/use-generate-expectation branch from 43207a3 to b19b8d3 Compare October 15, 2026 18:15
…eExpectation]`

The internal `CreateExpectationOn` generator duplicated what the public generator in `aweXpect.Core` now does, so the char, Guid, string and TimeSpan expectations move to it and the internal one is removed. The analyzers of `aweXpect.Core` now also reach the consumers of `aweXpect`, so the generator runs in a test project that only references `aweXpect`.

- the generated API, its null guarantees and its documentation are unchanged
- needs a released `aweXpect.Core` that contains the generator: until its version is bumped in `Directory.Packages.props`, only the Debug build compiles
@vbreuss
vbreuss force-pushed the refactor/use-generate-expectation branch from b19b8d3 to cb20008 Compare October 15, 2026 18:27
…looking using

The `using aweXpect.Core;` only existed so that the crefs in the attribute documentation resolve in the generated file, so removing it as unused would have broken them.
@vbreuss
vbreuss merged commit 2bdfbc6 into main Oct 15, 2026
12 checks passed
@vbreuss
vbreuss deleted the refactor/use-generate-expectation branch October 15, 2026 18:40
@sonarqubecloud

Copy link
Copy Markdown

github-actions Bot added a commit that referenced this pull request Oct 15, 2026
…te expectations with `[GenerateExpectation]` (#1831) by Valentin Breuß
github-actions Bot added a commit that referenced this pull request Oct 15, 2026
…te expectations with `[GenerateExpectation]` (#1831) by Valentin Breuß
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Benchmark Results

Details

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

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

Method Mean vs aweXpect Error StdDev Gen0 Gen1 Allocated vs aweXpect
Contains_aweXpect 335.0 ns 1.05 ns 0.82 ns 0.0429 - 720 B
Contains_FluentAssertions 359.8 ns +7% 1.46 ns 1.30 ns 0.0958 - 1608 B +123%
Contains_TUnit 389.9 ns +16% 1.03 ns 0.91 ns 0.0505 - 848 B +18%
Equivalency_aweXpect 12,237.0 ns 17.66 ns 15.66 ns 0.1678 - 3040 B
Equivalency_FluentAssertions 359,314.4 ns +2836% 600.90 ns 532.68 ns 35.1563 - 590292 B +19318%
Equivalency_TUnit 18,828.0 ns +54% 79.01 ns 73.90 ns 0.9155 - 15680 B +416%
EventTriggered_aweXpect 762.5 ns 0.85 ns 0.75 ns 0.1097 - 1848 B
EventTriggered_FluentAssertions 82,805.6 ns +10760% 429.89 ns 358.98 ns 0.2441 0.1221 5252 B +184%
Int_GreaterThan_aweXpect 137.2 ns 0.21 ns 0.17 ns 0.0305 - 512 B
Int_GreaterThan_FluentAssertions 244.0 ns +78% 0.46 ns 0.43 ns 0.0730 - 1224 B +139%
Int_GreaterThan_TUnit 238.2 ns +74% 0.75 ns 0.71 ns 0.0463 - 776 B +52%
ItemsCount_AtLeast_aweXpect 322.1 ns 0.64 ns 0.60 ns 0.0358 - 600 B
ItemsCount_AtLeast_FluentAssertions 488.6 ns +52% 0.51 ns 0.45 ns 0.1192 - 2008 B +235%
ItemsCount_AtLeast_TUnit 368.3 ns +14% 0.89 ns 0.78 ns 0.0634 - 1064 B +77%
Multiple_aweXpect 767.2 ns 0.99 ns 0.93 ns 0.1001 - 1688 B
Multiple_FluentAssertions 1,816.5 ns +137% 25.23 ns 22.37 ns 0.4025 - 6744 B +300%
Multiple_TUnit 911.2 ns +19% 19.94 ns 18.65 ns 0.1335 - 2240 B +33%
Satisfies_aweXpect 173.8 ns 5.33 ns 4.98 ns 0.0329 - 552 B
Satisfies_FluentAssertions 31,767.5 ns +18183% 86.89 ns 77.02 ns 0.3052 0.2441 5614 B +917%
Satisfies_TUnit 236.1 ns +36% 1.01 ns 0.94 ns 0.0424 - 712 B +29%
String_aweXpect 253.9 ns 0.34 ns 0.30 ns 0.0343 - 576 B
String_FluentAssertions 497.7 ns +96% 1.62 ns 1.43 ns 0.1373 - 2304 B +300%
String_TUnit 318.6 ns +25% 0.53 ns 0.47 ns 0.0544 - 912 B +58%
StringArray_aweXpect 626.3 ns 2.04 ns 1.81 ns 0.0515 - 864 B
StringArray_FluentAssertions 1,340.7 ns +114% 32.16 ns 30.09 ns 0.2480 - 4152 B +381%
StringArray_TUnit 643.9 ns +3% 2.76 ns 2.58 ns 0.0753 - 1264 B +46%
StringArrayInAnyOrder_aweXpect 607.4 ns 1.73 ns 1.62 ns 0.0544 - 912 B
StringArrayInAnyOrder_FluentAssertions 26,566.3 ns +4274% 167.88 ns 140.19 ns 1.9836 0.0610 33471 B +3570%
StringArrayInAnyOrder_TUnit 751.4 ns +24% 3.93 ns 3.67 ns 0.0839 - 1408 B +54%
Throws_aweXpect 12,131.1 ns 29.99 ns 28.05 ns 0.0916 - 1720 B
Throws_FluentAssertions 40,937.8 ns +237% 110.96 ns 98.36 ns 1.0986 - 18609 B +982%
Throws_TUnit 11,439.4 ns -6% 18.14 ns 16.97 ns 0.1068 - 1824 B +6%
ThrowsAsync_aweXpect 11,511.6 ns 32.60 ns 30.49 ns 0.1221 - 2208 B
ThrowsAsync_FluentAssertions 59,179.5 ns +414% 69.99 ns 62.04 ns 1.4038 - 23553 B +967%
ThrowsAsync_TUnit 22,331.0 ns +94% 51.41 ns 48.09 ns 0.1526 - 2920 B +32%

@github-actions

Copy link
Copy Markdown
Contributor

This is addressed in release v3.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant