Repository navigation
fix: infer the type argument of a generic method from a matcher in setups and verifications - #1098
Conversation
[Medium impact] The latest changes appear safe to merge.
|
There was a problem hiding this comment.
All reported issues were addressed across 31 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
Test Results 58 files ± 0 58 suites ±0 1h 59m 19s ⏱️ - 18m 45s Results for commit f9362c7. ± Comparison against base commit d1b3146. This pull request removes 23 and adds 29 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
🚀 Benchmark ResultsCompared to Memory
CompleteWorkflowBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) Intel Xeon 6975P-C 2.70GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 MockCreationBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 9V45 3.89GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CompleteUnconfiguredBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) Intel Xeon 6975P-C 2.70GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CompleteMethodBenchmarks
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 CompletePropertyBenchmarks
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 CompleteIndexerBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 7763 2.62GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CompleteEventBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 7763 2.66GHz, 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 CallbackBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) INTEL XEON PLATINUM 8573C 2.99GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 AsyncBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 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 SequenceBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) INTEL XEON PLATINUM 8573C 3.01GHz, 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 |
017a261 to
861bd79
Compare
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
…etups and verifications On a generic method such as `ILogger.BeginScope<TState>(TState state)`, `Setup.BeginScope(It.IsAny<int>())` and `Verify.BeginScope(It.IsAny<int>())` compiled but never matched (#1081). The overload that takes values was promoted with `[OverloadResolutionPriority(int.MaxValue)]`, and without explicit type arguments the compiler infers `TState` from the matcher itself, so the call bound `BeginScope<IParameterWithCallback<int>>(value)` instead of `BeginScope<int>(matcher)`, and the setup was registered for the wrong closed method. A parameter typed with a method type parameter that a matcher can satisfy (`MayHoldMatcher`) now blocks that promotion, exactly like a declared `object` parameter already does: whenever a matcher overload is applicable, it outranks the overload that takes values, and it infers the type argument from the matcher. To keep the other spellings binding as before, the same rules as for `object` apply: a lone `null` or `default` with explicit type arguments (`Setup.Plain<string>(null)`) forwards from the `IParameters?` overload to the overload that takes values, so it still stands for that argument and not for any parameters (only same-arity generic siblings can capture that call), and a type parameter sibling keeps the all-values overload of a lone `params object[]` unpromoted, so `Setup.M("a")` still prefers `M<string>` as the call on the mock does. Above four parameters, where classic mode emits no mixed overloads, the generator now also emits one that takes matchers for the type parameter slots and values elsewhere, also for the overloads that leave out an optional parameter. A matcher for an `in` parameter is now wrapped covariantly like any other value parameter; before, `In<object>(It.IsAny<string>())` and `Equals(in object?)` setups with a derived-type matcher threw `InvalidCastException`. Because the overload that takes values is no longer promoted, a lone parameters match such as `Setup.Plain<object>(Match.AnyParameters())` now binds the `IParameters` overload. The runtime detection of a parameters match in the overload that takes values (#1071) is therefore unreachable, so the generated check and the unreleased `ParametersVoidMethodSetup`/`ParametersReturnMethodSetup` types are removed. A parameters match passed typed as `object` is now compared as a value, as for a declared `object` parameter. An alternative was an analyzer that reports a type argument inferred as a matcher type. It was not chosen because a generator fix exists that makes the natural spelling work at every arity, while explicit type arguments, literals, `null`/`default`, `Match.AnyParameters()` and `params` keep their meaning. This is a narrow source break: `.AnyParameters()` is no longer available after an explicit `null`/`default` or a matcher in a type parameter slot (e.g. `Setup.Plain<int>(default).AnyParameters()`), because such a call now binds the matcher or `IParameters` overload, as it already did for an `object` parameter. Use `Match.AnyParameters()` instead. A nullable matcher for a non-nullable type argument (`Verify.Plain<object>(It.IsAny<object?>())`) now reports CS8620, as it does for an `object` parameter. ```csharp ILogger logger = ILogger.CreateMock(); logger.Mock.Setup.BeginScope(It.IsAny<int>()).Returns(scope); // sets up BeginScope<int> logger.BeginScope(42); // returns scope logger.Mock.Verify.BeginScope(It.IsAny<int>()).Once(); // passes ```
A matcher for one type parameter next to a value for another still bound the overload that takes values and inferred the matcher type, and the overloads that leave out a type-parameter argument had no such overload to forward to. The combinations are capped at four type-parameter slots so that the generated overloads stay bounded.
A matcher next to an array matcher for `params object[]` still inferred the matcher type, a value next to a non-generic sibling set up the sibling instead of the generic method that the call binds, and a method with five type-parameter slots and a left-out argument did not compile.
The special cases do not depend on their own type, so they join an existing coverage type without a snapshot of their own (#1100). Union mode never applies to a method with a same-named sibling, so the sibling check there had no effect.
230fcc6 to
2aded11
Compare
This comment has been minimized.
This comment has been minimized.
Without the promoted all-values overload, a lone null for a non-generic method next to a generic sibling bound the IParameters overload and matched every call.
|
…ic method from a matcher in setups and verifications (#1098) by Valentin Breuß
…ic method from a matcher in setups and verifications (#1098) by Valentin Breuß
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.
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`.
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`.
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`.
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`.
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`.
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`.
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`.
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`.
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`.



On a generic method such as
ILogger.BeginScope<TState>(TState state),Setup.BeginScope(It.IsAny<int>())andVerify.BeginScope(It.IsAny<int>())compiled but never matched (#1081). The overload that takes values was promoted with[OverloadResolutionPriority(int.MaxValue)], and without explicit type arguments the compiler infersTStatefrom the matcher itself, so the call boundBeginScope<IParameterWithCallback<int>>(value)instead ofBeginScope<int>(matcher), and the setup was registered for the wrong closed method.A parameter typed with a method type parameter that a matcher can satisfy (
MayHoldMatcher) now blocks that promotion, exactly like a declaredobjectparameter already does: whenever a matcher overload is applicable, it outranks the overload that takes values, and it infers the type argument from the matcher. To keep the other spellings binding as before, the same rules as forobjectapply: a lonenullordefaultwith explicit type arguments (Setup.Plain<string>(null)) forwards from theIParameters?overload to the overload that takes values, so it still stands for that argument and not for any parameters (only same-arity generic siblings can capture that call), and a type parameter sibling keeps the all-values overload of a loneparams object[]unpromoted, soSetup.M("a")still prefersM<string>as the call on the mock does. Above four parameters, where classic mode emits no mixed overloads, the generator now also emits one that takes matchers for the type parameter slots and values elsewhere, also for the overloads that leave out an optional parameter. A matcher for aninparameter is now wrapped covariantly like any other value parameter; before,In<object>(It.IsAny<string>())andEquals(in object?)setups with a derived-type matcher threwInvalidCastException.An alternative was an analyzer that reports a type argument inferred as a matcher type. It was not chosen because a generator fix exists that makes the natural spelling work at every arity, while explicit type arguments, literals,
null/default,Match.AnyParameters()andparamskeep their meaning.This is a narrow source break:
.AnyParameters()is no longer available after an explicitnull/defaultor a matcher in a type parameter slot (e.g.Setup.Plain<int>(default).AnyParameters()), because such a call now binds the matcher orIParametersoverload, as it already did for anobjectparameter. UseMatch.AnyParameters()instead. A nullable matcher for a non-nullable type argument (Verify.Plain<object>(It.IsAny<object?>())) now reports CS8620, as it does for anobjectparameter.