views:

745

answers:

5

Is there a quick way to find all of the implementations of, not references to, an interface's method/property/etc? Here's some sample code:

public class SomeClass : IBaseClass
{
  public Int32 GetInt()
  {
     return 1;
  }
}

public interface IBaseClass
{
  public Int32 GetInt();
}

public class SomeOtherClass
{
  ISomeClass _someClass;
  private TestMethod()
  {
    _someClass = new SomeClass();
    _someClass.GetInt();
  }
}

I want to quickly get to SomeClass.GetInt() while reviewing SomeOtherClass.TestMethod(). If I right click on _someClass.GetInt() and click 'Go To Definition', it takes me to the interface. If I click 'Find All References', I could potentially see a list of all uses ... not just the classes that implement the GetInt() method.

Is there a faster way to find this? Any tips from other developers? We are using D.I. for most of our dependencies, which means that tracing through deeply nested code takes forever.

+3  A: 

Alt-End will do this in ReSharper, I believe.

lance
Ouch, $349 per developer. That's what we paid for VS2008 pro.
Jess
You didn't ask for a sales pitch for ReSharper, and what you're earning is none of our business, but consider what kind of money you're making doing what you're doing, and then consider how quickly you'd recoup the license fee. If the numbers are right, $350 is worth it. To give you some perspective, I'll claim that, after 1 month of actually slowing myself enough to learn ReSharper's ins and outs (and, to be sure, I'm still learning some of them) while I work, the tool increases my productivity as a code author by 30% at LEAST (it's probably higher, frankly, but I don't want to exaggerate).
lance
I agree, any company that balks at resharpers price (the C# only edition is even cheaper) is an idiot since the time you waste without costs a company $1000s. I also agree with lance's view that the cost of resharper is easily recouped in a month.
Chris Marisic
I've used it some in the past. While I found it useful for refactoring (which I don't do often), I didn't find it making me much more productive. I'll admit that I didn't spend a lot of time learning the "ins and out", but it's hard for me to justify the expense when our only problem with VS.NET is finding implemented interfaces.
Jess
Agreed! I don't care how much money you're making -- you'd have to use the "Go To Implementation" feature quite a lot to recoup the license fee from that feature alone! :)
lance
+1  A: 

R# has a Go to Implementation option on the pop-up menu, which is really handy for that.

Brian Rasmussen
Sounds great, nothing in VS that you know of?
Jess
Not beyond Find References which you already mention. If you don't know R# I really encourage you to check it out. In addition to features like this it has useful coding tip and a really powerful set of refactoring features.
Brian Rasmussen
Isn't R# a completely different programming language, or there an R# IDE as well? We are building an ASP.NET MVC app ...
Jess
R# is Resharper. A plug-in for Visual Studio. It adds a bunch of useful commands.
Brian Rasmussen
Ah! I had just googled R# and came up with this ( http://sourceforge.net/projects/r-sharp/ ). I'm obviously not down with lingo =)
Jess
+2  A: 

Looks like there's hope, at least. Be sure to follow the Future Focus: Call Hierarchy link shared by DJ Park.

lance
That looks pretty sweet, thanks. Too bad there's not a plug-in for VS2K8.
Jess
+1  A: 

Without ReSharper the best way to do this is:

Find in files (Ctrl+Shift+F) Find What: "class*ISomeClass" Find Options: "Use Wildcards"

This will find all implementation and than you can search for your function in a concrete implementation.

Zhenya