Finding Sub-Classes and Implementations - visual-studio-2010

My favorite way to find subclasses of class 'X' or implementations of interface 'Y' has been to use Red Gate's Reflector. But I'd like to know if there is a (free) way to do the same thing from VS 2010. Does 2010 already have this ability? Is there a plugin I can add?
The object browser, the place I might expect this feature to be found, does not seem to have this capability. It can tell you about a parent type, but it does not tell you about derived types.

A more non-straight forward but works in all cases is to temporarily change the class/interface that you are modifying to abstract and add a abstract method.property and rebuild the solution :) all the build errors would point you towards the direct/indirect children.

While I've not found a RedGate Reflector level of functionality for this need, I have started using a partial solution. Using the regex search capability in VS, I enter the following:
\:.#<place base class or interface here>
Example:
\:.#MyBase
Any derivative interface or class made from "MyBase," defined in the solution, will be returned.

I've just found free Inheritance Margin Extension.
With this I can view inheritance info right in the code editor and also navigate to base/overridden items (with right mouse click on the inheritance glyph).

Related

How can I know who calls the method in Xcode?

Does Xcode have a way to show the caller function of a method? I want to know all of the calling functions of a method in a class. A solution would be to find the method in the project, but sometimes different classes have methods with the same name - That could find us a method we're not looking for..
Many other IDEs have this capability, such as Visual C++ 2003/2005/2008,Eclipse ...
Can you do this in XCode?
Xcode 4.4 intrudced this functionality:
New Features in Xcode 4.4 (Scroll down to 'Find and Search Additions')
Move your cursor on top of the function you are interested in
Open the Assistant editor(⌃ +⌘+Enter)
On the top of the assistant editor, Select 'Callers'
You will see a list of all the function that's calling your function
Not the as effective as other IDEs, but does the job.
Yes. Set a breakpoint inside your method, then when it breaks, there are two spots to see a stack. First is in Xcode's "console" area (usually the bottom middle), there is a top-bar which may not immediately appear to be navigable, but it is a select-style UI control which has the entire stack in it. Selecting a different level shows you that scope's variables, etc. and pops your editor to that exact file (where you can mouse-over variables to see their in-memory real-time values). Second is in the left-hand area (where you normally browse files). There is another tab there (besides the file browser) for exactly this purpose. There is a slider at the bottom which controls how many "steps" in the stack you see; clicking on one has a similar affect.
For simple refactoring such as method re-naming, you can use the contextual-menu when you right-click a selected method-name, and Xcode will replace all identical selectors in your project. However, this does not address what you mentioned about different classes having methods with the same signature. It does, however, give you a very nice interface for reviewing the changes in-context and easily accepting or rejecting them one at a time.
It might be noted, however, that changing method signatures often may be a sign of poor design, and particularly if you have to do it with methods which have the same signature on different classes (which are not "siblings" and therefore should both get the rename)

Is there a way to group methods/properties in the outline view of Aptana IDE

I've looked everywhere for a feature like this. I use the Aptana IDE (which is based on Eclipse) for my php development, and I use the outline feature a lot.
I enjoy xcode's 'pragma mark' feature, which lets you group sections of your source code together in the outline view for quick reference. (Described here: http://cocoasamurai.blogspot.com/2006/09/tip-pragma-mark-organizing-your-source.html)
Is there anything like this for Aptana/Eclipse?
[EDIT: I wrote this blog post which explains further: https://peacocksoftware.com/blog/create-pragma-separator-eclipse-xcode ]
The closest I have found is to do one of these two things:
Create a dummy constant, or create a dummy function. Both will create entries in the outline. See screenshot. Personally, I think I like the constant better, because its icon in the outline makes it clear it isn't really a function.

Why Dialog is not a Component in Scala Swing?

This question arises because I want to capture LostFocusEvent from Dialog. Unfortunately, this event is not fired for non Component derived components. What I want to ask is what is the aim of Dialog not derived from Component, but RichWindow, as compared to the Swing library?
I think really the best way to get the answer is to contact Ingo Maier directly, but you may be able to deduce the some of the thinking behind from his blog article The scala.swing package in 2.8 and beyond:
Window hierarchy
This is how the Java AWT/Swing window hierarchy looks like:
While AWT's Frame and Dialog share the common base class Window, the Swing extensions have no subclass relationship or extend a common interface even though they share common functionality not present in AWT. In an attempt to straighten things up a little, we redesigned the window base hierarchy in scala.swing which now looks as follows:
[...]
This design lets us factor common wrapper code into class RichWindow.
So I am guessing that this is a deliberate design by the author stating that Windows are in fact not components in the same way frames and buttons are, and can be dropped on to other containers.

When I am looking at a method that is called on an interface, how do I go to the code the implements the method?

We have lot of code like:
IPerson
{
Eat();
}
Persion : IPerson
{
}
IPerson p;
p.Eat();
As most of our interfaces only have 1 or 2 classes that implement them, there should be a way for me to right click on the “p.Eat()” and be taken to the code the in person class. When there is more than one implementer, I wish to be shown a list to choose from.
There is a new feature in Visual Studio 2010, called View Call Hierarchy (Ctrl+K, Ctrl+T).
Right-click on a symbol in code (method name or properties are good) and select View Call Hierarchy, and you will get a new window with various options. On interface members, you will see an 'Implements [member]' option, dropping this down will show you all instances where the interface member has been implemented.
Similar options appear for virtual / abstract members, showing you where they are overridden or implemented.
As an extra bonus, this window also shows 'Calls To [member]' and 'Calls From [member]'.
Resharper is an extremely valuable refactoring tool which provides the behaviour you describe.
I currently right click on the method name in the interface file and select the option 'Go To Implementation'.
I'm assuming this is a Resharper feature and not just Visual Studio 2010 purely because you aren't aware of it. Try right-clicking and seeing if you have the option. If not - I highly recommend getting a refactoring tool with this kind of functionality.
Edit | Find and Replace | Find Symbol will find definitions and references.
Right click on p.Eat() and choose "Find all references". In the Find Symbol Results windows, you may find all of the implementations of that interface method. Double-clicking each item will show up the reference in code editor.

Flatten inherited members in Visual Studio's Watch window?

Is there some way to make the Watch window display all inherited properties and fields in one long flat list, rather than hidden behind a nested "base" node?
I'm debugging some C# code that makes massive use of inheritance - some of the properties I want to watch are behind three levels of "base" in the Watch window. This would be more or less bearable if I just wanted to examine a single such object, but I'm actually looking at a tree of them...
see http://blogs.msdn.com/b/jaredpar/archive/2010/02/19/flattening-class-hierarchies-when-debugging-c.aspx
UPDATE: I wrote a commercial tool called OzCode that solves this problem. The idea is that if you're interested in a property of the base class, you can "Star" that property, which causes the property to appear at the top of members list, and also in the text of its parent.
So for example, in the following scenario, I had to expand two base nodes to get to see the properties I wanted, "Important" and "Interesting":
But once I star these properties, they will always appear at the top, even when viewing variables of the Derived type, so I'll see:
These stars are persisted and will be shown whenever you view a an object of that type in the DataTip or QuickWatch window from that moment on, so the next time you a variable of that type, you won't need to expand those "base" nodes. And because starred values appear as the parent node's text, if you're looking at a tree datastructure of these heavily nested objects (as you stated you were), you will be able to see these properties without even expanding the nodes at all.
FULL DISCLOSURE: I'm the co-author of the tool I've described here.
Not as such. You see, it is a feature! The ability to see where a property comes from is important most of the time.
I understand your pain though. There are some work arounds. First, you can just put the object.property in the watch window. This will just display the property you are looking for. It is great for digging into a specific property but not so much for getting all the others.
You can also try (BaseClass)object. This will cast it to the base object that contains the property (properties?) you are looking for. Again it is great for looking a a specific subset of properties but completly hides all the others.
Good luck and good hunting.

Resources