Skip to content

Implemented Arg.Is matcher and generic constraints#733

Merged
dtchepak merged 5 commits intonsubstitute:mainfrom
icalvo:anytype
Sep 3, 2023
Merged

Implemented Arg.Is matcher and generic constraints#733
dtchepak merged 5 commits intonsubstitute:mainfrom
icalvo:anytype

Conversation

@icalvo
Copy link
Copy Markdown
Contributor

@icalvo icalvo commented Aug 29, 2023

This PR implements a part of #634.

Arg.AnyType does not work when the type we replace has generic constraints. Therefore we converted AnyType to an interface so that the user can implement a custom class that satisfies the constraints.

Arg.Is matcher was not supported by the former PR (#715).

XML-Doc comments have been added to Arg.AnyType.

/// If the generic type parameter has constraints, you will have to create a derived class/struct that
/// implements those constraints.
/// </remarks>
public interface AnyType
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.

thought: what do you think about providing implementations for common constraints? In particular AnyClass (with default ctor to match : class, new()), and AnyStruct or AnyValueType.

@dtchepak dtchepak merged commit 6db536b into nsubstitute:main Sep 3, 2023
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.

2 participants