Custom pattern for HashSet<T> + Queryable.Contains

Because of this issue in Entity Framework I'm looking for a custom search pattern in C# that tracks occurrences of `hashSet.Contains` in which `hashSet` is a HashSet<T> variable and Contains is Queryable.Contains.

I managed to create a pattern that finds hashSets variables of type “System.Collections.Generic.HashSet<int>” followed by “.Contains” textually, but

  • that's too specific (not System.Collections.Generic.HashSet<T> )
  • it yields false positives because there are more Contains methods for HashSet.

I didn't manage to create a pattern with these elements:

  • a variable of type “System.Collections.Generic.HashSet<T>”
  • Queryable.Contains
  • (
  • a variable of type “T”
  • )

Is it possible in the custom pattern editor?

0
3 comments

Hello Gert,

Could you please provide an example of your current search pattern?

Thank you.

0

I hope this will be clear enough:

0

Hi,

Sorry, took a long time to respond.

We've tried to create a pattern but got stuck with reconstructing code sample that uses different Contains method? If the request is still relevant for you, could you please provide such code sample as well?

Thank you in advance.

 

0

Please sign in to leave a comment.