Skip to content

fix: match the whole array with an array matcher on a params object[] parameter - #1031

Merged
vbreuss merged 1 commit into
mainfrom
fix/params-object-array-matcher
Nov 18, 2026
Merged

vbreuss merged 1 commit into
mainfrom
fix/params-object-array-matcher

Conversation

@vbreuss

@vbreuss vbreuss commented Nov 18, 2026

Copy link
Copy Markdown
Member

A matcher for the array type on a params object[] (or params dynamic[]) parameter was captured as a single element instead of matching the whole array, so the setup or verification never matched a real call:

public interface ILog { void Log(int level, params object[] args); }

sut.Log(1, "a", 2);
sut.Mock.Verify.Log(1, It.IsAny<object[]>()).Once(); // failed, now passes

The overload that takes a value for every parameter is promoted with OverloadResolutionPriority(int.MaxValue). With a params object[] it accepts any argument list in its expanded form, because every matcher converts to object, so it outranked the overload that takes the array matcher. A plain object parameter has the same hazard and already skips the promotion (ParametersBlockAllValuesPromotion); a params object[] value parameter now skips it as well. The matcher overloads then win whenever they apply, and the all-values overload still binds literal elements such as Log(1, "a", 2) and an explicit object[], because no other overload accepts them.

The static type of the matcher decides between the two readings of a single matcher argument: It.IsAny<object[]>() (the array type) matches the whole array, It.IsAny<object>() (the element type) matches one element.

For a method whose only parameter is a params object[], a lone null now reaches the IParameters overload, like it does for a single object parameter. It is forwarded as a null matcher for the array, so Only(null) matches a call with a null array (it threw an ArgumentNullException before). On such a method, Only() now binds to the per-element matcher overload with no elements: it still matches only calls without arguments, but no longer offers .AnyParameters().

Other params element types and indexers are not affected. Delegates already bound correctly, because their value overloads carry no priorities.

@vbreuss vbreuss self-assigned this Nov 18, 2026
@vbreuss vbreuss added the bug Something isn't working label Nov 18, 2026
@vbreuss
vbreuss enabled stacked auto-merge (squash) November 18, 2026 15:51
@vbreuss
vbreuss disabled stacked auto-merge November 18, 2026 15:53
@vbreuss
vbreuss added this pull request to stack #1033 November 18, 2026 15:53
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Test Results

    47 files      47 suites   1h 23m 22s ⏱️
 4 894 tests  4 894 ✅ 0 💤 0 ❌
49 382 runs  49 382 ✅ 0 💤 0 ❌

Results for commit 543182a.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

🚀 Benchmark Results

Compared to main, which ran on the same runner. Times that change by more than 10% are marked.

Memory

Benchmark main PR Δ
Indexer (N=1000) 105,544 B 105,545 B 🔴 +1 B (±0%)

Time

Benchmark main PR Δ
Property (N=1) 152.3 ns 181.1 ns 🔴 +19%
CompleteWorkflowBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
Intel Xeon Platinum 8370C CPU 2.80GHz (Max: 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-v4

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

Complete Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1.309 μs 0.0147 μs 0.0130 μs 1.00 2.8 KB 1.00
Imposter 1.300 μs 0.0088 μs 0.0078 μs 0.99 3.17 KB 1.13
TUnitMocks 3.836 μs 0.0442 μs 0.0413 μs 2.93 10.3 KB 3.67
Moq 410.895 μs 1.4632 μs 1.3687 μs 313.90 46.33 KB 16.52
NSubstitute 25.176 μs 0.1113 μs 0.0986 μs 19.23 37.13 KB 13.24
FakeItEasy 23.980 μs 0.1026 μs 0.0909 μs 18.32 34.33 KB 12.24
MockCreationBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V45 4.28GHz, 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  

CreateMock Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 10.18 ns 0.359 ns 0.336 ns 1.00 136 B 1.00
Imposter 61.66 ns 3.675 ns 3.258 ns 6.06 504 B 3.71
TUnitMocks 18.13 ns 0.609 ns 0.569 ns 1.78 216 B 1.59
Moq 789.02 ns 24.289 ns 22.720 ns 77.55 2088 B 15.35
NSubstitute 1,012.49 ns 35.166 ns 31.174 ns 99.51 5032 B 37.00
FakeItEasy 986.55 ns 55.094 ns 51.535 ns 96.96 2755 B 20.26
CompleteUnconfiguredBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
Intel Xeon 6975P-C 3.56GHz, 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  

Unconfigured N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 404.0 ns 15.33 ns 14.34 ns 1.00 1.48 KB 1.00
Imposter 1 236.5 ns 8.34 ns 7.80 ns 0.59 1.06 KB 0.72
TUnitMocks 1 470.1 ns 20.36 ns 19.05 ns 1.17 1.81 KB 1.23
Moq 1 36,585.4 ns 191.26 ns 159.71 ns 90.66 9.88 KB 6.69
NSubstitute 1 5,543.1 ns 133.02 ns 124.43 ns 13.74 10.01 KB 6.78
FakeItEasy 1 4,695.5 ns 173.21 ns 162.02 ns 11.64 11.57 KB 7.84
Mockolate 10 1,503.0 ns 24.92 ns 23.31 ns 1.00 3.89 KB 1.00
Imposter 10 875.6 ns 25.25 ns 23.62 ns 0.58 2.89 KB 0.74
TUnitMocks 10 2,940.7 ns 92.86 ns 86.86 ns 1.96 8.47 KB 2.18
Moq 10 51,970.4 ns 295.26 ns 276.19 ns 34.59 24.63 KB 6.33
NSubstitute 10 15,858.7 ns 132.61 ns 124.04 ns 10.55 22.93 KB 5.89
FakeItEasy 10 20,497.0 ns 348.52 ns 308.96 ns 13.64 53.92 KB 13.86
Mockolate 1000 127,736.0 ns 2,144.94 ns 2,006.37 ns 1.00 266.86 KB 1.00
Imposter 1000 68,879.0 ns 1,821.29 ns 1,703.64 ns 0.54 203.99 KB 0.76
TUnitMocks 1000 273,817.7 ns 6,084.67 ns 5,393.90 ns 2.14 691.21 KB 2.59
Moq 1000 1,080,649.4 ns 7,389.33 ns 6,911.99 ns 8.46 1653.01 KB 6.19
NSubstitute 1000 1,090,296.1 ns 7,010.17 ns 6,214.34 ns 8.54 1434.38 KB 5.38
FakeItEasy 1000 2,353,740.5 ns 70,381.95 ns 65,835.32 ns 18.43 4690.6 KB 17.58
CompleteMethodBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V74 2.87GHz, 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  

Method N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 142.3 ns 3.91 ns 3.66 ns 1.00 600 B 1.00
Imposter 1 178.9 ns 1.54 ns 1.29 ns 1.26 728 B 1.21
TUnitMocks 1 487.0 ns 17.87 ns 16.72 ns 3.42 2088 B 3.48
Moq 1 148,391.6 ns 982.25 ns 870.74 ns 1,043.25 14900 B 24.83
NSubstitute 1 5,799.9 ns 120.89 ns 113.08 ns 40.78 9320 B 15.53
FakeItEasy 1 5,217.4 ns 79.67 ns 74.52 ns 36.68 8365 B 13.94
Mockolate 10 370.0 ns 2.41 ns 2.26 ns 1.00 1104 B 1.00
Imposter 10 347.7 ns 1.72 ns 1.61 ns 0.94 1088 B 0.99
TUnitMocks 10 1,415.3 ns 21.43 ns 20.04 ns 3.83 3840 B 3.48
Moq 10 154,063.8 ns 837.77 ns 699.58 ns 416.45 18901 B 17.12
NSubstitute 10 8,336.6 ns 78.89 ns 73.80 ns 22.53 12345 B 11.18
FakeItEasy 10 8,497.9 ns 123.45 ns 109.43 ns 22.97 16622 B 15.06
Mockolate 1000 26,953.9 ns 169.90 ns 150.61 ns 1.00 56544 B 1.00
Imposter 1000 21,902.6 ns 139.31 ns 116.33 ns 0.81 40688 B 0.72
TUnitMocks 1000 102,554.7 ns 952.45 ns 890.93 ns 3.80 203585 B 3.60
Moq 1000 368,216.3 ns 2,486.14 ns 2,325.54 ns 13.66 431938 B 7.64
NSubstitute 1000 287,607.0 ns 2,669.78 ns 2,497.31 ns 10.67 378038 B 6.69
FakeItEasy 1000 364,162.2 ns 8,001.54 ns 7,484.64 ns 13.51 944606 B 16.71
CompletePropertyBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V45 4.53GHz, 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  

Property N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 181.1 ns 2.36 ns 2.09 ns 1.00 904 B 1.00
Imposter 1 118.1 ns 1.47 ns 1.30 ns 0.65 672 B 0.74
TUnitMocks 1 297.3 ns 6.28 ns 5.87 ns 1.64 1672 B 1.85
Moq 1 5,623.4 ns 73.07 ns 64.78 ns 31.05 10568 B 11.69
NSubstitute 1 3,792.5 ns 36.16 ns 32.06 ns 20.94 11688 B 12.93
FakeItEasy 1 3,699.2 ns 82.51 ns 77.18 ns 20.43 11196 B 12.38
Mockolate 10 417.1 ns 6.66 ns 5.90 ns 1.00 1768 B 1.00
Imposter 10 256.6 ns 3.71 ns 3.28 ns 0.62 960 B 0.54
TUnitMocks 10 1,152.5 ns 11.07 ns 10.36 ns 2.76 4024 B 2.28
Moq 10 8,959.0 ns 250.77 ns 222.30 ns 21.49 18505 B 10.47
NSubstitute 10 8,745.5 ns 83.56 ns 78.17 ns 20.97 21553 B 12.19
FakeItEasy 10 9,320.9 ns 160.60 ns 142.37 ns 22.35 30785 B 17.41
Mockolate 1000 28,351.5 ns 247.53 ns 219.43 ns 1.00 96808 B 1.00
Imposter 1000 15,362.4 ns 290.46 ns 271.70 ns 0.54 32641 B 0.34
TUnitMocks 1000 92,857.2 ns 3,072.35 ns 2,873.88 ns 3.28 242489 B 2.50
Moq 1000 347,313.4 ns 5,170.42 ns 4,836.42 ns 12.25 836537 B 8.64
NSubstitute 1000 527,028.2 ns 13,640.70 ns 12,759.52 ns 18.59 1139722 B 11.77
FakeItEasy 1000 631,676.1 ns 5,434.49 ns 4,817.53 ns 22.28 2194324 B 22.67
CompleteIndexerBenchmarks
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  

Indexer N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 326.1 ns 2.44 ns 2.04 ns 1.00 1.61 KB 1.00
Imposter 1 243.1 ns 4.42 ns 3.92 ns 0.75 1.07 KB 0.67
TUnitMocks 1 571.2 ns 3.22 ns 3.01 ns 1.75 2.72 KB 1.69
Moq 1 140,826.1 ns 892.28 ns 745.09 ns 431.83 20.32 KB 12.62
NSubstitute 1 7,277.7 ns 140.66 ns 131.57 ns 22.32 12.73 KB 7.91
FakeItEasy 1 7,006.2 ns 62.99 ns 52.60 ns 21.48 13.27 KB 8.25
Mockolate 10 897.9 ns 10.16 ns 9.50 ns 1.00 2.52 KB 1.00
Imposter 10 598.2 ns 7.86 ns 6.97 ns 0.67 2.13 KB 0.84
TUnitMocks 10 1,939.6 ns 28.57 ns 26.73 ns 2.16 5.37 KB 2.13
Moq 10 152,625.4 ns 967.19 ns 904.71 ns 169.99 29.69 KB 11.77
NSubstitute 10 18,339.3 ns 197.79 ns 154.42 ns 20.43 25.52 KB 10.11
FakeItEasy 10 16,254.4 ns 342.46 ns 320.33 ns 18.10 32.47 KB 12.87
Mockolate 1000 64,815.2 ns 225.59 ns 211.02 ns 1.00 103.07 KB 1.00
Imposter 1000 39,405.1 ns 167.49 ns 148.48 ns 0.61 118.15 KB 1.15
TUnitMocks 1000 142,705.5 ns 427.52 ns 357.00 ns 2.20 293.67 KB 2.85
Moq 1000 763,251.1 ns 8,508.14 ns 7,958.52 ns 11.78 1006.45 KB 9.76
NSubstitute 1000 1,202,496.5 ns 17,327.79 ns 13,528.40 ns 18.55 1465.59 KB 14.22
FakeItEasy 1000 1,048,766.9 ns 26,598.23 ns 23,578.64 ns 16.18 2153 KB 20.89
CompleteEventBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V45 4.34GHz, 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  

Event Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 82.45 ns 0.638 ns 0.566 ns 1.00 696 B 1.00
Imposter 104.72 ns 0.578 ns 0.541 ns 1.27 512 B 0.74
TUnitMocks 93.29 ns 0.434 ns 0.385 ns 1.13 1392 B 2.00
Moq 7,327.33 ns 47.052 ns 44.012 ns 88.88 12760 B 18.33
NSubstitute 2,744.47 ns 54.026 ns 50.536 ns 33.29 9192 B 13.21
FakeItEasy 108,370.70 ns 1,437.207 ns 1,344.365 ns 1,314.48 15618 B 22.44
CallbackBenchmarks
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  

Callback Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 150.8 ns 1.54 ns 1.36 ns 1.00 792 B 1.00
Imposter 154.3 ns 1.49 ns 1.24 ns 1.02 616 B 0.78
TUnitMocks 376.1 ns 2.07 ns 1.93 ns 2.49 2056 B 2.60
Moq 61,312.7 ns 294.72 ns 275.69 ns 406.74 9055 B 11.43
NSubstitute 3,244.0 ns 14.16 ns 11.82 ns 21.52 7864 B 9.93
FakeItEasy 3,167.9 ns 19.05 ns 17.82 ns 21.02 6930 B 8.75

@vbreuss
vbreuss force-pushed the fix/params-object-array-matcher branch 2 times, most recently from 9a6c42c to 24c2b34 Compare November 18, 2026 20:05
…[]` parameter

A matcher for the array of a `params object[]` parameter was captured as one element of the array. For `Log(int level, params object[] args)`, `Verify.Log(1, It.IsAny<object[]>())` bound the overload that takes values: it is promoted with `[OverloadResolutionPriority(int.MaxValue)]`, priorities are applied before the better overload is chosen, and in its expanded form it accepts any argument list, because every matcher converts to `object`. The setup or verification then expected a call with the matcher itself as argument and matched nothing. The same applied to `params dynamic[]`, `params object?[]` and a `params T[]` whose `T` is a type parameter of the mocked type that is closed over `object`.

The static type of the matcher now decides: a matcher for the array type matches the whole array, a matcher for the element type matches one element. The overloads that differ from the all-values overload only by a matcher for the `params` parameter now outrank it. With other parameters the order is `(values, IParameter<object[]>?)`, all values, `IParameters`; for a lone `params object[]` it is `IParameter<object[]>?`, `IParameters`, `params IParameter<object>[]`, all values. Nothing else moves: the overloads that replace other values by matchers stay below the all-values overload, so a `default` literal next to a `params object[]` (`Setup.Log(default, "a")`, `Setup.Log(default)`, a `default` for an optional parameter) keeps meaning the value and keeps `.AnyParameters()`.

```csharp
sut.Log(1, "a", 2);
sut.Mock.Verify.Log(1, It.IsAny<object[]>()).Once(); // failed before
sut.Mock.Verify.Log(1, "a", 2).Once(); // as before
sut.Mock.Verify.Log(It.IsAny<int>(), It.IsAny<object>(), It.Is<object>(2)).Once(); // as before
```

A lone `params object[]` needs two more things to keep the meaning of existing calls. A call without arguments would bind to the per-element overload and lose `.AnyParameters()`, so the method gets an overload without parameters (unless an overload of the method has none already): `Setup.Only()` and `Setup.Only().AnyParameters()` mean what they meant. Several `null` literals (`Setup.Only(null, null)`) now bind to the per-element overload, so its elements are nullable and a `null` matcher stands for a `null` element; the call keeps matching `Only(null, null)`.

These calls compiled before but could not work, and work now:

- `Only(Match.AnyParameters())` binds the `IParameters` overload and matches every call.
- Matchers for the elements of a lone `params object[]` match element by element: `Only(It.IsAny<object>())`, `Only(It.IsAny<string>())`, `Only(It.IsAny<object>(), It.IsAny<object>())`.
- A `null` literal for the array means a `null` array instead of throwing an `ArgumentNullException`: `Log(1, null)`, `Log(default, default)`, `Only(null)`, `Only(args: null)`.
- Next to an overload with an `object` parameter, the all-values overload of a lone `params object[]` is not promoted either, so the two compete like the methods do: for `Ov(object)` and `Ov(params object[])`, `Setup.Ov("a")`, `Setup.Ov((object)null)` and `Setup.Ov(It.IsAny<object>())` configure `Ov(object)`, which is the method that `sut.Ov("a")` calls. They configured the `params` method before.

Calls that compiled before and behave differently now:

- `.AnyParameters()` after a matcher for the array no longer compiles (CS1061), for example `Setup.Log(1, It.IsAny<object[]>()).AnyParameters()`. It only compiled because the matcher was captured as a value. This is the only call that stops compiling, and no call becomes ambiguous.
- With `.AnyParameters()`, `Setup.Ov("a").AnyParameters()` ignores the parameters of `Ov(object)` instead of those of `Ov(params object[])`, as a consequence of the last fix above.
- A `null` literal in the per-element overload of a method with other parameters (`Setup.Log(It.IsAny<int>(), null, null)`) matches `null` elements instead of nothing.
- In a group that has an overload with an `object` parameter and an overload with as many value-type parameters as the call has arguments (`M(object)`, `M(int, int)`, `M(params object[])`), `Setup.M(null, 1)` binds `M(IParameter<int>?, int)` instead of the `params` overload.

Known gaps that did not change and are tracked separately:

- A matcher for an element next to literal values binds the all-values overload and never matches: `Log(1, It.IsAny<object>())`, `Log(1, "a", It.IsAny<object>())`, `Only("a", It.IsAny<object>())`.
- Above four parameters no overload combines values with a matcher, so `Five(1, 2, 3, 4, It.IsAny<object[]>())` binds the all-values overload and never matches; these methods keep their priorities.
- A type parameter of the method is not covered: `Gen<object>(1, It.IsAny<object[]>())` on `Gen<T>(int level, params T[] args)` still binds the all-values overload.
- A `null` array that is typed as such still throws an `ArgumentNullException`: `Log(1, (object[])null)`, `Only((object[])null)`, and `Five(1, 2, 3, 4, null)` above four parameters.

A matcher for the whole array already bound correctly on delegates; their overloads did not change.

The tests compile about 200 `Setup` and `Verify` calls against the generated code, in classic and in union mode, and pin for each call the overload the compiler binds and the invocations it matches.
@vbreuss
vbreuss force-pushed the fix/params-object-array-matcher branch from 24c2b34 to 543182a Compare November 18, 2026 20:13
@sonarqubecloud

Copy link
Copy Markdown

@vbreuss
vbreuss merged commit 42c3a5c into main Nov 18, 2026
24 checks passed
@vbreuss
vbreuss deleted the fix/params-object-array-matcher branch November 18, 2026 20:43
@github-actions

Copy link
Copy Markdown

This is addressed in release v4.2.0.

@github-actions github-actions Bot added the state: released The issue is released label Nov 19, 2026
vbreuss added a commit that referenced this pull request Nov 20, 2026
On a generic method such as `Plain<T>(T value)`, `Verify.Plain<object>(It.IsAny<object?>())` and `Setup.Plain<object>(Match.AnyParameters())` never matched. They bind the overload that takes values: it is promoted with `[OverloadResolutionPriority(int.MaxValue)]`, and once the call closes `T` over `object`, every matcher converts to the parameter, so the matcher was captured as the expected value. A declared `object` parameter avoids this because its overload that takes values is not promoted (#1031 extends that rule to `params object[]`), but a type parameter only becomes `object` at the call site.

The same rule cannot be applied to type parameters. A `null` or `default` literal converts to the matcher types as well, so overload resolution cannot tell it from a matcher: without the promotion, or with the matcher overloads ranked above it, `Plain<string>(null)` and `Plain<int>(default)` would bind the `IParameters` or matcher overload and match everything or nothing, and `.AnyParameters()` after them would stop compiling.

So the bindings stay as they are, and the overload that takes values recognizes a matcher at runtime. For a parameter typed with a type parameter that can be closed over `object` (no `struct`, `unmanaged`, base class or interface constraint and no `allows ref struct`), the generated setup and verification pass the value through the new `Matchers.IsValueOrMatcher`: an `IParameter<T>` is used as the matcher, an `IParameters` for the only parameter of a method as the parameters match, and any other value is compared by equality as before. These setups use `WithParameterCollection` instead of `WithLiteralValues`, and the verifications create the matcher once before counting, so matching still does not allocate. This holds for every arity, above four parameters as well, and for the overloads that mix values and matchers.

```csharp
sut.Plain<object>("x");
sut.Two<object>(1, "x");
sut.Mock.Verify.Plain<object>(It.IsAny<string>()).Once(); // failed before
sut.Mock.Verify.Plain<object>(Match.AnyParameters()).Once(); // failed before
sut.Mock.Verify.Two<object>(1, It.IsAny<object>()).Once(); // failed before
sut.Mock.Verify.Plain<object>("x").Once(); // as before
```

No call binds differently. The only change in behavior is that a matcher passed as the value of such a parameter now acts as a matcher; a non-generic `object` parameter, other type arguments and type parameters that cannot be `object` behave as before. A `params T[]` of a method type parameter (`Gen<object>(1, It.IsAny<object[]>())`) remains the known gap from #1031.

Fixes #1044
vbreuss added a commit that referenced this pull request Nov 20, 2026
Methods with a `params` parameter get a per-element overload for `Setup` and `Verify`, so `It.Is(1), It.IsAny<int>()` matches the elements one by one. Delegate mocks never emitted it: on a `params T[]` delegate such a call did not compile, and on a `params object[]` delegate the element matchers bound to the overload that takes values and were compared as values, so the setup never applied and the verification never matched.

The delegate emitter now adds the same overloads as the method emitter, through the same helpers and with the same priorities: the per-element overload for every arity (also above four parameters), and for a lone `params object[]` the overload without parameters that keeps `Setup().AnyParameters()` for a call without arguments. This covers the setup and verify interfaces, their implementations and the verify monitor. A `params` delegate keeps the classic overloads in union mode as well, so both modes are covered. The whole-array matcher of #1031 still matches the whole array, literal elements still match by value, and the null literals of #1032 keep their meaning; `ParamsObjectArrayTests` now compares the delegates with the methods for all of these calls, including `params string[]`.

As on methods, a `null` literal for the array next to a matcher for another parameter (`Setup(It.IsAny<int>(), null)`) is now ambiguous (CS0121) between the whole-array and the per-element overload; it compiled for delegates only since #1032 and only with `OverloadResolutionPriorityAttribute`. `It.IsNull<object[]>()` expresses it unambiguously.

```csharp
public delegate int Logger(int level, params object[] args);

Logger logger = Logger.CreateMock();
logger.Mock.Setup(It.Is(4), It.IsAny<object>(), It.Is<object>(2)).Returns(1);

int result = logger(4, "a", 2); // 1, before: 0
logger.Mock.Verify(It.Is(4), It.IsAny<object>(), It.Is<object>(2)).Once();
```

Fixes #1045
vbreuss added a commit that referenced this pull request Nov 20, 2026
Methods with a `params` parameter get a per-element overload for `Setup` and `Verify`, so `It.Is(1), It.IsAny<int>()` matches the elements one by one. Delegate mocks never emitted it: on a `params T[]` delegate such a call did not compile, and on a `params object[]` delegate the element matchers bound to the overload that takes values and were compared as values, so the setup never applied and the verification never matched.

The delegate emitter now adds the same overloads as the method emitter, through the same helpers and with the same priorities: the per-element overload for every arity (also above four parameters), and for a lone `params object[]` the overload without parameters that keeps `Setup().AnyParameters()` for a call without arguments. This covers the setup and verify interfaces, their implementations and the verify monitor, in classic and in union mode (a member with a `params` parameter always has the classic overloads). The whole-array matcher of #1031 still matches the whole array and literal elements still match by value; `ParamsObjectArrayTests` compares the delegates with the methods for these calls, including `params string[]`.

Without `OverloadResolutionPriorityAttribute` (classic mode on .NET 8, .NET Framework or netstandard without a polyfill) a call without `params` arguments, such as `Setup()`, `Setup().AnyParameters()` or `Setup(It.IsAny<int>())`, would be ambiguous between the per-element overload and the one that takes the array as values. Methods already had that problem, so in that case every `params T[]` member, method or delegate, now also gets an overload that leaves out the `params` parameter and matches an empty array. With the attribute the generated code is unchanged.

A failed verification with element matchers now lists them, for example `Invoke(It.IsAny<int>(), [It.IsAny<object>(), 2])`, and the overload without `params` arguments prints `[]`. The element matcher is built once per verification instead of once per recorded call.

Breaking change, as on methods: on a `params T[]` delegate, a `null` array literal next to any matcher or `null` for another parameter no longer compiles (CS0121 between the whole-array and the per-element overload), for example `Setup(It.IsAny<int>(), null)`, `Setup(It.IsAny<int>(), args: null)` or `Setup(null, null)` on `(int, params object[])`. This also applies to delegates with five or more parameters, with optional parameters, or with an `object` or `int?` first parameter. Use `It.IsNull<T[]>()` for the array instead. Without `OverloadResolutionPriorityAttribute`, `null` literals for the elements are ambiguous as well (`Setup(null, null)` on a lone `params string[]`, `Setup(It.IsAny<int>(), null, null)`); pass typed values such as `(string?)null` instead.

```csharp
public delegate int Logger(int level, params object[] args);

Logger logger = Logger.CreateMock();
logger.Mock.Setup(It.Is(4), It.IsAny<object>(), It.Is<object>(2)).Returns(1);

int result = logger(4, "a", 2); // 1, before: 0
logger.Mock.Verify(It.Is(4), It.IsAny<object>(), It.Is<object>(2)).Once();
```
vbreuss added a commit that referenced this pull request Nov 20, 2026
On a generic method such as `Plain<T>(T value)`, `Verify.Plain<object>(It.IsAny<object?>())` and `Setup.Plain<object>(Match.AnyParameters())` never matched. They bind the overload that takes values: it is promoted with `[OverloadResolutionPriority(int.MaxValue)]`, and once the call closes `T` over `object`, every matcher converts to the parameter, so the matcher was captured as the expected value. A declared `object` parameter avoids this because its overload that takes values is not promoted (#1031 extends that rule to `params object[]`), but a type parameter only becomes `object` at the call site.

The same rule cannot be applied to type parameters. A `null` or `default` literal converts to the matcher types as well, so overload resolution cannot tell it from a matcher: without the promotion, or with the matcher overloads ranked above it, `Plain<string>(null)` and `Plain<int>(default)` would bind the `IParameters` or matcher overload and match everything or nothing, and `.AnyParameters()` after them would stop compiling.

So the bindings stay as they are, and the overload that takes values recognizes a matcher at runtime. For a parameter typed with a type parameter that can be closed over `object` (no `struct`, `unmanaged`, base class or interface constraint and no `allows ref struct`), the generated setup and verification pass the value through the new `Matchers.IsValueOrMatcher`: an `IParameter<T>` is used as the matcher, an `IParameters` for the only parameter of a method as the parameters match, and any other value is compared by equality as before. These setups use `WithParameterCollection` instead of `WithLiteralValues`, and the verifications create the matcher once before counting, so matching still does not allocate. This holds for every arity, above four parameters as well, and for the overloads that mix values and matchers.

```csharp
sut.Plain<object>("x");
sut.Two<object>(1, "x");
sut.Mock.Verify.Plain<object>(It.IsAny<string>()).Once(); // failed before
sut.Mock.Verify.Plain<object>(Match.AnyParameters()).Once(); // failed before
sut.Mock.Verify.Two<object>(1, It.IsAny<object>()).Once(); // failed before
sut.Mock.Verify.Plain<object>("x").Once(); // as before
```

No call binds differently. The only change in behavior is that a matcher passed as the value of such a parameter now acts as a matcher; a non-generic `object` parameter, other type arguments and type parameters that cannot be `object` behave as before. A `params T[]` of a method type parameter (`Gen<object>(1, It.IsAny<object[]>())`) remains the known gap from #1031.

Fixes #1044
vbreuss added a commit that referenced this pull request Nov 20, 2026
On a generic method such as `Plain<T>(T value)`, `Verify.Plain<object>(It.IsAny<object?>())` and `Setup.Plain<object>(Match.AnyParameters())` never matched. They bind the overload that takes values: it is promoted with `[OverloadResolutionPriority(int.MaxValue)]`, and once the call closes `T` over `object`, every matcher converts to the parameter, so the matcher was captured as the expected value. A declared `object` parameter avoids this because its overload that takes values is not promoted (#1031 extends that rule to `params object[]`), but a type parameter only becomes `object` at the call site.

The same rule cannot be applied to type parameters. A `null` or `default` literal converts to the matcher types as well, so overload resolution cannot tell it from a matcher: without the promotion, or with the matcher overloads ranked above it, `Plain<string>(null)` and `Plain<int>(default)` would bind the `IParameters` or matcher overload and match everything or nothing, and `.AnyParameters()` after them would stop compiling.

So the bindings stay as they are, and the overload that takes values recognizes a matcher at runtime. For a parameter typed with a type parameter that can be closed over `object` (no `struct`, base class or interface constraint and no `allows ref struct`), the generated setup and verification check whether the value is an `IParameter<T>`: then it is used as the matcher (`Matchers.IsValueOrMatcher` in setups, `Matchers.AsMatcher` in verifications), and any other value is compared by equality as before. A lone parameters match, for the only parameter or next to an empty trailing `params` array, makes the overload stand in for the `IParameters` overload as a whole: the setup is a parameters setup that keeps `AnyParameters()`, and the verification matches and describes the parameters like that overload. Plain values keep the `WithLiteralValues` setup and the inline equality comparison in verifications, so they allocate no more than before; only a value that is a matcher switches to `WithParameterCollection`. This holds for every arity, above four parameters as well, and for the overloads that mix values and matchers.

```csharp
sut.Plain<object>("x");
sut.Two<object>(1, "x");
sut.Log<object>("x");
sut.Mock.Verify.Plain<object>(It.IsAny<string>()).Once(); // failed before
sut.Mock.Verify.Plain<object>(Match.AnyParameters()).Once(); // failed before
sut.Mock.Verify.Two<object>(1, It.IsAny<object>()).Once(); // failed before
sut.Mock.Verify.Log<object>(Match.AnyParameters()).Once(); // failed before, Log<T>(T value, params int[] rest)
sut.Mock.Verify.Plain<object>("x").Once(); // as before
```

No call binds differently. The only change in behavior is that a matcher passed as the value of such a parameter now acts as a matcher; a non-generic `object` parameter, other type arguments and type parameters that cannot be `object` behave as before. A matcher that does not convert to the parameter type, such as `It.IsAny<int>()` for `Plain<object>`, is still a value, as for a declared `object` parameter. A `params T[]` of a method type parameter (`Gen<object>(1, It.IsAny<object[]>())`) remains the known gap from #1031.
vbreuss added a commit that referenced this pull request Nov 21, 2026
… `object`

A matcher passed to a `params T[]` parameter of a generic method that the call closes over `object` was captured as a value. For `Only<T>(params T[] args)` and `Sum<T>(int level, params T[] args)`, every matcher converts to `object`, so `Verify.Only<object>(It.IsAny<object>())`, `Only<object>(It.IsAny<object[]>())`, `Only<object>(Match.AnyParameters())` and `Sum<object>(1, It.IsAny<object>())` bound the overload that takes values, which is promoted with `[OverloadResolutionPriority(int.MaxValue)]`, and matched nothing. Before this change no call could set up or verify such a method with a matcher.

The overload that takes values now recognizes the matchers at runtime, as #1071 does for a parameter of type `T`, and applies the rules of #1031 for `params object[]`:

- A lone matcher for the array matches the whole array: `Only<object>(It.IsAny<object[]>())`.
- Matchers for the elements match element by element, and plain values next to them are compared by equality: `Only<object>(It.IsAny<object>())`, `Sum<object>(1, "a", It.IsAny<object>())`.
- A lone `Match.AnyParameters()` or `Match.Parameters(…)` for a lone `params T[]` stands for the parameters.

```csharp
sut.Only<object>(1, "a");
sut.Mock.Verify.Only<object>(It.IsAny<object>(), "a").Once(); // failed before
sut.Mock.Verify.Only<object>(It.IsAny<object[]>()).Once(); // failed before
sut.Mock.Verify.Only<object>(1, "a").Once(); // as before
```

Plain values keep the comparison they had. A matcher that does not convert to the element type stays a value, as for a parameter of type `T`: `It.IsAny<int>()` for `Only<object>` still matches nothing.

One call behaves differently for every type argument of such a method: a `null` array now matches a `null` array instead of throwing an `ArgumentNullException`, for example `Setup.Sum<string>(1, null)` or `Verify.Only<object>(null)`, as #1031 defined it for `params object[]`. A `params` array of another element type, such as `params string[]`, still throws.

Consumers without `OverloadResolutionPriorityAttribute` get an overload that leaves out the `params` array; it keeps matching only an empty array.

Not covered, as for `params object[]`: a matcher for an element next to plain values on a method that is not generic (`Log(1, It.IsAny<object>())`), and a type argument that is inferred from the matcher (`Only(It.IsAny<string>())`).
vbreuss added a commit that referenced this pull request Nov 21, 2026
Implements #1039.

Every matcher converts to `object`, so a matcher passed where `Setup` or `Verify` takes an `object` value can bind as the value itself. The setup or verification then expects a call with the matcher object as argument and silently matches nothing:

```csharp
public interface IFoo
{
	void Take(object value);
	void Log(int level, params object[] args);
}

sut.Take(5);
sut.Log(1, "a", 2);
sut.Mock.Verify.Take(It.IsAny<int>()).Once();             // fails: It.IsAny<int>() is no matcher for object
sut.Mock.Verify.Log(1, "a", It.IsAny<object>()).Once();   // fails: no overload mixes values with element matchers
```

#1030, #1031 and #1071 already fixed the cases where a matcher for the parameter type was compared as a value. What is left cannot work as written: a matcher for another type (`It.IsAny<int>()` for an `object` parameter, property or indexer value, or indexer key), element matchers of a `params object[]` or `params T[]` next to plain values, an `object` parameter above four parameters next to plain values in classic mode, and a type argument inferred from the matcher (`Setup.Accept(It.IsAny<int>())` on `Accept<T>(T value)` infers `T` as the matcher type).

The new warning Mockolate0007 reports a matcher (a type implementing `IParameter`) that binds to a value parameter of a generated `Setup` or `Verify` member, or of `Set` on a property or indexer verification. It knows the cases that work at runtime and does not report them: a matcher for the value type on a parameter typed with a type parameter that can be `object` (the same rule the generator uses for #1071), and the matcher case of a union parameter. `It.Is<object>(matcher)` and an explicit `(object)` cast are not reported, so a matcher object can still be the expected value.

The message says what to change, depending on why the matcher is compared as a value:

- a matcher for another type: use a matcher for the value type;
- a matcher for the value type next to plain values or matchers for other types: pass matchers of the parameter types for the other arguments as well;
- a type argument inferred from the matcher: state the type arguments explicitly;
- a custom matcher that is also a value of the parameter type: cast it to `IParameter<T>`, or, where even that converts to the value type, that no overload takes it as a matcher.

Built against the generated code of `Mockolate.Tests` in classic (net10.0) and union (net11.0) mode, every reported call fails at runtime and every call that matches is not reported. The suite itself has one hit, `DynamicMembersTests` verifying `Dyn5("a", 2, 3, 4, It.IsAny<object>())`: in classic mode the matcher is compared as a value. The test only pins the failure message, so it keeps the call with the warning suppressed.

Known gaps that the rule does not report: `It.IsOut`/`It.IsRef` matchers and `Match.AnyParameters()` in a value parameter, because they are no `IParameter`. For a lone `params T[]` of a generic method closed over `object` no spelling reaches the matcher overload; the rule reports it, but fixing it needs a generator change.

The descriptor lives in `MatcherAsValueAnalyzer` instead of `Rules`, like Mockolate0003 and Mockolate0006, because release tracking reports RS2002 for an unshipped rule declared in another file. The conventions and the comment in `Rules.cs` now say so for all three.
vbreuss added a commit that referenced this pull request Nov 21, 2026
A matcher for a `params T[]` parameter of a generic method was captured as a value. The overload that takes values was promoted with `[OverloadResolutionPriority(int.MaxValue)]`, so for `Only<T>(params T[] args)` and `Sum<T>(int level, params T[] args)` the call `Setup.Only(It.IsAny<string>())` inferred `T` as the matcher type, and with the type argument `object`, to which every matcher converts, `Verify.Only<object>(It.IsAny<object>())`, `Only<object>(It.IsAny<object[]>())`, `Only<object>(Match.AnyParameters())` and `Sum<object>(1, It.IsAny<object>())` bound the overload that takes values and matched nothing. No call could set up or verify such a method with a matcher.

A `params` array of a type parameter now blocks that promotion, as #1098 does for a parameter of type `T`: whenever a matcher overload is applicable, it outranks the overload that takes values, and it infers the type argument from the matcher. The rules of #1031 for `params object[]` apply:

- A lone matcher for the array matches the whole array: `Only<object>(It.IsAny<object[]>())`.
- Matchers for the elements match element by element: `Only(It.IsAny<string>())` sets up `Only<string>`, and `Only<object>(It.IsAny<object>())` matches one element.
- `Match.AnyParameters()` and `Match.Parameters(…)` for a lone `params T[]` stand for the parameters.
- A lone `null` for a lone `params T[]` forwards to the overload that takes values, as #1098 does for a parameter of type `T`, so it stands for a `null` array.
- A lone `params T[]` gets the overload without arguments that `params object[]` has, so `Setup.Only<object>().AnyParameters()` keeps working.

Matchers that still bind the overload that takes values, which only happens for the type argument `object`, are recognized at runtime, as #1071 does for a parameter of type `T`: `Only<object>(It.IsAny<object>(), "a")` and `Sum<object>(1, "a", It.IsAny<object>())` match element by element and compare the plain values next to them by equality. Plain values keep the comparison they had.

```csharp
sut.Only<object>(1, "a");
sut.Only("a");
sut.Mock.Verify.Only<object>(It.IsAny<object>(), "a").Once(); // failed before
sut.Mock.Verify.Only<object>(It.IsAny<object[]>()).Once(); // failed before
sut.Mock.Verify.Only(It.IsAny<string>()).Once(); // failed before
sut.Mock.Verify.Only<object>(1, "a").Once(); // as before
```

One call behaves differently for every type argument of such a method: a `null` array now matches a `null` array instead of throwing an `ArgumentNullException`, for example `Setup.Sum<string>(1, null)` or `Verify.Only<object>(null)`, as #1031 defined it for `params object[]`. A `params` array of another element type, such as `params string[]`, still throws.

This is a narrow source break, as in #1098: `.AnyParameters()` is no longer available after a matcher or a lone `null` for such a `params` array, or after a `null` or `default` literal for another parameter next to it (e.g. `Setup.Sum<object>(1, null).AnyParameters()`), because such a call now binds a matcher or `IParameters` overload. Use `Match.AnyParameters()` instead.

Consumers without `OverloadResolutionPriorityAttribute` get an overload that leaves out the `params` array; it keeps matching only an empty array.

Not covered, as for `params object[]`: a matcher for an element next to plain values without the type argument `object`, such as `Sum(1, It.IsAny<string>())`, which infers `T` as the matcher type.
vbreuss added a commit that referenced this pull request Nov 21, 2026
…1096)

Every matcher converts to `object`, so a matcher passed where `Setup` or `Verify` takes an `object` value can bind as the value itself. The setup or verification then expects a call with the matcher object as argument and silently matches nothing:

```csharp
public interface IFoo
{
	void Take(object value);
	void Log(int level, params object[] args);
}

sut.Take(5);
sut.Log(1, "a", 2);
sut.Mock.Verify.Take(It.IsAny<int>()).Once();             // fails: It.IsAny<int>() is no matcher for object
sut.Mock.Verify.Log(1, "a", It.IsAny<object>()).Once();   // fails: no overload mixes values with element matchers
```

#1030, #1031 and #1071 already fixed the cases where a matcher for the parameter type was compared as a value. What is left cannot work as written: a matcher for another type (`It.IsAny<int>()` for an `object` parameter, property or indexer value, or indexer key), element matchers of a `params object[]` or `params T[]` next to plain values, an `object` parameter above four parameters next to plain values in classic mode, and a type argument inferred from the matcher (`Setup.Accept(It.IsAny<int>())` on `Accept<T>(T value)` infers `T` as the matcher type).

The new warning Mockolate0007 reports a matcher (a type implementing `IParameter`) that binds to a value parameter of a generated `Setup` or `Verify` member, or of `Set` on a property or indexer verification. It knows the cases that work at runtime and does not report them: a matcher for the value type on a parameter typed with a type parameter that can be `object` (the same rule the generator uses for #1071), and the matcher case of a union parameter. `It.Is<object>(matcher)` and an explicit `(object)` cast are not reported, so a matcher object can still be the expected value.

The message says what to change, depending on why the matcher is compared as a value:

- a matcher for another type: use a matcher for the value type;
- a matcher for the value type next to plain values or matchers for other types: pass matchers of the parameter types for the other arguments as well;
- a type argument inferred from the matcher: state the type arguments explicitly;
- a custom matcher that is also a value of the parameter type: cast it to `IParameter<T>`, or, where even that converts to the value type, that no overload takes it as a matcher.

Built against the generated code of `Mockolate.Tests` in classic (net10.0) and union (net11.0) mode, every reported call fails at runtime and every call that matches is not reported. The suite itself has one hit, `DynamicMembersTests` verifying `Dyn5("a", 2, 3, 4, It.IsAny<object>())`: in classic mode the matcher is compared as a value. The test only pins the failure message, so it keeps the call with the warning suppressed.

Known gaps that the rule does not report: `It.IsOut`/`It.IsRef` matchers and `Match.AnyParameters()` in a value parameter, because they are no `IParameter`. For a lone `params T[]` of a generic method closed over `object` no spelling reaches the matcher overload; the rule reports it, but fixing it needs a generator change.

The descriptor lives in `MatcherAsValueAnalyzer` instead of `Rules`, like Mockolate0003 and Mockolate0006, because release tracking reports RS2002 for an unshipped rule declared in another file. The conventions and the comment in `Rules.cs` now say so for all three.
vbreuss added a commit that referenced this pull request Nov 21, 2026
A matcher for a `params T[]` parameter of a generic method was captured as a value. The overload that takes values was promoted with `[OverloadResolutionPriority(int.MaxValue)]`, so for `Only<T>(params T[] args)` and `Sum<T>(int level, params T[] args)` the call `Setup.Only(It.IsAny<string>())` inferred `T` as the matcher type, and with the type argument `object`, to which every matcher converts, `Verify.Only<object>(It.IsAny<object>())`, `Only<object>(It.IsAny<object[]>())`, `Only<object>(Match.AnyParameters())` and `Sum<object>(1, It.IsAny<object>())` bound the overload that takes values and matched nothing. No call could set up or verify such a method with a matcher.

A `params` array of a type parameter now blocks that promotion, as #1098 does for a parameter of type `T`: whenever a matcher overload is applicable, it outranks the overload that takes values, and it infers the type argument from the matcher.

- A lone matcher for the array matches the whole array: `Only<object>(It.IsAny<object[]>())`.
- Matchers for the elements match element by element: `Only(It.IsAny<string>())` sets up `Only<string>`, and `Only<object>(It.IsAny<object>())` matches one element. A `null` element next to them matches a `null` element, also for a nullable type argument.
- `Match.AnyParameters()` and `Match.Parameters(…)` for a lone `params T[]` stand for the parameters.
- A lone `null` for a lone `params T[]` stands for a `null` array, and a `null` for the array next to matchers for the other parameters binds the matcher for the whole array, so it does as well: `Setup.Sum<object>(It.IsAny<int>(), null)`. Above four parameters no overload combines values with the matcher for the whole array.
- A lone `null` or `default` for a parameter before such an array forwards to the overload that takes values, as #1098 does for a parameter of type `T`, so `Setup.Sum<object>(default)` stands for `Sum<object>(0)` instead of any parameters. The same holds for a non-generic sibling with a value type parameter whose all-values overload is not promoted, such as `F(int value)` beside `F<T>(T value)`, which #1098 stopped promoting, or beside `F<T>(params T[] values)`, which this change stops promoting.
- A lone `params T[]` gets the overload without arguments that `params object[]` has, so `Setup.Only<object>().AnyParameters()` keeps working, unless a sibling with as many type parameters takes a call without arguments, such as `Only<T>(T value = default!)`, which the call on the mock binds; this also holds without `OverloadResolutionPriorityAttribute`. A lone non-generic `params` array beside such a generic sibling, such as `Pick(params string[])` beside `Pick<T>(params T[])`, gets that overload as well, so `Setup.Pick().AnyParameters()` keeps working, and a lone `null` for it forwards to the overload that takes values.

Matchers that still bind the overload that takes values, which only happens for the type argument `object`, are recognized at runtime, as #1071 does for a parameter of type `T`: `Only<object>(It.IsAny<object>(), "a")` and `Sum<object>(1, "a", It.IsAny<object>())` match element by element and compare the plain values next to them by equality. This goes beyond `params object[]`, where a matcher next to plain values still matches nothing. A matcher for the whole array next to other elements matches one element there, as for `params object[]`. Plain values keep the comparison they had. Mockolate0007 no longer reports a matcher for an element of such an array that is recognized at runtime, as it already did not for a parameter of type `T`, and still reports a matcher for the whole array next to other elements.

```csharp
sut.Only<object>(1, "a");
sut.Only("a");
sut.Mock.Verify.Only<object>(It.IsAny<object>(), "a").Once(); // failed before
sut.Mock.Verify.Only<object>(It.IsAny<object[]>()).Once(); // failed before
sut.Mock.Verify.Only(It.IsAny<string>()).Once(); // failed before
sut.Mock.Verify.Only<object>(1, "a").Once(); // as before
```

One call behaves differently for every type argument of such a method: a `null` array now matches a `null` array instead of throwing an `ArgumentNullException`, for example `Setup.Sum<string>(1, null)` or `Verify.Only<object>(null)`, as #1031 defined it for `params object[]`. A `params` array of another element type, such as `params string[]`, still throws.

This is a narrow source break, as in #1098: `.AnyParameters()` is no longer available after a matcher or a `null` for such a `params` array, or after a lone `null` or `default` or one next to such an array for another parameter (e.g. `Setup.Sum<object>(1, null).AnyParameters()` or `Setup.Sum<object>(default).AnyParameters()`), and after a `default` for a non-generic sibling with as many parameters, such as `Setup.W(1, default).AnyParameters()` for `W(int a, int b)` beside `W<T>(int a, params T[] values)`, because such a call now binds a matcher or `IParameters` overload. Use `Match.AnyParameters()` instead. A lone `default` that was ambiguous before can bind now: for `Ws<T>(int value)` beside `Ws<T>(params T[] values)`, `Setup.Ws<object>(default)` was CS0121 and now sets up a `null` array, as the call on the mock `Ws<object>(default)` is ambiguous as well.

Not covered: a matcher for an element next to plain values without the type argument `object`, such as `Sum(1, It.IsAny<string>())`, which infers `T` as the matcher type, and inferring the type argument from a matcher without `OverloadResolutionPriorityAttribute`.
vbreuss added a commit that referenced this pull request Nov 21, 2026
A matcher for a `params T[]` parameter of a generic method was captured as a value. The overload that takes values was promoted with `[OverloadResolutionPriority(int.MaxValue)]`, so for `Only<T>(params T[] args)` and `Sum<T>(int level, params T[] args)` the call `Setup.Only(It.IsAny<string>())` inferred `T` as the matcher type, and with the type argument `object`, to which every matcher converts, `Verify.Only<object>(It.IsAny<object>())`, `Only<object>(It.IsAny<object[]>())`, `Only<object>(Match.AnyParameters())` and `Sum<object>(1, It.IsAny<object>())` bound the overload that takes values and matched nothing. No call could set up or verify such a method with a matcher.

A `params` array of a type parameter now blocks that promotion, as #1098 does for a parameter of type `T`: whenever a matcher overload is applicable, it outranks the overload that takes values, and it infers the type argument from the matcher.

- A lone matcher for the array matches the whole array: `Only<object>(It.IsAny<object[]>())`.
- Matchers for the elements match element by element: `Only(It.IsAny<string>())` sets up `Only<string>`, and `Only<object>(It.IsAny<object>())` matches one element. A `null` element next to them matches a `null` element, also for a nullable type argument.
- `Match.AnyParameters()` and `Match.Parameters(…)` for a lone `params T[]` stand for the parameters.
- A lone `null` for a lone `params T[]` stands for a `null` array, and a `null` for the array next to matchers for the other parameters binds the matcher for the whole array, so it does as well: `Setup.Sum<object>(It.IsAny<int>(), null)`. Above four parameters no overload combines values with the matcher for the whole array.
- A lone `null` or `default` for a parameter before such an array forwards to the overload that takes values, as #1098 does for a parameter of type `T`, so `Setup.Sum<object>(default)` stands for `Sum<object>(0)` instead of any parameters. The same holds for a non-generic sibling with a value type parameter whose all-values overload is not promoted, such as `F(int value)` beside `F<T>(T value)`, which #1098 stopped promoting, or beside `F<T>(params T[] values)`, which this change stops promoting.
- A lone `params T[]` gets the overload without arguments that `params object[]` has, so `Setup.Only<object>().AnyParameters()` keeps working, unless a sibling with as many type parameters takes a call without arguments, such as `Only<T>(T value = default!)`, which the call on the mock binds; this also holds without `OverloadResolutionPriorityAttribute`. A lone non-generic `params` array beside such a generic sibling, such as `Pick(params string[])` beside `Pick<T>(params T[])`, gets that overload as well, so `Setup.Pick().AnyParameters()` keeps working, and a lone `null` for it forwards to the overload that takes values.

Matchers that still bind the overload that takes values, which only happens for the type argument `object`, are recognized at runtime, as #1071 does for a parameter of type `T`: `Only<object>(It.IsAny<object>(), "a")` and `Sum<object>(1, "a", It.IsAny<object>())` match element by element and compare the plain values next to them by equality. This goes beyond `params object[]`, where a matcher next to plain values still matches nothing. A matcher for the whole array next to other elements matches one element there, as for `params object[]`. Plain values keep the comparison they had. Mockolate0007 no longer reports a matcher for an element of such an array that is recognized at runtime, as it already did not for a parameter of type `T`, and still reports a matcher for the whole array next to other elements.

```csharp
sut.Only<object>(1, "a");
sut.Only("a");
sut.Mock.Verify.Only<object>(It.IsAny<object>(), "a").Once(); // failed before
sut.Mock.Verify.Only<object>(It.IsAny<object[]>()).Once(); // failed before
sut.Mock.Verify.Only(It.IsAny<string>()).Once(); // failed before
sut.Mock.Verify.Only<object>(1, "a").Once(); // as before
```

One call behaves differently for every type argument of such a method: a `null` array now matches a `null` array instead of throwing an `ArgumentNullException`, for example `Setup.Sum<string>(1, null)` or `Verify.Only<object>(null)`, as #1031 defined it for `params object[]`. A `params` array of another element type, such as `params string[]`, still throws.

This is a narrow source break, as in #1098: `.AnyParameters()` is no longer available after a matcher or a `null` for such a `params` array, or after a lone `null` or `default` or one next to such an array for another parameter (e.g. `Setup.Sum<object>(1, null).AnyParameters()` or `Setup.Sum<object>(default).AnyParameters()`), and after a `default` for a non-generic sibling with as many parameters, such as `Setup.W(1, default).AnyParameters()` for `W(int a, int b)` beside `W<T>(int a, params T[] values)`, because such a call now binds a matcher or `IParameters` overload. Use `Match.AnyParameters()` instead. A lone `default` that was ambiguous before can bind now: for `Ws<T>(int value)` beside `Ws<T>(params T[] values)`, `Setup.Ws<object>(default)` was CS0121 and now sets up a `null` array, as the call on the mock `Ws<object>(default)` is ambiguous as well.

Not covered: a matcher for an element next to plain values without the type argument `object`, such as `Sum(1, It.IsAny<string>())`, which infers `T` as the matcher type, and inferring the type argument from a matcher without `OverloadResolutionPriorityAttribute`.
vbreuss added a commit that referenced this pull request Nov 21, 2026
A matcher for a `params T[]` parameter of a generic method was captured as a value. The overload that takes values was promoted with `[OverloadResolutionPriority(int.MaxValue)]`, so for `Only<T>(params T[] args)` and `Sum<T>(int level, params T[] args)` the call `Setup.Only(It.IsAny<string>())` inferred `T` as the matcher type, and with the type argument `object`, to which every matcher converts, `Verify.Only<object>(It.IsAny<object>())`, `Only<object>(It.IsAny<object[]>())`, `Only<object>(Match.AnyParameters())` and `Sum<object>(1, It.IsAny<object>())` bound the overload that takes values and matched nothing. No call could set up or verify such a method with a matcher.

A `params` array of a type parameter now blocks that promotion, as #1098 does for a parameter of type `T`: whenever a matcher overload is applicable, it outranks the overload that takes values, and it infers the type argument from the matcher.

- A lone matcher for the array matches the whole array: `Only<object>(It.IsAny<object[]>())`.
- Matchers for the elements match element by element: `Only(It.IsAny<string>())` sets up `Only<string>`, and `Only<object>(It.IsAny<object>())` matches one element. A `null` element next to them matches a `null` element, also for a nullable type argument.
- `Match.AnyParameters()` and `Match.Parameters(…)` for a lone `params T[]` stand for the parameters.
- A lone `null` for a lone `params T[]` stands for a `null` array, and a `null` for the array next to matchers for the other parameters binds the matcher for the whole array, so it does as well: `Setup.Sum<object>(It.IsAny<int>(), null)`. Above four parameters no overload combines values with the matcher for the whole array.
- A lone `null` or `default` for a parameter before such an array forwards to the overload that takes values, as #1098 does for a parameter of type `T`, so `Setup.Sum<object>(default)` stands for `Sum<object>(0)` instead of any parameters. The same holds for a non-generic sibling with a value type parameter whose all-values overload is not promoted, such as `F(int value)` beside `F<T>(T value)`, which #1098 stopped promoting, or beside `F<T>(params T[] values)`, which this change stops promoting.
- A lone `params T[]` gets the overload without arguments that `params object[]` has, so `Setup.Only<object>().AnyParameters()` keeps working, unless a sibling with as many type parameters takes a call without arguments, such as `Only<T>(T value = default!)`, which the call on the mock binds; this also holds without `OverloadResolutionPriorityAttribute`. A lone non-generic `params` array beside such a generic sibling, such as `Pick(params string[])` beside `Pick<T>(params T[])`, gets that overload as well, so `Setup.Pick().AnyParameters()` keeps working, unless another lone `params` array with as many type parameters, such as `Pick(params int[])`, would get the same overload.

Matchers that still bind the overload that takes values, which only happens for the type argument `object`, are recognized at runtime, as #1071 does for a parameter of type `T`: `Only<object>(It.IsAny<object>(), "a")` and `Sum<object>(1, "a", It.IsAny<object>())` match element by element and compare the plain values next to them by equality. This goes beyond `params object[]`, where a matcher next to plain values still matches nothing. A matcher for the whole array next to other elements matches one element there, as for `params object[]`. Plain values keep the comparison they had. Mockolate0007 no longer reports a matcher for an element of such an array that is recognized at runtime, as it already did not for a parameter of type `T`, and still reports a matcher for the whole array next to other elements.

```csharp
sut.Only<object>(1, "a");
sut.Only("a");
sut.Mock.Verify.Only<object>(It.IsAny<object>(), "a").Once(); // failed before
sut.Mock.Verify.Only<object>(It.IsAny<object[]>()).Once(); // failed before
sut.Mock.Verify.Only(It.IsAny<string>()).Once(); // failed before
sut.Mock.Verify.Only<object>(1, "a").Once(); // as before
```

One call behaves differently for every type argument of such a method: a `null` array now matches a `null` array instead of throwing an `ArgumentNullException`, for example `Setup.Sum<string>(1, null)` or `Verify.Only<object>(null)`, as #1031 defined it for `params object[]`. A `params` array of another element type, such as `params string[]`, still throws.

This is a narrow source break, as in #1098: `.AnyParameters()` is no longer available after a matcher or a `null` for such a `params` array, or after a lone `null` or `default` or one next to such an array for another parameter (e.g. `Setup.Sum<object>(1, null).AnyParameters()` or `Setup.Sum<object>(default).AnyParameters()`), and after a `default` for a non-generic sibling with as many parameters, such as `Setup.W(1, default).AnyParameters()` for `W(int a, int b)` beside `W<T>(int a, params T[] values)`, because such a call now binds a matcher or `IParameters` overload. Use `Match.AnyParameters()` instead. A lone `default` that was ambiguous before can bind now: for `Ws<T>(int value)` beside `Ws<T>(params T[] values)`, `Setup.Ws<object>(default)` was CS0121 and now sets up a `null` array, as the call on the mock `Ws<object>(default)` is ambiguous as well.

Not covered: a matcher for an element next to plain values without the type argument `object`, such as `Sum(1, It.IsAny<string>())`, which infers `T` as the matcher type, and inferring the type argument from a matcher without `OverloadResolutionPriorityAttribute`.
vbreuss added a commit that referenced this pull request Nov 21, 2026
A matcher for a `params T[]` parameter of a generic method was captured as a value. The overload that takes values was promoted with `[OverloadResolutionPriority(int.MaxValue)]`, so for `Only<T>(params T[] args)` and `Sum<T>(int level, params T[] args)` the call `Setup.Only(It.IsAny<string>())` inferred `T` as the matcher type, and with the type argument `object`, to which every matcher converts, `Verify.Only<object>(It.IsAny<object>())`, `Only<object>(It.IsAny<object[]>())`, `Only<object>(Match.AnyParameters())` and `Sum<object>(1, It.IsAny<object>())` bound the overload that takes values and matched nothing. No call could set up or verify such a method with a matcher.

A `params` array of a type parameter now blocks that promotion, as #1098 does for a parameter of type `T`: whenever a matcher overload is applicable, it outranks the overload that takes values, and it infers the type argument from the matcher.

- A lone matcher for the array matches the whole array: `Only<object>(It.IsAny<object[]>())`.
- Matchers for the elements match element by element: `Only(It.IsAny<string>())` sets up `Only<string>`, and `Only<object>(It.IsAny<object>())` matches one element. A `null` element next to them matches a `null` element, also for a nullable type argument.
- `Match.AnyParameters()` and `Match.Parameters(…)` for a lone `params T[]` stand for the parameters.
- A lone `null` for a lone `params T[]` stands for a `null` array, and a `null` for the array next to matchers for the other parameters binds the matcher for the whole array, so it does as well: `Setup.Sum<object>(It.IsAny<int>(), null)`. Above four parameters no overload combines values with the matcher for the whole array.
- A lone `null` or `default` for a parameter before such an array forwards to the overload that takes values, as #1098 does for a parameter of type `T`, so `Setup.Sum<object>(default)` stands for `Sum<object>(0)` instead of any parameters. The same holds for a non-generic sibling with a value type parameter whose all-values overload is not promoted, such as `F(int value)` beside `F<T>(T value)`, which #1098 stopped promoting, or beside `F<T>(params T[] values)`, which this change stops promoting.
- A lone `params T[]` gets the overload without arguments that `params object[]` has, so `Setup.Only<object>().AnyParameters()` keeps working, unless a sibling with as many type parameters takes a call without arguments, such as `Only<T>(T value = default!)`, which the call on the mock binds; this also holds without `OverloadResolutionPriorityAttribute`. A lone non-generic `params` array beside such a generic sibling, such as `Pick(params string[])` beside `Pick<T>(params T[])`, gets that overload as well, so `Setup.Pick().AnyParameters()` keeps working, unless a sibling with as many type parameters takes a call without arguments or another lone `params` array with as many type parameters, such as `Pick(params int[])`, would get the same overload. A lone `null` for such a non-generic array keeps binding the `IParameters` overload, which reports CS8625 and Mockolate0006, unless the array is nullable, such as `params string?[]?`, where it forwards to the overload that takes values, as the call on the mock takes a lone `null` as well.

Matchers that still bind the overload that takes values, which only happens for the type argument `object`, are recognized at runtime, as #1071 does for a parameter of type `T`: `Only<object>(It.IsAny<object>(), "a")` and `Sum<object>(1, "a", It.IsAny<object>())` match element by element and compare the plain values next to them by equality. This goes beyond `params object[]`, where a matcher next to plain values still matches nothing. A matcher for the whole array next to other elements matches one element there, as for `params object[]`. Plain values keep the comparison they had. Mockolate0007 no longer reports a matcher for an element of such an array that is recognized at runtime, as it already did not for a parameter of type `T`, and still reports a matcher for the whole array next to other elements.

```csharp
sut.Only<object>(1, "a");
sut.Only("a");
sut.Mock.Verify.Only<object>(It.IsAny<object>(), "a").Once(); // failed before
sut.Mock.Verify.Only<object>(It.IsAny<object[]>()).Once(); // failed before
sut.Mock.Verify.Only(It.IsAny<string>()).Once(); // failed before
sut.Mock.Verify.Only<object>(1, "a").Once(); // as before
```

One call behaves differently for every type argument of such a method: a `null` array now matches a `null` array instead of throwing an `ArgumentNullException`, for example `Setup.Sum<string>(1, null)` or `Verify.Only<object>(null)`, as #1031 defined it for `params object[]`. A `params` array of another element type, such as `params string[]`, still throws.

This is a narrow source break, as in #1098: `.AnyParameters()` is no longer available after a matcher or a `null` for such a `params` array, or after a lone `null` or `default` or one next to such an array for another parameter (e.g. `Setup.Sum<object>(1, null).AnyParameters()` or `Setup.Sum<object>(default).AnyParameters()`), and after a `default` for a non-generic sibling with as many parameters, such as `Setup.W(1, default).AnyParameters()` for `W(int a, int b)` beside `W<T>(int a, params T[] values)`, because such a call now binds a matcher or `IParameters` overload. Use `Match.AnyParameters()` instead. A lone `default` that was ambiguous before can bind now: for `Ws<T>(int value)` beside `Ws<T>(params T[] values)`, `Setup.Ws<object>(default)` was CS0121 and now sets up a `null` array, as the call on the mock `Ws<object>(default)` is ambiguous as well. A lone `null` can become ambiguous, as #1098 made it for a parameter of type `T`: for `Bo(bool value)` and `Bo(int? value)` beside `Bo<T>(params T[] values)`, `Setup.Bo(null)` is CS0121 between the matcher overloads of both siblings, whose overloads that take values are no longer promoted.

Not covered: a matcher for an element next to plain values without the type argument `object`, such as `Sum(1, It.IsAny<string>())`, which infers `T` as the matcher type, and inferring the type argument from a matcher without `OverloadResolutionPriorityAttribute`.
vbreuss added a commit that referenced this pull request Nov 22, 2026
A matcher for a `params T[]` parameter of a generic method was captured as a value. The overload that takes values was promoted with `[OverloadResolutionPriority(int.MaxValue)]`, so for `Only<T>(params T[] args)` and `Sum<T>(int level, params T[] args)` the call `Setup.Only(It.IsAny<string>())` inferred `T` as the matcher type, and with the type argument `object`, to which every matcher converts, `Verify.Only<object>(It.IsAny<object>())`, `Only<object>(It.IsAny<object[]>())`, `Only<object>(Match.AnyParameters())` and `Sum<object>(1, It.IsAny<object>())` bound the overload that takes values and matched nothing. No call could set up or verify such a method with a matcher.

A `params` array of a type parameter now blocks that promotion, as #1098 does for a parameter of type `T`: whenever a matcher overload is applicable, it outranks the overload that takes values, and it infers the type argument from the matcher.

- A lone matcher for the array matches the whole array: `Only<object>(It.IsAny<object[]>())`.
- Matchers for the elements match element by element: `Only(It.IsAny<string>())` sets up `Only<string>`, and `Only<object>(It.IsAny<object>())` matches one element. A `null` element next to them matches a `null` element, also for a nullable type argument.
- `Match.AnyParameters()` and `Match.Parameters(…)` for a lone `params T[]` stand for the parameters.
- A lone `null` for a lone `params T[]` stands for a `null` array, and a `null` for the array next to matchers for the other parameters binds the matcher for the whole array, so it does as well: `Setup.Sum<object>(It.IsAny<int>(), null)`. Above four parameters no overload combines values with the matcher for the whole array.
- A lone `null` or `default` for a parameter before such an array forwards to the overload that takes values, as #1098 does for a parameter of type `T`, so `Setup.Sum<object>(default)` stands for `Sum<object>(0)` instead of any parameters. The same holds for a non-generic sibling with a value type parameter whose all-values overload is not promoted, such as `F(int value)` beside `F<T>(T value)`, which #1098 stopped promoting, or beside `F<T>(params T[] values)`, which this change stops promoting.
- A lone `params T[]` gets the overload without arguments that `params object[]` has, so `Setup.Only<object>().AnyParameters()` keeps working, unless a sibling with as many type parameters takes a call without arguments, such as `Only<T>(T value = default!)`, which the call on the mock binds; this also holds without `OverloadResolutionPriorityAttribute`. A lone non-generic `params` array beside such a generic sibling, such as `Pick(params string[])` beside `Pick<T>(params T[])`, gets that overload as well, so `Setup.Pick().AnyParameters()` keeps working, unless a sibling with as many type parameters takes a call without arguments or another lone `params` array with as many type parameters, such as `Pick(params int[])`, would get the same overload. A lone `null` for such a non-generic array keeps binding the `IParameters` overload, which reports CS8625 and Mockolate0006, unless the array is nullable, such as `params string?[]?`, where it forwards to the overload that takes values and throws an `ArgumentNullException`, as before.

Matchers that still bind the overload that takes values, which only happens for the type argument `object`, are recognized at runtime, as #1071 does for a parameter of type `T`: `Only<object>(It.IsAny<object>(), "a")` and `Sum<object>(1, "a", It.IsAny<object>())` match element by element and compare the plain values next to them by equality. This goes beyond `params object[]`, where a matcher next to plain values still matches nothing. A matcher for the whole array next to other elements matches one element there, as for `params object[]`. Plain values keep the comparison they had. Mockolate0007 no longer reports a matcher for an element of such an array that is recognized at runtime, as it already did not for a parameter of type `T`, and still reports a matcher for the whole array next to other elements.

```csharp
sut.Only<object>(1, "a");
sut.Only("a");
sut.Mock.Verify.Only<object>(It.IsAny<object>(), "a").Once(); // failed before
sut.Mock.Verify.Only<object>(It.IsAny<object[]>()).Once(); // failed before
sut.Mock.Verify.Only(It.IsAny<string>()).Once(); // failed before
sut.Mock.Verify.Only<object>(1, "a").Once(); // as before
```

One call behaves differently for every type argument of such a method: a `null` array now matches a `null` array instead of throwing an `ArgumentNullException`, for example `Setup.Sum<string>(1, null)` or `Verify.Only<object>(null)`, as #1031 defined it for `params object[]`. A `params` array of another element type, such as `params string[]`, still throws.

This is a narrow source break, as in #1098: `.AnyParameters()` is no longer available after a matcher or a `null` for such a `params` array, or after a lone `null` or `default` or one next to such an array for another parameter (e.g. `Setup.Sum<object>(1, null).AnyParameters()` or `Setup.Sum<object>(default).AnyParameters()`), and after a `default` for a non-generic sibling with as many parameters, such as `Setup.W(1, default).AnyParameters()` for `W(int a, int b)` beside `W<T>(int a, params T[] values)`, because such a call now binds a matcher or `IParameters` overload. `Setup.K().AnyParameters()` is no longer available for `K(params string[])` beside `K<T>(params T[])` and `K(string a = "")`, because `Setup.K()` now sets up `K(string a = "")`, which the call on the mock `K()` binds, instead of a method that `K()` never calls. Use `Match.AnyParameters()` instead. A lone `default` that was ambiguous before can bind now: for `Ws<T>(int value)` beside `Ws<T>(params T[] values)`, `Setup.Ws<object>(default)` was CS0121 and now sets up a `null` array, as the call on the mock `Ws<object>(default)` is ambiguous as well. A lone `null` can become ambiguous, as #1098 made it for a parameter of type `T`: for `Bo(bool value)` and `Bo(int? value)` beside `Bo<T>(params T[] values)`, `Setup.Bo(null)` is CS0121 between the matcher overloads of both siblings, whose overloads that take values are no longer promoted.

Not covered: a matcher for an element next to plain values without the type argument `object`, such as `Sum(1, It.IsAny<string>())`, which infers `T` as the matcher type, and inferring the type argument from a matcher without `OverloadResolutionPriorityAttribute`.
vbreuss added a commit that referenced this pull request Nov 22, 2026
A matcher for a `params T[]` parameter of a generic method was captured as a value. The overload that takes values was promoted with `[OverloadResolutionPriority(int.MaxValue)]`, so for `Only<T>(params T[] args)` and `Sum<T>(int level, params T[] args)` the call `Setup.Only(It.IsAny<string>())` inferred `T` as the matcher type, and with the type argument `object`, to which every matcher converts, `Verify.Only<object>(It.IsAny<object>())`, `Only<object>(It.IsAny<object[]>())`, `Only<object>(Match.AnyParameters())` and `Sum<object>(1, It.IsAny<object>())` bound the overload that takes values and matched nothing. No call could set up or verify such a method with a matcher.

A `params` array of a type parameter now blocks that promotion, as #1098 does for a parameter of type `T`: whenever a matcher overload is applicable, it outranks the overload that takes values, and it infers the type argument from the matcher.

- A lone matcher for the array matches the whole array: `Only<object>(It.IsAny<object[]>())`.
- Matchers for the elements match element by element: `Only(It.IsAny<string>())` sets up `Only<string>`, and `Only<object>(It.IsAny<object>())` matches one element. A `null` element next to them matches a `null` element, also for a nullable type argument.
- `Match.AnyParameters()` and `Match.Parameters(…)` for a lone `params T[]` stand for the parameters.
- A lone `null` for a lone `params T[]` stands for a `null` array, and a `null` for the array next to matchers for the other parameters binds the matcher for the whole array, so it does as well: `Setup.Sum<object>(It.IsAny<int>(), null)`. Above four parameters no overload combines values with the matcher for the whole array.
- A lone `null` or `default` for a parameter before such an array forwards to the overload that takes values, as #1098 does for a parameter of type `T`, so `Setup.Sum<object>(default)` stands for `Sum<object>(0)` instead of any parameters. The same holds for a non-generic sibling with a value type parameter whose all-values overload is not promoted, such as `F(int value)` beside `F<T>(T value)`, which #1098 stopped promoting, or beside `F<T>(params T[] values)`, which this change stops promoting.
- A lone `params T[]` gets the overload without arguments that `params object[]` has, so `Setup.Only<object>().AnyParameters()` keeps working, unless a sibling with as many type parameters takes a call without arguments, such as `Only<T>(T value = default!)`, which the call on the mock binds; this also holds without `OverloadResolutionPriorityAttribute`. A lone non-generic `params` array beside such a generic sibling, such as `Pick(params string[])` beside `Pick<T>(params T[])`, gets that overload as well, so `Setup.Pick().AnyParameters()` keeps working, unless a sibling with as many type parameters takes a call without arguments or another lone `params` array with as many type parameters, such as `Pick(params int[])`, would get the same overload. A lone `null` for such a non-generic array binds the `IParameters` overload, as for a lone `params T[]`, which reports CS8625 and Mockolate0006, unless the array is nullable, such as `params string?[]?`, where it forwards to the overload that takes values and throws an `ArgumentNullException`, as before.

Matchers that still bind the overload that takes values, which only happens for the type argument `object`, are recognized at runtime, as #1071 does for a parameter of type `T`: `Only<object>(It.IsAny<object>(), "a")` and `Sum<object>(1, "a", It.IsAny<object>())` match element by element and compare the plain values next to them by equality. This goes beyond `params object[]`, where a matcher next to plain values still matches nothing. A matcher for the whole array next to other elements matches one element there, as for `params object[]`. Plain values keep the comparison they had. Mockolate0007 no longer reports a matcher for an element of such an array that is recognized at runtime, as it already did not for a parameter of type `T`, and still reports a matcher for the whole array next to other elements.

```csharp
sut.Only<object>(1, "a");
sut.Only("a");
sut.Mock.Verify.Only<object>(It.IsAny<object>(), "a").Once(); // failed before
sut.Mock.Verify.Only<object>(It.IsAny<object[]>()).Once(); // failed before
sut.Mock.Verify.Only(It.IsAny<string>()).Once(); // failed before
sut.Mock.Verify.Only<object>(1, "a").Once(); // as before
```

One call behaves differently for every type argument of such a method: a `null` array now matches a `null` array instead of throwing an `ArgumentNullException`, for example `Setup.Sum<string>(1, null)` or `Verify.Only<object>(null)`, as #1031 defined it for `params object[]`. A lone `null` for a lone `params T[]` that matched any parameters, such as `Setup.Ln<object>(null)` beside `Ln<T, U>(T a = default!)`, now matches a `null` array as well. A `params` array of another element type, such as `params string[]`, still throws, unless a generic sibling stops promoting its overload that takes values: `Setup.Lk("s", null)` for `Lk(string s, params string[])` beside `Lk<T>(string s, params T[])` now matches a `null` array, and `Setup.N(null)` for `N(params string[])` beside `N<T>(params T[])` now binds the `IParameters` overload and matches any parameters instead of throwing.

This is a narrow source break, as in #1098: `.AnyParameters()` is no longer available after a matcher or a `null` for such a `params` array, or after a lone `null` or `default` or one next to such an array for another parameter (e.g. `Setup.Sum<object>(1, null).AnyParameters()` or `Setup.Sum<object>(default).AnyParameters()`), and after a `default` for a non-generic sibling with as many parameters, such as `Setup.W(1, default).AnyParameters()` for `W(int a, int b)` beside `W<T>(int a, params T[] values)`, because such a call now binds a matcher or `IParameters` overload. `Setup.K().AnyParameters()` is no longer available for `K(params string[])` beside `K<T>(params T[])` and `K(string a = "")`, because `Setup.K()` now sets up `K(string a = "")`, which the call on the mock `K()` binds, instead of a method that `K()` never calls; the same holds for a generic sibling, such as `Setup.Optional<object>().AnyParameters()` for `Optional<T>(params T[])` beside `Optional<T>(T value = default!)`. Use `Match.AnyParameters()` instead. A lone `default` that was ambiguous before can bind now: for `Ws<T>(int value)` beside `Ws<T>(params T[] values)`, `Setup.Ws<object>(default)` was CS0121 and now sets up a `null` array, as the call on the mock `Ws<object>(default)` is ambiguous as well. A lone `null` can become ambiguous, as #1098 made it for a parameter of type `T`: for `Bo(bool value)` and `Bo(int? value)` beside `Bo<T>(params T[] values)`, `Setup.Bo(null)` is CS0121 between the matcher overloads of both siblings, whose overloads that take values are no longer promoted.

Not covered: a matcher for an element next to plain values without the type argument `object`, such as `Sum(1, It.IsAny<string>())`, which infers `T` as the matcher type, and inferring the type argument from a matcher without `OverloadResolutionPriorityAttribute`.
vbreuss added a commit that referenced this pull request Nov 22, 2026
A matcher for a `params T[]` parameter of a generic method was captured as a value. The overload that takes values was promoted with `[OverloadResolutionPriority(int.MaxValue)]`, so for `Only<T>(params T[] args)` and `Sum<T>(int level, params T[] args)` the call `Setup.Only(It.IsAny<string>())` inferred `T` as the matcher type, and with the type argument `object`, to which every matcher converts, `Verify.Only<object>(It.IsAny<object>())`, `Only<object>(It.IsAny<object[]>())`, `Only<object>(Match.AnyParameters())` and `Sum<object>(1, It.IsAny<object>())` bound the overload that takes values and matched nothing. No call could set up or verify such a method with a matcher.

A `params` array of a type parameter now blocks that promotion, as #1098 does for a parameter of type `T`: whenever a matcher overload is applicable, it outranks the overload that takes values, and it infers the type argument from the matcher.

- A lone matcher for the array matches the whole array: `Only<object>(It.IsAny<object[]>())`.
- Matchers for the elements match element by element: `Only(It.IsAny<string>())` sets up `Only<string>`, and `Only<object>(It.IsAny<object>())` matches one element. A `null` element next to them matches a `null` element, also for a nullable type argument.
- `Match.AnyParameters()` and `Match.Parameters(…)` for a lone `params T[]` stand for the parameters.
- A lone `null` for a lone `params T[]` stands for a `null` array, and a `null` for the array next to matchers for the other parameters binds the matcher for the whole array, so it does as well: `Setup.Sum<object>(It.IsAny<int>(), null)`. Above four parameters no overload combines values with the matcher for the whole array.
- A lone `null` or `default` for a parameter before such an array forwards to the overload that takes values, as #1098 does for a parameter of type `T`, so `Setup.Sum<object>(default)` stands for `Sum<object>(0)` instead of any parameters. The same holds for a non-generic sibling with a value type parameter whose all-values overload is not promoted, such as `F(int value)` beside `F<T>(T value)`, which #1098 stopped promoting, or beside `F<T>(params T[] values)`, which this change stops promoting.
- A lone `params T[]` gets the overload without arguments that `params object[]` has, so `Setup.Only<object>().AnyParameters()` keeps working, unless a sibling with as many type parameters takes a call without arguments, such as `Only<T>(T value = default!)`, which the call on the mock binds; this also holds without `OverloadResolutionPriorityAttribute`. A lone non-generic `params` array beside such a generic sibling, such as `Pick(params string[])` beside `Pick<T>(params T[])`, gets that overload as well, so `Setup.Pick().AnyParameters()` keeps working, unless a sibling with as many type parameters takes a call without arguments or another lone `params` array with as many type parameters, such as `Pick(params int[])`, would get the same overload. A lone `null` for such a non-generic array binds the `IParameters` overload, as for a lone `params T[]`, which reports CS8625 and Mockolate0006, unless the array is nullable, such as `params string?[]?`, where it forwards to the overload that takes values and throws an `ArgumentNullException`, as before.

Matchers that still bind the overload that takes values, which only happens for the type argument `object`, are recognized at runtime, as #1071 does for a parameter of type `T`: `Only<object>(It.IsAny<object>(), "a")` and `Sum<object>(1, "a", It.IsAny<object>())` match element by element and compare the plain values next to them by equality. This goes beyond `params object[]`, where a matcher next to plain values still matches nothing. A matcher for the whole array next to other elements matches one element there, as for `params object[]`. Plain values keep the comparison they had. Mockolate0007 no longer reports a matcher for an element of such an array that is recognized at runtime, as it already did not for a parameter of type `T`, and still reports a matcher for the whole array next to other elements.

```csharp
sut.Only<object>(1, "a");
sut.Only("a");
sut.Mock.Verify.Only<object>(It.IsAny<object>(), "a").Once(); // failed before
sut.Mock.Verify.Only<object>(It.IsAny<object[]>()).Once(); // failed before
sut.Mock.Verify.Only(It.IsAny<string>()).Once(); // failed before
sut.Mock.Verify.Only<object>(1, "a").Once(); // as before
```

One call behaves differently for every type argument of such a method: a `null` array now matches a `null` array instead of throwing an `ArgumentNullException`, for example `Setup.Sum<string>(1, null)` or `Verify.Only<object>(null)`, as #1031 defined it for `params object[]`. A lone `null` for a lone `params T[]` that matched any parameters, such as `Setup.Ln<object>(null)` beside `Ln<T, U>(T a = default!)`, now matches a `null` array as well. A `params` array of another element type, such as `params string[]`, still throws, unless a generic sibling stops promoting its overload that takes values: `Setup.Lk("s", null)` for `Lk(string s, params string[])` beside `Lk<T>(string s, params T[])` now matches a `null` array, and `Setup.N(null)` for `N(params string[])` beside `N<T>(params T[])` now binds the `IParameters` overload and matches any parameters instead of throwing.

This is a narrow source break, as in #1098: `.AnyParameters()` is no longer available after a matcher or a `null` for such a `params` array, or after a lone `null` or `default` or one next to such an array for another parameter (e.g. `Setup.Sum<object>(1, null).AnyParameters()` or `Setup.Sum<object>(default).AnyParameters()`), and after a `default` for a non-generic sibling with as many parameters, such as `Setup.W(1, default).AnyParameters()` for `W(int a, int b)` beside `W<T>(int a, params T[] values)`, because such a call now binds a matcher or `IParameters` overload. `Setup.K().AnyParameters()` is no longer available for `K(params string[])` beside `K<T>(params T[])` and `K(string a = "")`, because `Setup.K()` now sets up `K(string a = "")`, which the call on the mock `K()` binds, instead of a method that `K()` never calls; the same holds for a generic sibling, such as `Setup.Optional<object>().AnyParameters()` for `Optional<T>(params T[])` beside `Optional<T>(T value = default!)`. Use `Match.AnyParameters()` instead. A lone `default` that was ambiguous before can bind now: for `Ws<T>(int value)` beside `Ws<T>(params T[] values)`, `Setup.Ws<object>(default)` was CS0121 and now sets up a `null` array, as the call on the mock `Ws<object>(default)` is ambiguous as well. A lone `null` for such an array stays or becomes CS0121 beside a generic sibling with as many parameters whose last one takes a `null` as well, such as `Gm<T>(params T[][])`, `Pc<T>(params string[])` or `Pe<T>(IEnumerable<T>)`, where it did not work on main either; a sibling that takes an array of `T[]`, such as `Pn<T>(T[][])`, keeps taking it, as the call on the mock does. A lone `null` can also become ambiguous, as #1098 made it for a parameter of type `T`: for `Bo(bool value)` and `Bo(int? value)` beside `Bo<T>(params T[] values)`, `Setup.Bo(null)` is CS0121 between the matcher overloads of both siblings, whose overloads that take values are no longer promoted.

Not covered: a matcher for an element next to plain values without the type argument `object`, such as `Sum(1, It.IsAny<string>())`, which infers `T` as the matcher type, and inferring the type argument from a matcher without `OverloadResolutionPriorityAttribute`.
vbreuss added a commit that referenced this pull request Nov 22, 2026
A matcher for a `params T[]` parameter of a generic method was captured as a value. The overload that takes values was promoted with `[OverloadResolutionPriority(int.MaxValue)]`, so for `Only<T>(params T[] args)` and `Sum<T>(int level, params T[] args)` the call `Setup.Only(It.IsAny<string>())` inferred `T` as the matcher type, and with the type argument `object`, to which every matcher converts, `Verify.Only<object>(It.IsAny<object>())`, `Only<object>(It.IsAny<object[]>())`, `Only<object>(Match.AnyParameters())` and `Sum<object>(1, It.IsAny<object>())` bound the overload that takes values and matched nothing. No call could set up or verify such a method with a matcher.

A `params` array of a type parameter now blocks that promotion, as #1098 does for a parameter of type `T`: whenever a matcher overload is applicable, it outranks the overload that takes values, and it infers the type argument from the matcher.

- A lone matcher for the array matches the whole array: `Only<object>(It.IsAny<object[]>())`.
- Matchers for the elements match element by element: `Only(It.IsAny<string>())` sets up `Only<string>`, and `Only<object>(It.IsAny<object>())` matches one element. A `null` element next to them matches a `null` element, also for a nullable type argument.
- `Match.AnyParameters()` and `Match.Parameters(…)` for a lone `params T[]` stand for the parameters.
- A lone `null` for a lone `params T[]` stands for a `null` array, and a `null` for the array next to matchers for the other parameters binds the matcher for the whole array, so it does as well: `Setup.Sum<object>(It.IsAny<int>(), null)`. Above four parameters no overload combines values with the matcher for the whole array.
- A lone `null` or `default` for a parameter before such an array forwards to the overload that takes values, as #1098 does for a parameter of type `T`, so `Setup.Sum<object>(default)` stands for `Sum<object>(0)` instead of any parameters. The same holds for a non-generic sibling with a value type parameter whose all-values overload is not promoted, such as `F(int value)` beside `F<T>(T value)`, which #1098 stopped promoting, or beside `F<T>(params T[] values)`, which this change stops promoting.
- A lone `params T[]` gets the overload without arguments that `params object[]` has, so `Setup.Only<object>().AnyParameters()` keeps working, unless a sibling with as many type parameters takes a call without arguments, such as `Only<T>(T value = default!)`, which the call on the mock binds; this also holds without `OverloadResolutionPriorityAttribute`. A lone non-generic `params` array beside such a generic sibling, such as `Pick(params string[])` beside `Pick<T>(params T[])`, gets that overload as well, so `Setup.Pick().AnyParameters()` keeps working, unless a sibling with as many type parameters takes a call without arguments or another lone `params` array with as many type parameters, such as `Pick(params int[])`, would get the same overload. A lone `null` for such a non-generic array binds the `IParameters` overload, as for a lone `params T[]`, which reports CS8625 and Mockolate0006, unless the array is nullable, such as `params string?[]?`, where it forwards to the overload that takes values and throws an `ArgumentNullException`, as before.

Matchers that still bind the overload that takes values, which only happens for the type argument `object`, are recognized at runtime, as #1071 does for a parameter of type `T`: `Only<object>(It.IsAny<object>(), "a")` and `Sum<object>(1, "a", It.IsAny<object>())` match element by element and compare the plain values next to them by equality. This goes beyond `params object[]`, where a matcher next to plain values still matches nothing. A matcher for the whole array next to other elements matches one element there, as for `params object[]`. Plain values keep the comparison they had. Mockolate0007 no longer reports a matcher for an element of such an array that is recognized at runtime, as it already did not for a parameter of type `T`, and still reports a matcher for the whole array next to other elements.

```csharp
sut.Only<object>(1, "a");
sut.Only("a");
sut.Mock.Verify.Only<object>(It.IsAny<object>(), "a").Once(); // failed before
sut.Mock.Verify.Only<object>(It.IsAny<object[]>()).Once(); // failed before
sut.Mock.Verify.Only(It.IsAny<string>()).Once(); // failed before
sut.Mock.Verify.Only<object>(1, "a").Once(); // as before
```

One call behaves differently for every type argument of such a method: a `null` array now matches a `null` array instead of throwing an `ArgumentNullException`, for example `Setup.Sum<string>(1, null)` or `Verify.Only<object>(null)`, as #1031 defined it for `params object[]`. A lone `null` for a lone `params T[]` that matched any parameters, such as `Setup.Ln<object>(null)` beside `Ln<T, U>(T a = default!)`, now matches a `null` array as well. A `params` array of another element type, such as `params string[]`, still throws, unless a generic sibling stops promoting its overload that takes values: `Setup.Lk("s", null)` for `Lk(string s, params string[])` beside `Lk<T>(string s, params T[])` now matches a `null` array, and `Setup.N(null)` for `N(params string[])` beside `N<T>(params T[])` now binds the `IParameters` overload and matches any parameters instead of throwing.

This is a narrow source break, as in #1098: `.AnyParameters()` is no longer available after a matcher or a `null` for such a `params` array, or after a lone `null` or `default` or one next to such an array for another parameter (e.g. `Setup.Sum<object>(1, null).AnyParameters()` or `Setup.Sum<object>(default).AnyParameters()`), and after a `default` for a non-generic sibling with as many parameters, such as `Setup.W(1, default).AnyParameters()` for `W(int a, int b)` beside `W<T>(int a, params T[] values)`, because such a call now binds a matcher or `IParameters` overload. `Setup.K().AnyParameters()` is no longer available for `K(params string[])` beside `K<T>(params T[])` and `K(string a = "")`, because `Setup.K()` now sets up `K(string a = "")`, which the call on the mock `K()` binds, instead of a method that `K()` never calls; the same holds for a generic sibling, such as `Setup.Optional<object>().AnyParameters()` for `Optional<T>(params T[])` beside `Optional<T>(T value = default!)`. Use `Match.AnyParameters()` instead. A lone `default` that was ambiguous before can bind now: for `Ws<T>(int value)` beside `Ws<T>(params T[] values)`, `Setup.Ws<object>(default)` was CS0121 and now sets up a `null` array, as the call on the mock `Ws<object>(default)` is ambiguous as well. A lone `null` for such an array stays or becomes CS0121 beside a generic sibling with as many parameters that takes a `params` array or another reference type in that place, such as `Gm<T>(params T[][])`, `Pc<T>(params string[])` or `Pe<T>(IEnumerable<T>)`, where it did not work on main either or the call on the mock is ambiguous as well; a sibling that takes an array there, such as `Pn<T>(T[][])` or `Za<T>(string[])`, keeps taking it, as the call on the mock does. A lone `null` can also become ambiguous, as #1098 made it for a parameter of type `T`: for `Bo(bool value)` and `Bo(int? value)` beside `Bo<T>(params T[] values)`, `Setup.Bo(null)` is CS0121 between the matcher overloads of both siblings, whose overloads that take values are no longer promoted.

Not covered: a matcher for an element next to plain values without the type argument `object`, such as `Sum(1, It.IsAny<string>())`, which infers `T` as the matcher type, and inferring the type argument from a matcher without `OverloadResolutionPriorityAttribute`.
vbreuss added a commit that referenced this pull request Nov 22, 2026
A matcher for a `params T[]` parameter of a generic method was captured as a value. The overload that takes values was promoted with `[OverloadResolutionPriority(int.MaxValue)]`, so for `Only<T>(params T[] args)` and `Sum<T>(int level, params T[] args)` the call `Setup.Only(It.IsAny<string>())` inferred `T` as the matcher type, and with the type argument `object`, to which every matcher converts, `Verify.Only<object>(It.IsAny<object>())`, `Only<object>(It.IsAny<object[]>())`, `Only<object>(Match.AnyParameters())` and `Sum<object>(1, It.IsAny<object>())` bound the overload that takes values and matched nothing. No call could set up or verify such a method with a matcher.

A `params` array of a type parameter now blocks that promotion, as #1098 does for a parameter of type `T`: whenever a matcher overload is applicable, it outranks the overload that takes values, and it infers the type argument from the matcher.

- A lone matcher for the array matches the whole array: `Only<object>(It.IsAny<object[]>())`.
- Matchers for the elements match element by element: `Only(It.IsAny<string>())` sets up `Only<string>`, and `Only<object>(It.IsAny<object>())` matches one element. A `null` element next to them matches a `null` element, also for a nullable type argument.
- `Match.AnyParameters()` and `Match.Parameters(…)` for a lone `params T[]` stand for the parameters.
- A lone `null` for a lone `params T[]` stands for a `null` array, and a `null` for the array next to matchers for the other parameters binds the matcher for the whole array, so it does as well: `Setup.Sum<object>(It.IsAny<int>(), null)`, unless a sibling with as many parameters may take a `null` in that place. Above four parameters no overload combines values with the matcher for the whole array.
- A lone `null` or `default` for a parameter before such an array forwards to the overload that takes values, as #1098 does for a parameter of type `T`, so `Setup.Sum<object>(default)` stands for `Sum<object>(0)` instead of any parameters. The same holds for a non-generic sibling with a value type parameter whose all-values overload is not promoted, such as `F(int value)` beside `F<T>(T value)`, which #1098 stopped promoting, or beside `F<T>(params T[] values)`, which this change stops promoting.
- A lone `params T[]` gets the overload without arguments that `params object[]` has, so `Setup.Only<object>().AnyParameters()` keeps working, unless a sibling with as many type parameters takes a call without arguments, such as `Only<T>(T value = default!)`, which the call on the mock binds; this also holds without `OverloadResolutionPriorityAttribute`. A lone non-generic `params` array beside such a generic sibling, such as `Pick(params string[])` beside `Pick<T>(params T[])`, gets that overload as well, so `Setup.Pick().AnyParameters()` keeps working, unless a sibling with as many type parameters takes a call without arguments or another lone `params` array with as many type parameters, such as `Pick(params int[])`, would get the same overload. A lone `null` for such a non-generic array binds the `IParameters` overload, as for a lone `params T[]`, which reports CS8625 and Mockolate0006, unless the array is nullable, such as `params string?[]?`, where it forwards to the overload that takes values and throws an `ArgumentNullException`, as before.

Matchers that still bind the overload that takes values, which only happens for the type argument `object`, are recognized at runtime, as #1071 does for a parameter of type `T`: `Only<object>(It.IsAny<object>(), "a")` and `Sum<object>(1, "a", It.IsAny<object>())` match element by element and compare the plain values next to them by equality. This goes beyond `params object[]`, where a matcher next to plain values still matches nothing. A matcher for the whole array next to other elements matches one element there, as for `params object[]`. Plain values keep the comparison they had. Mockolate0007 no longer reports a matcher for an element of such an array that is recognized at runtime, as it already did not for a parameter of type `T`, and still reports a matcher for the whole array next to other elements.

```csharp
sut.Only<object>(1, "a");
sut.Only("a");
sut.Mock.Verify.Only<object>(It.IsAny<object>(), "a").Once(); // failed before
sut.Mock.Verify.Only<object>(It.IsAny<object[]>()).Once(); // failed before
sut.Mock.Verify.Only(It.IsAny<string>()).Once(); // failed before
sut.Mock.Verify.Only<object>(1, "a").Once(); // as before
```

One call behaves differently for every type argument of such a method: a `null` array now matches a `null` array instead of throwing an `ArgumentNullException`, for example `Setup.Sum<string>(1, null)` or `Verify.Only<object>(null)`, as #1031 defined it for `params object[]`. A lone `null` for a lone `params T[]` that matched any parameters, such as `Setup.Ln<object>(null)` beside `Ln<T, U>(T a = default!)`, now matches a `null` array as well. A `params` array of another element type, such as `params string[]`, still throws, unless a generic sibling stops promoting its overload that takes values: `Setup.Lk("s", null)` for `Lk(string s, params string[])` beside `Lk<T>(string s, params T[])` now matches a `null` array, and `Setup.N(null)` for `N(params string[])` beside `N<T>(params T[])` now binds the `IParameters` overload and matches any parameters instead of throwing.

This is a narrow source break, as in #1098: `.AnyParameters()` is no longer available after a matcher or a `null` for such a `params` array, or after a lone `null` or `default` or one next to such an array for another parameter (e.g. `Setup.Sum<object>(1, null).AnyParameters()` or `Setup.Sum<object>(default).AnyParameters()`), and after a `default` for a non-generic sibling with as many parameters, such as `Setup.W(1, default).AnyParameters()` for `W(int a, int b)` beside `W<T>(int a, params T[] values)`, because such a call now binds a matcher or `IParameters` overload. `Setup.K().AnyParameters()` is no longer available for `K(params string[])` beside `K<T>(params T[])` and `K(string a = "")`, because `Setup.K()` now sets up `K(string a = "")`, which the call on the mock `K()` binds, instead of a method that `K()` never calls; the same holds for a generic sibling, such as `Setup.Optional<object>().AnyParameters()` for `Optional<T>(params T[])` beside `Optional<T>(T value = default!)`. Use `Match.AnyParameters()` instead. A lone `default` that was ambiguous before can bind now: for `Ws<T>(int value)` beside `Ws<T>(params T[] values)`, `Setup.Ws<object>(default)` was CS0121 and now sets up a `null` array, as the call on the mock `Ws<object>(default)` is ambiguous as well. A `null` for such an array stays or becomes CS0121 beside a sibling with as many parameters that may take a `null` in that place, instead of binding a method that the call on the mock may not bind. It did not work on main beside `Gm<T>(params T[][])`, `Pc<T>(params string[])` or `Pe<T>(IEnumerable<T>)` either, but on main `Setup.Za<object>(null)` for `Za<T>(string[] a)` beside `Za<T>(params T[] args)` and `Setup.Ya<object>(null, null)` for `Ya<T>(string x, string y)` beside `Ya<T>(int level, params T[] args)` set up the sibling, and `.AnyParameters()` was available after them. Only a sibling that takes an array of `T[]` there, such as `Pn<T>(T[][])`, keeps taking a `null`, as the call on the mock does. A lone `null` can also become ambiguous, as #1098 made it for a parameter of type `T`: for `Bo(bool value)` and `Bo(int? value)` beside `Bo<T>(params T[] values)`, `Setup.Bo(null)` is CS0121 between the matcher overloads of both siblings, whose overloads that take values are no longer promoted.

Not covered: a matcher for an element next to plain values without the type argument `object`, such as `Sum(1, It.IsAny<string>())`, which infers `T` as the matcher type, and inferring the type argument from a matcher without `OverloadResolutionPriorityAttribute`.
vbreuss added a commit that referenced this pull request Nov 22, 2026
A matcher for a `params T[]` parameter of a generic method was captured as a value. The overload that takes values was promoted with `[OverloadResolutionPriority(int.MaxValue)]`, so for `Only<T>(params T[] args)` and `Sum<T>(int level, params T[] args)` the call `Setup.Only(It.IsAny<string>())` inferred `T` as the matcher type, and with the type argument `object`, to which every matcher converts, `Verify.Only<object>(It.IsAny<object>())`, `Only<object>(It.IsAny<object[]>())`, `Only<object>(Match.AnyParameters())` and `Sum<object>(1, It.IsAny<object>())` bound the overload that takes values and matched nothing. No call could set up or verify such a method with a matcher.

For a method without overloads, a `params` array of a type parameter now blocks that promotion, as #1098 does for a parameter of type `T`: whenever a matcher overload is applicable, it outranks the overload that takes values, and it infers the type argument from the matcher. A method with overloads keeps the promotion and binds as before, because each same-named overload competes with an unpromoted overload in ways that the call on the mock does not, and would capture calls such as `Setup.Add(1, 2)` for `Add(double a, double b)` beside `Add<T>(params T[] values)`, which the call on the mock `Add(1, 2)` binds to `Add<int>`.

- A lone matcher for the array matches the whole array: `Only<object>(It.IsAny<object[]>())`.
- Matchers for the elements match element by element: `Only(It.IsAny<string>())` sets up `Only<string>`, and `Only<object>(It.IsAny<object>())` matches one element. A `null` element next to them matches a `null` element, also for a nullable type argument.
- `Match.AnyParameters()` and `Match.Parameters(…)` for a lone `params T[]` stand for the parameters.
- A lone `null` for a lone `params T[]` stands for a `null` array, and a `null` for the array next to matchers for the other parameters binds the matcher for the whole array, so it does as well: `Setup.Sum<object>(It.IsAny<int>(), null)`. Above four parameters no overload combines values with the matcher for the whole array.
- A lone `null` or `default` for a parameter before such an array forwards to the overload that takes values, as #1098 does for a parameter of type `T`, so `Setup.Sum<object>(default)` stands for `Sum<object>(0)` instead of any parameters.
- A lone `params T[]` gets the overload without arguments that `params object[]` has, so `Setup.Only<object>().AnyParameters()` keeps working.

Matchers that still bind the overload that takes values, which only happens for the type argument `object`, also on a method with overloads, are recognized at runtime, as #1071 does for a parameter of type `T`: `Only<object>(It.IsAny<object>(), "a")`, `Sum<object>(1, "a", It.IsAny<object>())` and `Add<object>("a", It.IsAny<object>())` match element by element and compare the plain values next to them by equality. This goes beyond `params object[]`, where a matcher next to plain values still matches nothing. A matcher for the whole array next to other elements matches one element there, as for `params object[]`. Plain values keep the comparison they had. Mockolate0007 no longer reports a matcher for an element of such an array that is recognized at runtime, as it already did not for a parameter of type `T`, and still reports a matcher for the whole array next to other elements.

```csharp
sut.Only<object>(1, "a");
sut.Only("a");
sut.Mock.Verify.Only<object>(It.IsAny<object>(), "a").Once(); // failed before
sut.Mock.Verify.Only<object>(It.IsAny<object[]>()).Once(); // failed before
sut.Mock.Verify.Only(It.IsAny<string>()).Once(); // failed before
sut.Mock.Verify.Only<object>(1, "a").Once(); // as before
```

One call behaves differently for every type argument of such a method without overloads: a `null` array now matches a `null` array instead of throwing an `ArgumentNullException`, for example `Setup.Sum<string>(1, null)` or `Verify.Only<object>(null)`, as #1031 defined it for `params object[]`.

This is a narrow source break for a method without overloads, as in #1098: `.AnyParameters()` is no longer available after a matcher or a `null` for such a `params` array, or after a lone `null` or `default` or one next to such an array for another parameter (e.g. `Setup.Sum<object>(1, null).AnyParameters()` or `Setup.Sum<object>(default).AnyParameters()`), because such a call now binds a matcher or `IParameters` overload. Use `Match.AnyParameters()` instead.

Not covered: a matcher for an element next to plain values without the type argument `object`, such as `Sum(1, It.IsAny<string>())`, which infers `T` as the matcher type; a method with overloads, where matchers without a type argument still infer `T` as the matcher type, as in `Setup.Add(It.IsAny<int>(), It.IsAny<int>())`, and need it, as in `Setup.Add<int>(It.IsAny<int>(), It.IsAny<int>())`; and inferring the type argument from a matcher without `OverloadResolutionPriorityAttribute`.
vbreuss added a commit that referenced this pull request Nov 22, 2026
A matcher for a `params T[]` parameter of a generic method was captured as a value. The overload that takes values was promoted with `[OverloadResolutionPriority(int.MaxValue)]`, so for `Only<T>(params T[] args)` and `Sum<T>(int level, params T[] args)` the call `Setup.Only(It.IsAny<string>())` inferred `T` as the matcher type, and with the type argument `object`, to which every matcher converts, `Verify.Only<object>(It.IsAny<object>())`, `Only<object>(It.IsAny<object[]>())`, `Only<object>(Match.AnyParameters())` and `Sum<object>(1, It.IsAny<object>())` bound the overload that takes values and matched nothing. Only calls with a matcher for every parameter worked.

For a method without overloads or optional parameters, a `params` array of a type parameter now blocks that promotion, as #1098 does for a parameter of type `T`: whenever a matcher overload is applicable, it outranks the overload that takes values, and it infers the type argument from the matcher. A method with overloads keeps the promotion and binds as before, because each same-named overload competes with an unpromoted overload in ways that the call on the mock does not, and would capture calls such as `Setup.Add(1, 2)` for `Add(double a, double b)` beside `Add<T>(params T[] values)`, which the call on the mock `Add(1, 2)` binds to `Add<int>`. An optional parameter before the array keeps it as well, because an overload for matchers takes a `null` for it as its declared default value, so `Setup.Opt<object>(1, null)` for `Opt<T>(int a, string? s = "x", params T[] args)` would set up `s = "x"` instead of `s = null`.

- A lone matcher for the array matches the whole array: `Only<object>(It.IsAny<object[]>())`.
- Matchers for the elements match element by element: `Only(It.IsAny<string>())` sets up `Only<string>`, and `Only<object>(It.IsAny<object>())` matches one element. A `null` element next to them matches a `null` element, also for a nullable type argument.
- `Match.AnyParameters()` and `Match.Parameters(…)` for a lone `params T[]` stand for the parameters.
- A lone `null` for a lone `params T[]` stands for a `null` array, and a `null` for the array next to matchers for the other parameters binds the matcher for the whole array, so it does as well: `Setup.Sum<object>(It.IsAny<int>(), null)`. Above four parameters no overload combines values with the matcher for the whole array.
- A lone `null` or `default` for a parameter before such an array forwards to the overload that takes values, as #1098 does for a parameter of type `T`, so `Setup.Sum<object>(default)` stands for `Sum<object>(0)` instead of any parameters.
- A lone `params T[]` gets the overload without arguments that `params object[]` has, so `Setup.Only<object>().AnyParameters()` keeps working.

Matchers that still bind the overload that takes values, which only happens for the type argument `object`, also on a method with overloads, are recognized at runtime, as #1071 does for a parameter of type `T`: `Only<object>(It.IsAny<object>(), "a")`, `Sum<object>(1, "a", It.IsAny<object>())` and `Add<object>("a", It.IsAny<object>())` match element by element and compare the plain values next to them by equality. This goes beyond `params object[]`, where a matcher next to plain values still matches nothing. A matcher for the whole array next to other elements matches one element there, as for `params object[]`. Plain values keep the comparison they had. Mockolate0007 no longer reports a matcher for an element of such an array that is recognized at runtime, as it already did not for a parameter of type `T`, and still reports a matcher for the whole array next to other elements, now saying that it only matches the array as its only element.

```csharp
sut.Only<object>(1, "a");
sut.Only("a");
sut.Mock.Verify.Only<object>(It.IsAny<object>(), "a").Once(); // failed before
sut.Mock.Verify.Only<object>(It.IsAny<object[]>()).Once(); // failed before
sut.Mock.Verify.Only(It.IsAny<string>()).Once(); // failed before
sut.Mock.Verify.Only<object>(1, "a").Once(); // as before
```

Two kinds of calls behave differently. A `null` array now matches a `null` array instead of throwing an `ArgumentNullException`, as #1031 defined it for `params object[]`, for every type argument, for example `Setup.Sum<string>(1, null)` or `Verify.Only<object>(null)`, and also on a method with overloads or optional parameters, where the call binds the overload that takes values as before, such as `Setup.Add<string>(null!)`. A `null` element for a value type now stands for its default value, as a `null` does for a value type parameter, so `Setup.Sum<int>(default, default, default)` and `Verify.Only<int>(It.IsAny<int>(), default)` match zeros instead of nothing; this holds for every per-element overload of a `params` array of a value type.

This is a narrow source break for a method without overloads or optional parameters, as in #1098: `.AnyParameters()` is no longer available after a matcher or a `null` for such a `params` array, or after a lone `null` or `default` or one next to such an array for another parameter (e.g. `Setup.Sum<object>(1, null).AnyParameters()` or `Setup.Sum<object>(default).AnyParameters()`), because such a call now binds a matcher or `IParameters` overload. Use `Match.AnyParameters()` instead.

Not covered: a matcher for an element next to plain values without the type argument `object`, such as `Sum(1, It.IsAny<string>())`, which infers `T` as the matcher type; a method with overloads, where matchers without a type argument still infer `T` as the matcher type, as in `Setup.Add(It.IsAny<int>(), It.IsAny<int>())`, and need it, as in `Setup.Add<int>(It.IsAny<int>(), It.IsAny<int>())`; and inferring the type argument from a matcher without `OverloadResolutionPriorityAttribute`.
vbreuss added a commit that referenced this pull request Nov 22, 2026
A matcher for a `params T[]` parameter of a generic method was captured as a value. The overload that takes values was promoted with `[OverloadResolutionPriority(int.MaxValue)]`, so for `Only<T>(params T[] args)` and `Sum<T>(int level, params T[] args)` the call `Setup.Only(It.IsAny<string>())` inferred `T` as the matcher type, and with the type argument `object`, to which every matcher converts, `Verify.Only<object>(It.IsAny<object>())`, `Only<object>(It.IsAny<object[]>())`, `Only<object>(Match.AnyParameters())` and `Sum<object>(1, It.IsAny<object>())` bound the overload that takes values and matched nothing. Only calls with a matcher for every parameter worked.

For a method without overloads or optional parameters, a `params` array of a type parameter now blocks that promotion, as #1098 does for a parameter of type `T`: whenever a matcher overload is applicable, it outranks the overload that takes values, and it infers the type argument from the matcher. A method with overloads keeps the promotion and binds as before, because each same-named overload competes with an unpromoted overload in ways that the call on the mock does not, and would capture calls such as `Setup.Add(1, 2)` for `Add(double a, double b)` beside `Add<T>(params T[] values)`, which the call on the mock `Add(1, 2)` binds to `Add<int>`. An optional parameter before the array keeps it as well, because an overload for matchers takes a `null` for it as its declared default value, so `Setup.Opt<object>(1, null)` for `Opt<T>(int a, string? s = "x", params T[] args)` would set up `s = "x"` instead of `s = null`.

- A lone matcher for the array matches the whole array: `Only<object>(It.IsAny<object[]>())`.
- Matchers for the elements match element by element: `Only(It.IsAny<string>())` sets up `Only<string>`, and `Only<object>(It.IsAny<object>())` matches one element. A `null` element next to them matches a `null` element, also for a nullable type argument.
- `Match.AnyParameters()` and `Match.Parameters(…)` for a lone `params T[]` stand for the parameters.
- A lone `null` for a lone `params T[]` stands for a `null` array, and a `null` for the array next to matchers for the other parameters binds the matcher for the whole array, so it does as well: `Setup.Sum<object>(It.IsAny<int>(), null)`. Above four parameters no overload combines values with the matcher for the whole array.
- A lone `null` or `default` for a parameter before such an array forwards to the overload that takes values, as #1098 does for a parameter of type `T`, so `Setup.Sum<object>(default)` stands for `Sum<object>(0)` instead of any parameters.
- A lone `params T[]` gets the overload without arguments that `params object[]` has, so `Setup.Only<object>().AnyParameters()` keeps working.

Matchers that still bind the overload that takes values, which only happens for the type argument `object`, also on a method with overloads, are recognized at runtime, as #1071 does for a parameter of type `T`: `Only<object>(It.IsAny<object>(), "a")`, `Sum<object>(1, "a", It.IsAny<object>())` and `Add<object>("a", It.IsAny<object>())` match element by element and compare the plain values next to them by equality. This goes beyond `params object[]`, where a matcher next to plain values still matches nothing. A matcher for the whole array next to other elements matches one element there, as for `params object[]`. Plain values keep the comparison they had. Mockolate0007 no longer reports a matcher for an element of such an array that is recognized at runtime, as it already did not for a parameter of type `T`, and still reports a matcher for the whole array next to other elements, now saying that it only matches the array as its only element.

```csharp
sut.Only<object>(1, "a");
sut.Only("a");
sut.Mock.Verify.Only<object>(It.IsAny<object>(), "a").Once(); // failed before
sut.Mock.Verify.Only<object>(It.IsAny<object[]>()).Once(); // failed before
sut.Mock.Verify.Only(It.IsAny<string>()).Once(); // failed before
sut.Mock.Verify.Only<object>(1, "a").Once(); // as before
```

Two kinds of calls behave differently. A `null` array now matches a `null` array instead of throwing an `ArgumentNullException`, as #1031 defined it for `params object[]`, for every type argument, for example `Setup.Sum<string>(1, null)` or `Verify.Only<object>(null)`, and also on a method with overloads or optional parameters, where the call binds the overload that takes values as before, such as `Setup.Add<string>(null!)`. A `null` element for a value type now stands for its default value, as a `null` does for a value type parameter, so `Setup.Sum<int>(default, default, default)` and `Verify.Only<int>(It.IsAny<int>(), default)` match zeros instead of nothing; this holds for every per-element overload of a `params` array of a value type.

This is a narrow source break for a method without overloads or optional parameters, as in #1098: `.AnyParameters()` is no longer available after a matcher or a `null` for such a `params` array, or after a lone `null` or `default` or one next to such an array for another parameter (e.g. `Setup.Sum<object>(1, null).AnyParameters()` or `Setup.Sum<object>(default).AnyParameters()`), because such a call now binds a matcher or `IParameters` overload. Use `Match.AnyParameters()` instead.

Not covered: a matcher for an element next to plain values without the type argument `object`, such as `Sum(1, It.IsAny<string>())`, which infers `T` as the matcher type; a method with overloads, where matchers without a type argument still infer `T` as the matcher type, as in `Setup.Add(It.IsAny<int>(), It.IsAny<int>())`, and need it, as in `Setup.Add<int>(It.IsAny<int>(), It.IsAny<int>())`; and inferring the type argument from a matcher without `OverloadResolutionPriorityAttribute`.
vbreuss added a commit that referenced this pull request Nov 22, 2026
A matcher for a `params T[]` parameter of a generic method was captured as a value. The overload that takes values was promoted with `[OverloadResolutionPriority(int.MaxValue)]`, so for `Only<T>(params T[] args)` and `Sum<T>(int level, params T[] args)` the call `Setup.Only(It.IsAny<string>())` inferred `T` as the matcher type, and with the type argument `object`, to which every matcher converts, `Verify.Only<object>(It.IsAny<object>())`, `Only<object>(It.IsAny<object[]>())`, `Only<object>(Match.AnyParameters())` and `Sum<object>(1, It.IsAny<object>())` bound the overload that takes values and matched nothing. No call could set up or verify such a method with a matcher.

A `params` array of a type parameter now blocks that promotion, as #1098 does for a parameter of type `T`: whenever a matcher overload is applicable, it outranks the overload that takes values, and it infers the type argument from the matcher.

- A lone matcher for the array matches the whole array: `Only<object>(It.IsAny<object[]>())`.
- Matchers for the elements match element by element: `Only(It.IsAny<string>())` sets up `Only<string>`, and `Only<object>(It.IsAny<object>())` matches one element. A `null` element next to them matches a `null` element, also for a nullable type argument.
- `Match.AnyParameters()` and `Match.Parameters(…)` for a lone `params T[]` stand for the parameters.
- A lone `null` for a lone `params T[]` stands for a `null` array, and a `null` for the array next to matchers for the other parameters binds the matcher for the whole array, so it does as well: `Setup.Sum<object>(It.IsAny<int>(), null)`. Above four parameters no overload combines values with the matcher for the whole array.
- A lone `null` or `default` for a parameter before such an array forwards to the overload that takes values, as #1098 does for a parameter of type `T`, so `Setup.Sum<object>(default)` stands for `Sum<object>(0)` instead of any parameters. The same holds for a non-generic sibling with a value type parameter whose all-values overload is not promoted, such as `F(int value)` beside `F<T>(T value)`, which #1098 stopped promoting, or beside `F<T>(params T[] values)`, which this change stops promoting.
- A lone `params T[]` gets the overload without arguments that `params object[]` has, so `Setup.Only<object>().AnyParameters()` keeps working, unless a sibling with as many type parameters takes a call without arguments, such as `Only<T>(T value = default!)`, which the call on the mock binds; this also holds without `OverloadResolutionPriorityAttribute`. A lone non-generic `params` array beside such a generic sibling, such as `Pick(params string[])` beside `Pick<T>(params T[])`, gets that overload as well, so `Setup.Pick().AnyParameters()` keeps working, unless another lone `params` array with as many type parameters, such as `Pick(params int[])`, would get the same overload.

Matchers that still bind the overload that takes values, which only happens for the type argument `object`, are recognized at runtime, as #1071 does for a parameter of type `T`: `Only<object>(It.IsAny<object>(), "a")` and `Sum<object>(1, "a", It.IsAny<object>())` match element by element and compare the plain values next to them by equality. This goes beyond `params object[]`, where a matcher next to plain values still matches nothing. A matcher for the whole array next to other elements matches one element there, as for `params object[]`. Plain values keep the comparison they had. Mockolate0007 no longer reports a matcher for an element of such an array that is recognized at runtime, as it already did not for a parameter of type `T`, and still reports a matcher for the whole array next to other elements.

```csharp
sut.Only<object>(1, "a");
sut.Only("a");
sut.Mock.Verify.Only<object>(It.IsAny<object>(), "a").Once(); // failed before
sut.Mock.Verify.Only<object>(It.IsAny<object[]>()).Once(); // failed before
sut.Mock.Verify.Only(It.IsAny<string>()).Once(); // failed before
sut.Mock.Verify.Only<object>(1, "a").Once(); // as before
```

One call behaves differently for every type argument of such a method: a `null` array now matches a `null` array instead of throwing an `ArgumentNullException`, for example `Setup.Sum<string>(1, null)` or `Verify.Only<object>(null)`, as #1031 defined it for `params object[]`. A `params` array of another element type, such as `params string[]`, still throws.

This is a narrow source break, as in #1098: `.AnyParameters()` is no longer available after a matcher or a `null` for such a `params` array, or after a lone `null` or `default` or one next to such an array for another parameter (e.g. `Setup.Sum<object>(1, null).AnyParameters()` or `Setup.Sum<object>(default).AnyParameters()`), and after a `default` for a non-generic sibling with as many parameters, such as `Setup.W(1, default).AnyParameters()` for `W(int a, int b)` beside `W<T>(int a, params T[] values)`, because such a call now binds a matcher or `IParameters` overload. Use `Match.AnyParameters()` instead. A lone `default` that was ambiguous before can bind now: for `Ws<T>(int value)` beside `Ws<T>(params T[] values)`, `Setup.Ws<object>(default)` was CS0121 and now sets up a `null` array, as the call on the mock `Ws<object>(default)` is ambiguous as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant