Skip to content

Custom arg matcher support#912

Merged
dtchepak merged 3 commits intonsubstitute:mainfrom
dtchepak:custom-arg-match
Feb 22, 2026
Merged

Custom arg matcher support#912
dtchepak merged 3 commits intonsubstitute:mainfrom
dtchepak:custom-arg-match

Conversation

@dtchepak
Copy link
Copy Markdown
Member

  • Add Arg.Is(IArgumentMatcher<T>) and related overloads to provide better support for custom arg matchers.
  • Add ArgMatchers.Matching to match predicates with descriptions without requiring expressions.
  • Document changes

Feedback requests

Please check API seems reasonable.
Anything missing and/or confusing with the documentation additions?

Should we move these types (ArgMatchers, IArgumentMatcher, IDescribe*) into root package, rather than NSubstitute.Core.*?

@dtchepak
Copy link
Copy Markdown
Member Author

Hi @tpodolak,
Will these changes require analyzer updates?

@304NotModified
Copy link
Copy Markdown
Contributor

@dtchepak could you please fix the conflict?

- Add IDescribeSpecification to allow custom arg matchers to provide
  custom output for "expected to receive" entries.
- Fallback to ToString when IDescribeSpecification not implemented.
- Update code comment docs accordingly.
- Improved support for custom matchers

Closes nsubstitute#796.
@dtchepak dtchepak merged commit 0916244 into nsubstitute:main Feb 22, 2026
4 checks passed
@dtchepak dtchepak deleted the custom-arg-match branch February 22, 2026 05:22
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.

3 participants