Skip to content

Attempt to fix nullability for e.g. #973#976

Open
jdb0123 wants to merge 10 commits into
nsubstitute:mainfrom
jdb0123:fix-973
Open

Attempt to fix nullability for e.g. #973#976
jdb0123 wants to merge 10 commits into
nsubstitute:mainfrom
jdb0123:fix-973

Conversation

@jdb0123

@jdb0123 jdb0123 commented Jul 13, 2026

Copy link
Copy Markdown

No description provided.

Jbontt added 2 commits July 13, 2026 13:53
… types

Change predicate signatures from Predicate<T?> to Predicate<T> in Arg.Is and ExpressionArgumentMatcher, aligning with the compatibility API which already used non-nullable predicates.

Replace the unboxing cast in IsSatisfiedBy with an 'argument is T typed' type check in both ExpressionArgumentMatcher and the GenericToNonGenericMatcherProxy. A null argument passed for a non-nullable type now returns false instead of throwing or coercing to default.
it already throws when it's not assignable
@dtchepak

Copy link
Copy Markdown
Member

Thanks for picking this up @jdb0123 . Would it be simplest to revert #856 ?

Let me know when you're ready for a review of this. 🙇

@jdb0123

jdb0123 commented Jul 14, 2026

Copy link
Copy Markdown
Author

@dtchepak no problem, happy to help.

I believe the current changes should be sufficient to fix the issues. However, I only detected and fixed things which showed up in our own usage of nsubstitute so I might have missed things.

I think reverting the changes would be a bit of waste, given that the direction of enabling nullable is a good idea.

Anyhow, these changes are ready for review.

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