Can I see the "final" C# code when viewing an interface's methods?

93 views Asked by At

What I'm trying to say is, if an object is defined as an interface, then instantiated from a class factory, is it possible in VS 2008 to right click on a method call from that object and see the real code, instead of the interface's empty signature?

In other words there's a lot of this in our code:

ISomeInterface myObject = ObjectCreationFactory.CreateConcreteClassX();

myObject.DoSomething();

If I right click DoSomething() and go to its definition, I wind up seeing the (blank) method definition in ISomeInterface, and not that of the class returned by the ObjectCreationFactory.

Certainly I can go to the source in CreateConcreteClassX() and see what class is being instantiated, then go from there, but it'd be nice if there were a way in VS2008 to tell it "don't look at the interface, look at the concrete implementation." Could be I'm dreaming, but thought I'd ask anyway. Thanks for the help.

2

There are 2 answers

1
Ralf de Kleine On BEST ANSWER

Try the plugin Resharper. With right click you can go directly to the implementation.

0
3Dave On

CreateConcreteClass() could return any object that implments ISomeInterface, so there's no way to tell at compile time which method an interface member will point to. You could always trace into the call and see where you wind up.