Skip to content

Support C# 13 params collections in argument matching - #993

Merged
dtchepak merged 2 commits into
nsubstitute:mainfrom
zvirja:fix-905-params-collections
Aug 11, 2026
Merged

Support C# 13 params collections in argument matching#993
dtchepak merged 2 commits into
nsubstitute:mainfrom
zvirja:fix-905-params-collections

Conversation

@zvirja

@zvirja zvirja commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #905

Currently we support params for arrays only, while since C# 13 we could have many more types here. This PR adds support for that. I deprecated some of the code instead of deleting it just to play safe.

I tried to keep all params syntax knowledge in one class, so it's easy to maintain our interop with language. I also extracted all tests into a partial class - so it's easier to maintain it, as argument matching spec is growing quite a lot.

Notice, we still don't support Span/ReadOnlySpan primarily due to luck of support by the proxy library. I mentioned that in #992 so it's not lost.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@zvirja
zvirja requested a review from dtchepak August 10, 2026 13:56
dtchepak
dtchepak previously approved these changes Aug 10, 2026

@dtchepak dtchepak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 👍

Some random, non-blocking comments so feel free to ignore them and merge.

Comment thread src/NSubstitute/Core/Arguments/ParamsSupport.cs Outdated
Comment thread src/NSubstitute/Core/Arguments/ParamsSupport.cs
@dtchepak
dtchepak merged commit 14c88b5 into nsubstitute:main Aug 11, 2026
4 checks passed
@zvirja
zvirja deleted the fix-905-params-collections branch August 11, 2026 10:33
This was referenced Aug 11, 2026
This was referenced Aug 24, 2026
renebentes pushed a commit to renebentes/3054 that referenced this pull request Aug 24, 2026
Updated [NSubstitute](https://github.com/nsubstitute/NSubstitute) from
6.1.0 to 6.2.0.

<details>
<summary>Release notes</summary>

_Sourced from [NSubstitute's
releases](https://github.com/nsubstitute/NSubstitute/releases)._

## 6.2.0

# NSubstitute v6.2.0

This release improves generic call matching (#​989, #​974, #​990).
Thanks to @​zvirja and @​JMolenkamp for fixes this.
We've also switched to using trusted nuget publishing linked to GitHub
Releases. (#​987, @​zvirja)

## What's Changed

* Add trusted nuget publish by @​zvirja in
nsubstitute/NSubstitute#987
* fix: Stop using return-type assignability for generic call matching by
@​zvirja in nsubstitute/NSubstitute#989
* Remove skip-duplicate option from NuGet push command by @​zvirja in
nsubstitute/NSubstitute#988
* Add tag trigger for release pipeline by @​zvirja in
nsubstitute/NSubstitute#991
* Fix broken comparison of the generic methods by @​zvirja in
nsubstitute/NSubstitute#990
* Support C# 13 params collections in argument matching by @​zvirja in
nsubstitute/NSubstitute#993
* Add tests for nullable Task by @​zvirja in
nsubstitute/NSubstitute#994

**Full Changelog**:
nsubstitute/NSubstitute@v6.1.0...v6.2.0

Commits viewable in [compare
view](nsubstitute/NSubstitute@v6.1.0...v6.2.0).
</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Difference in Received() check between array params and new C# 13 params

2 participants