Pattern Catalog with Generic types?

I'm trying to create a pattern to match the expression of type "List<T>".

<Pattern Severity="WARNING">
    <Comment>Redundant ToList()</Comment>
    <ReplacePattern>$list$</ReplacePattern>
    <SearchPattern>$list$.ToList()</SearchPattern>
    <Params />
    <Placeholders>
      <ExpressionPlaceholder Name="list" ExpressionType="System.Collections.Generic.List&lt;T&gt;" ExactType="False" />
    </Placeholders>
  </Pattern>


However, this doesn't find anything.

When I use a non-generic type such as IList, then it finds it, but it also finds other items that I don't want it to find, such as arrays.

Is this something that the pattern catalog doesn't support?

3 comments

Hello Makoto,

I've checked the pattern and it works fine for me. Please note that your
pattern matches only usages of List etc (with concrete types as T). Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

I'm trying to create a pattern to match the expression of type
"List<T>".

 Severity="WARNING">
> Redundant ToList()
> $list$
> $list$.ToList()
> 
> 
>  ExpressionType="System.Collections.Generic.List<T>"
> ExactType="False" />
> 
> ]]>

However, this doesn't find anything.

When I use a non-generic type such as IList, then it finds it, but it
also finds other items that I don't want it to find, such as arrays.

Is this something that the pattern catalog doesn't support?

---
Original message URL:
http://devnet.jetbrains.net/message/5281864#5281864



0

This seems to be broken for me.

Also, in the code Inspection Severity option, I noticed there's one for "Parameter type can be IEnumerable<T>", but then I tried to create a method which takes in a List<T>, and it didn't give me any warning or suggestion.

EDIT:
If it helps, I'm using Visual Studio 2010

0

Hi Makoto, everyone,

Did you get a resolution to this problem?

I'm experiencing exactly the same issue, and was wondering if you'd found a fix.

Thanks
Matt

0

Please sign in to leave a comment.