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

fix: accept nullable method items in Return, ReturnExactly and ReturnVoid - #381

Merged
vbreuss merged 1 commit into
mainfrom
fix/return-nullable-method-items
Oct 9, 2026
Merged

vbreuss merged 1 commit into
mainfrom
fix/return-nullable-method-items

Conversation

@vbreuss

@vbreuss vbreuss commented Oct 9, 2026

Copy link
Copy Markdown
Member

The other collection expectations take MethodInfo? items since the collection subjects were declared nullable, but Return, ReturnExactly and ReturnVoid still required non-null items. Chaining them after another expectation (AreStatic().And.Return<int>()) or using them on an IEnumerable<MethodInfo?> caused CS8620.

  • Items are now declared as MethodInfo?.
  • A null item cannot be inspected, so it counts as a not matching method (like in the other method expectations) instead of throwing a NullReferenceException.

…eturnVoid`

The other collection expectations take `MethodInfo?` items since the collection subjects were declared nullable, but `Return`, `ReturnExactly` and `ReturnVoid` still required non-null items. Chaining them after another expectation (`AreStatic().And.Return<int>()`) or using them on an `IEnumerable<MethodInfo?>` caused CS8620.

- Items are now declared as `MethodInfo?`.
- A `null` item cannot be inspected, so it counts as a not matching method (like in the other method expectations) instead of throwing a `NullReferenceException`.
@vbreuss vbreuss self-assigned this Oct 9, 2026
Copilot AI balanced review requested due to automatic review settings October 9, 2026 20:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vbreuss
vbreuss enabled auto-merge (squash) October 9, 2026 20:02
@sonarqubecloud

sonarqubecloud Bot commented Oct 9, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Test Results

    13 files  ± 0      13 suites  ±0   11m 2s ⏱️ -32s
 6 865 tests + 4   6 862 ✅ + 4   3 💤 ±0  0 ❌ ±0 
41 035 runs  +24  41 022 ✅ +24  13 💤 ±0  0 ❌ ±0 

Results for commit b580e84. ± Comparison against base commit cff1ac8.

@vbreuss
vbreuss merged commit 8757925 into main Oct 9, 2026
13 checks passed
@vbreuss
vbreuss deleted the fix/return-nullable-method-items branch October 9, 2026 20:28
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.5 LTS (Noble Numbat)
AMD EPYC 9V74 2.87GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.303
[Host] : .NET 10.0.12 (10.0.12, 10.0.1226.42308), X64 RyuJIT x86-64-v3
DefaultJob : .NET 10.0.12 (10.0.12, 10.0.1226.42308), X64 RyuJIT x86-64-v3

Method Mean Error StdDev Gen0 Allocated
TypeIsNotStatic_aweXpect 131.2 ns 0.25 ns 0.21 ns 0.0238 400 B

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

👽 Mutation Results

Mutation testing badge

aweXpect.Reflection

Details
File Score Killed Survived Timeout No Coverage Ignored Compile Errors Runtime Errors Total Detected Total Undetected Total Mutants
ThatMethods.Return.cs 100.00% 20 0 0 0 5 6 0 20 0 31
ThatMethods.ReturnExactly.cs 100.00% 8 0 0 0 3 0 0 8 0 11

The final mutation score is 100.00%

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

@github-actions

Copy link
Copy Markdown

This is addressed in release v3.0.0.

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

Labels

state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants