Repository navigation
Conversation
Test Results 69 files 69 suites 53m 51s ⏱️ Results for commit 39c8ea3. ♻️ This comment has been updated with latest results. |
vbreuss
force-pushed
the
feat/invocation-type-arguments
branch
from
December 4, 2026 11:51
14335f4 to
94afd69
Compare
vbreuss
force-pushed
the
feat/generic-matcher-type-argument
branch
from
December 4, 2026 13:29
ff0e1e0 to
c73f01e
Compare
🚀 Benchmark ResultsCompared to Memory
Time
CompleteWorkflowBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) Intel Xeon 6973P-C 3.55GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 MockCreationBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) INTEL XEON PLATINUM 8573C 3.20GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CompleteUnconfiguredBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 9V45 4.19GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CompleteMethodBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 9V45 4.13GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CompletePropertyBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 7763 3.23GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CompleteIndexerBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 7763 2.64GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CompleteEventBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) Intel Xeon 6975P-C 2.70GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CallbackBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) INTEL XEON PLATINUM 8573C 3.00GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 AsyncBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 7763 2.68GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 SequenceBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 9V74 3.69GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 |
vbreuss
force-pushed
the
feat/generic-matcher-type-argument
branch
2 times, most recently
from
December 4, 2026 16:49
338b4d8 to
10c79f0
Compare
…eric and VerifyGeneric
`SetupGeneric` and `VerifyGeneric` matched a parameter that depends on a type
argument as `object`: the matcher only saw the boxed value. A typed matcher
therefore also matched calls with other type arguments, and a negative matcher
matched the calls of every other type:
```csharp
sut.Mock.SetupGeneric.Write(It.IsAny<string>()).Throws<IOException>();
sut.Write<object>("x"); // threw, although the type argument is object
await That(sut.Mock.VerifyGeneric.Write(It.IsNot("a"))).Once();
sut.Write(42); // counted by It.IsNot("a")
```
The static type of the matcher now selects the type arguments of the calls it
matches, and the matcher then checks the value, the same way at the call, in
`VerifyGeneric` and in `VerifySetup`. A call matches when the type that the
parameter has in it converts to the type of the matcher:
- `T value`: `It.IsAny<string>()` matches `Write<string>(…)` only, not
`Write<object>("x")` or `Write<int>(1)`. `It.IsAny<Exception>()` also matches
`Write<ArgumentException>(…)`, and a matcher of `object`
(`It.IsAny<object>()`, `It.Satisfies<object>(…)`) matches every type argument.
- Nullable value types convert as in C#: `It.IsAny<int?>()` matches
`Write<int>(…)`, `It.IsAny<int>()` does not match `Write<int?>(…)`.
- `null` matches a `null` argument of every type argument,
`It.IsNull<string>()` only one of `string`.
- A parameter that only partly depends on a type argument (`IRequest<T>`,
`IEnumerable<T>`, `T?` of a value type) also takes a matcher of a type that
implements or derives from it exactly, or of the underlying type, and the type
arguments follow from it: `Send(It.IsAny<Ping>())` with `Ping : IRequest<int>`
matches `Send<int>(ping)`, `Store(It.IsAny<List<string>>())` matches
`Store<string>(list)` but not `Store<object>(list)`.
- When overloads share a setup, the rule of the called overload applies, also
for recorded calls: for `Overloaded<T>(object value)` next to
`Overloaded<T>(T value)` only the value is checked.
- `Match.AnyParameters()` still matches every type argument, and so does a
matcher that implements `IParameter<T>` for several types (`It.Contains`).
A matcher passed as a non-generic `IParameter` uses the type of the
`IParameter<T>` it implements. This changes setups and verifications that relied
on a typed matcher seeing the boxed value of another type argument, e.g. a call
`Publish<IEvent>(orderPlaced)` is no longer matched by `It.IsAny<OrderPlaced>()`;
use `It.Satisfies<object>(value => value is OrderPlaced)` for them.
Not breaking against v4.2.0: logger mocks first shipped in 4.3.0-pre.1 and
`SetupGeneric`/`VerifyGeneric` in 4.3.0-pre.3, so this is a behaviour change
of the 4.3 pre-releases only.
Type.GetInterfaces() on the runtime type of a matcher fails the trim analysis of the library (IL2070, IL2075), so the build broke. The built-in matchers now tell the type argument of their IParameter<T> through an internal interface, any other matcher given as a non-generic IParameter selects object, and a matcher of a type that implements the parameter type through a variant conversion now also matches.
vbreuss
force-pushed
the
feat/generic-matcher-type-argument
branch
from
December 4, 2026 18:04
10c79f0 to
39c8ea3
Compare
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



SetupGenericandVerifyGenericmatched a parameter that depends on a type argument asobject: the matcher only saw the boxed value. A typed matcher therefore also matched calls with other type arguments, and a negative matcher matched the calls of every other type:The static type of the matcher now selects the type arguments of the calls it matches, and the matcher then checks the value, the same way at the call, in
VerifyGenericand inVerifySetup. A call matches when the type that the parameter has in it converts to the type of the matcher:T value:It.IsAny<string>()matchesWrite<string>(…)only, notWrite<object>("x")orWrite<int>(1).It.IsAny<Exception>()also matchesWrite<ArgumentException>(…), and a matcher ofobject(It.IsAny<object>(),It.Satisfies<object>(…)) matches every type argument.It.IsAny<int?>()matchesWrite<int>(…),It.IsAny<int>()does not matchWrite<int?>(…).nullmatches anullargument of every type argument,It.IsNull<string>()only one ofstring.IRequest<T>,IEnumerable<T>,T?of a value type) also takes a matcher of a type that implements or derives from it exactly, or of the underlying type, and the type arguments follow from it:Send(It.IsAny<Ping>())withPing : IRequest<int>matchesSend<int>(ping),Store(It.IsAny<List<string>>())matchesStore<string>(list)but notStore<object>(list).Overloaded<T>(object value)next toOverloaded<T>(T value)only the value is checked.Match.AnyParameters()still matches every type argument, and so does a matcher that implementsIParameter<T>for several types (It.Contains).A matcher passed as a non-generic
IParameteruses the type of theIParameter<T>it implements. This changes setups and verifications that relied on a typed matcher seeing the boxed value of another type argument, e.g. a callPublish<IEvent>(orderPlaced)is no longer matched byIt.IsAny<OrderPlaced>(); useIt.Satisfies<object>(value => value is OrderPlaced)for them.Not breaking against v4.2.0: logger mocks first shipped in 4.3.0-pre.1 and
SetupGeneric/VerifyGenericin 4.3.0-pre.3, so this is a behaviour change of the 4.3 pre-releases only.