Find all Classes that Override a Method

rbulph

Junior Contributor
Joined
Feb 17, 2003
Messages
397
Is there a way to quickly find all classes that override a given method? Maybe it would work like the "Find all References" item on the code context menu so you'd get a list of them in the Find Symbol Results window. This would be so useful because, without it, I'm having to look at all classes that inherit a class and might override a method in order to fully understand that method, and that's cumbersome. Any thoughts?
 
It's an interesting question. The thing is, there is no reason that the runtime would ever need this and it isn't a very common need, even when dealing with reflection.

As far as I know reflection doesn't directly support that kind of analysis. I'm guessing that what you have is the best you can do: enumerate the types and examine those that derive from the class in question. Is this causing a performance issue? Or were you just looking for a better way?
 
There's no performance issue, other than my own personal performance (!). It would be helpful to quickly be able to see how I was dealing with a method across the classes, rather than having to think about what classes I have that might override a method, and then check them all, opening extra windows in the process. There's so much that the Visual Studio does that I'm surprised this doesn't seem to have been dealt with, but perhaps I'm unusual in wishing for it.
 
Yes I'm still using the 2005 version. Not sure that I can be bothered with all the hassle (and presumably expense) of upgrading.
 
Expense - definitely, hassle however should be very little. VS 2010 will let you target .Net 2, 3, 3.5 or 4 and will even allow a .Net 4 application to load assemblies from other versions of the framework at the same time.
 
Or maybe it wouldn't be that hard to write an add-in myself. I remember doing this in the old Visual Basic. That way I can get it to do just what I want, and there's no time involved in figuring out what someone else's solution does.

Or actually the Find Symbol Command does pretty much what I want. Anyone know how to add this to the code context menu? I've tried through Tools/Customize/Rearrange Commands but can't see how to add buttons to this menu.
 
Last edited:
Back
Top