开发者

Resharper - Search For Instances Of Type

Is there a way for me to ask Resharper to find all instances of a given type or interface? I need to do a quick search for everywh开发者_如何转开发ere we're using an IDataReader.

[Edit] To clarify, I'm wondering if it's possible to identify explicit and implicit usages of the type. So IDataReader x = GetDataReader() as well as var y = GetDataReader() should be in the results.


Right-click on an IDataReader somewhere in your code and select "Find Usages" or "Find Usages advanced". Or is there something I am missing?


This is not currently possible with ReSharper. Here's a report on this problem in ReSharper issue tracker - please feel free to vote for it. There's almost no chance we can fix it for the upcoming version 6.0 though.

A workaround may be or may not be possible depending on your specific code base - for example, you could configure ReSharper's Code Cleanup to change "var" to explicit type usage, and follow that by searching for usages but I'm not really convinced you want to do that straight away. Another way would be to search for usages of GetDataReader() but chances are you have multiple methods returning this type.

All in all, that's quite an unfortunate limitation of ReSharper.


You can work-around this missing feature using structural search.

  • Open dialog with VS menu -> ReSharper -> Find -> Search with Pattern
  • Make sure C# is selected on the top of the dialog
  • Type var $identifier$ = $expression$; into the editor box to look for declaration statements with implicit type
  • On the right side of the dialog, double click the expression placeholder to edit its meaning
  • Set the topmost combobox to Expression Placeholder
  • Set the expression type to the type you are looking for
  • Press OK to go back to the pattern editor
  • Press Find to do the actual search.

This method is way more complicated than pressing Alt+F7 on the type name in the declaration. Still, you can do it if you are desperate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜