Replies: 1 comment
-
We're (historically) using |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We're (historically) using |
Beta Was this translation helpful? Give feedback.
-
I specifically want to do something like
list.Should().Contain(x => x is MyType m && m.MyProp == expected)
. But I think my question can be generalized to pattern matching in general, or even to "Why are predicatesExpression<Func<T, bool>>
s?" But this can mostly be done with the help of theCallerArgumentExpression
attribute. It will be a little bit different, and you won't get the body if you build theFunc
before (as you can with theExpression
s).Could give the
Contain
method a signature like this,I don't think it'll clash with the original signature, and it'll give us full access to all C# feature in the predicate function.
I don't know, just an idea. I solved my original problem by doing
list.Should().Contain(x => x is MyType && ((MyType)x).MyProp == expected)
.Beta Was this translation helpful? Give feedback.
All reactions