Skip to content
This repository was archived by the owner on Nov 10, 2026. It is now read-only.

feat: add WhichReturnVoid filter and ReturnsVoid/ReturnVoid assertions - #276

Merged
vbreuss merged 1 commit into
mainfrom
feat/return-void-236
May 31, 2026
Merged

vbreuss merged 1 commit into
mainfrom
feat/return-void-236

Conversation

@vbreuss

@vbreuss vbreuss commented May 31, 2026 •

Copy link
Copy Markdown
Member

This PR adds a void variant to the return-type filter/assertion family.

Because void cannot be used as a generic type argument (.WhichReturn<void>() doesn't compile), convention tests like "no public methods in value objects return void" or "all event handlers return void" previously
required raw predicates. This adds first-class support:

Filter Assert (single) Assert (many)
returns void .WhichReturnVoid() .ReturnsVoid() .ReturnVoid()

Implementation

Each new method is a thin delegation to the existing type-based API with typeof(void), reusing all matching logic, descriptions, and Or… chaining:

  • MethodFilters.WhichReturnVoid() → WhichReturn(@this, typeof(void))
  • ThatMethod.ReturnsVoid() → Returns(subject, typeof(void))
  • ThatMethods.ReturnVoid() → Return(subject, typeof(void)) (with the IAsyncEnumerable overload under NET8_0_OR_GREATER, matching the existing Return family)

No negated methods were added, consistent with Returns/Return/WhichReturn, which have none (negation is via DoesNotComplyWith).

Usage

// Filter
In.AllLoadedAssemblies().Methods()
    .WhichArePublic()
    .WhichReturnVoid();

// Assert (single)
await Expect.That(method).ReturnsVoid();

// Assert (many)
await Expect.That(methods).ReturnVoid();

@vbreuss vbreuss self-assigned this May 31, 2026
@vbreuss vbreuss added the enhancement New feature or request label May 31, 2026
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

Test Results

    13 files  ±  0      13 suites  ±0   5m 18s ⏱️ -25s
 4 891 tests + 17   4 888 ✅ + 17   3 💤 ±0  0 ❌ ±0 
29 326 runs  +102  29 313 ✅ +102  13 💤 ±0  0 ❌ ±0 

Results for commit d8af823. ± Comparison against base commit a0b5325.

@github-actions

Copy link
Copy Markdown

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.4 LTS (Noble Numbat)
AMD EPYC 7763 2.95GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.300
[Host] : .NET 10.0.8 (10.0.8, 10.0.826.23019), X64 RyuJIT x86-64-v3
DefaultJob : .NET 10.0.8 (10.0.8, 10.0.826.23019), X64 RyuJIT x86-64-v3

Method Mean Error StdDev Gen0 Allocated
TypeIsNotStatic_aweXpect 223.9 ns 0.83 ns 0.69 ns 0.0386 648 B

@github-actions

Copy link
Copy Markdown

👽 Mutation Results

Mutation testing badge

aweXpect.Reflection

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

The final mutation score is NaN%

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

@vbreuss vbreuss changed the title feat: add WhichReturnVoid filter and ReturnsVoid/ReturnVoid assertions feat: add WhichReturnVoid filter and ReturnsVoid/ReturnVoid assertions May 31, 2026
@vbreuss
vbreuss merged commit a7541a3 into main May 31, 2026
11 checks passed
@vbreuss
vbreuss deleted the feat/return-void-236 branch May 31, 2026 19:09
@github-actions

Copy link
Copy Markdown

This is addressed in release v1.5.0.

@github-actions github-actions Bot added the state: released The issue is released label May 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WhichReturnVoid() filter and assertion for methods

1 participant