开发者

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

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 200开发者_如何学C8 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.


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


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜