Visual Studio: Missing Ctrl+O+O, Ctrl+T Eclipse analog - visual-studio

I very like Eclipse Ctrl+O+O hotkey which includes in the list of members not only members of current class, but also all the members of all super-classes.
"Quick type hiererchy" feature also is pretty useful. Resharper has Alt + End and Alt + Home keys, but it doesn't organize result in a tree what is very handy.
Is it possible to get mentioned functionality in VS?

ReSharper provides the Type Hierarchy window (ReSharper > Inspect > Type Hierarchy) for investigating inheritance.
File Structure (ReSharper > Windows > File Structure) is ReSharper's version of Outline, and it could be what you're looking for.
Alternatively, you can step on the name of a superclass or interface being implemented in the type declaration, invoke ReSharper > Navigate > Navigate to, and choose Implementing members - it will highlight you all members from the given interface that are implemented in the current class, and you can navigate between the highlights.
If you tell me more about your usage scenario, i.e. what task you're trying to solve with an analog of Ctrl+O+O, I could advise you how to solve this task with ReSharper.
UPDATE:
ReSharper 6 (pre-release builds of which can be found here) provides a feature that corresponds to your usage scenario. In a file containing a class from an hierarchy, press Ctrl+F12 (IntelliJ IDEA keymap) to invoke "Go to File Members". Then, press Alt followed by Space to switch on the "Include members from related files" feature. This will show you any members in types up the inheritance hierarchy. You can flush results to the Find Results window by pressing +, and group them in a preferred way:

Related

How to list all classes implementing a interface using ReSharper?

Is there a way to list all classes implementing a given interface in ReSharper?
I usually find ",interfacename" to accomplish that but it is not a terrible solution.
In Resharper you can use Go to Implementation (Ctrl+F12, or click the symbol holding Ctrl+Alt keys) and use "Show in Find Results" option to show the results in the find results window.
Not resharper related, but Visual Studio 2015 after Update 1 allows you to right click the interface and select "Go To Implementation". With Visual Studio 2015 Update 2 they have added a shortcut Ctrl+F12.
Sure, put the text caret on the interface name and invoke Go to Derived Symbols - either Alt+End or Ctrl+Alt+B, depending on the keyboard scheme.
Note that you can also hit Alt+Enter on the interface name and type "derived" to get to the Go to Derived Symbols action a little quicker. Or use the Navigate To context menu to show all the navigation options for the interface name (Alt+~ or Ctrl+Alt+G)
Also, when the popup menu shows listing the interfaces, click the icon in the top right, and it will open the list in the Find Results window.

Find out what class a method belongs to (in Visual Studio or Resharper)

If I'm looking at a method definition in Visual Studio (with Resharper) is there an easy way to find out what class it belongs to? (As of now, I've resorted to a text search in the "up" direction for the string "class".)
The Resharper command Go to containing declaration (ctrl + [) should do the trick
Edit:
Or if you have the navigation bar at the top of the code window enabled, that should display the type name. But I have that turned off, since I use keyboard navigation and the bar itself slows down Visual Studio.
You have files with more than one class in? That makes ponies sad...
Anyway, to actually answer, can't you just look at the navigation bar?
The best (direct) way specific to your question is PHeiberg's answer.
But if you ask this question I guess you don't know the File Structure window that can be enabled by ReSharper->Windows->File Structure or by shortcut Ctrl+Alt+F.
With that window you see always where you are in your file.
Aside from using ReSharper's File Structure and/or Go to Containing Declaration - options mentioned previously - there's also a tiny feature in ReSharper called Quick Documentation that in my view is better suited for this kind of task since it shows you method info in-place, without forcing you to navigate anywhere from the method you're on. Ctrl+Q, Esc, and you're done. It works on all kinds of symbols (not limited to methods), both on declarations and on usages.
For VS, right click on the function and select 'Go To Declaration'. (Ctrl + F12)

Can I auto-import a namespace in MS Visual Studio 2010?

When developing for Android in Eclipse, for example, it's easy to automatically import packages and classes by hitting Ctrl+Shift+O. I'm finding it difficult to write code every time I have to go google a function to figure out its namespace ... is there an easier way?
Once you've added a dll as a reference, VS will suggest this as part of its intellisense feature. Type in the name, and then hover over it - there will be a blue (maybe it is red?) underline - and VS will give you an arrow to click that lets you add the namespace.
If it is a namespace you find yourself adding frequently, you can add it to your config so that you're not doing it in files across your project.
(I do have Resharper installed so I can't check this, but I'm pretty sure VS has this natively...)
There is Ctrl + Shift + F10 or Ctrl+ shortcut, that provides some light refactorings like creating method stubs, renames methods and variables and imports usings.
This shortcut is not always available - it can be used when a small red box underneath, after you click it you'll see the drop-down menu with a choice of possible actions
When you type in a class name, hit Ctrl + . a list would appear, then hit Enter on what you need

Visual Studio window which shows list of methods

In Visual Studio, is there a window which shows list of methods in the active class? A small window like the Solution Explorer would be great. In Eclipse, there is one.
There's a drop down just above the code window:
It's called Navigation bar and contains three drop downs: first drop down contains project, second type and third members (methods).
You can use the shortcut Ctrl + F2 (move focus to the project drop down) and press Tab twice (move focus to the third drop down) to focus it, down arrow will expand the list.
Full size image
I found how to turn the drop down on as shown in the first answer (#ChrisF):
Go to Options->Text Editor->(your language)
and tick "Navigation bar" in the display section.
Since Visual Studio 2012, you can view the outline ( fields and methods) in the solution explorer by expanding the node corresponding to your file .
Shortcut to Navigation Bar is Ctrl+F2. Takes you to the types dropdown first. Press tab to go to method dropdown, and then enter on a method to go to that one.
ReSharper has a 'ReSharper | Windows | File Structure' window, which is used for visualizing current code file structure.
Resharper has the File Structure window which is very similar to eclipse outline view. Originally answered in:
Visual Studio 2012: List of all Methods in class
Resharper help:
http://www.jetbrains.com/resharper/webhelp/Reference__Windows__File_Structure_Window.html
Despite it's an old question maybe this answer help you as helped me.
you can download codemaid extension from here : codemaid website
it has a lot of functionality that you may find in their website.
the one that is related to this question is code digging
Visualize and navigate through the contents of your C# and C++ files from a tree view hierarchy. Quickly switch between different sorting methods to get a better overview. Drag and drop to reorganize the code. See McCabe complexity scores and informative tool tips.
in other words it give you ability to see the methods and properties and also reorganize them just with drag and drop. it's my everyday use extension
There is no direct equivalent to the Outline View in Eclipse. The closest thing I've found is the Class View, which lists all classes and their members/methods. There is a search box at the top to narrow the selection.
In Visual Studio 2019, there is the "Go To Member" action located in Edit - Go To that is mapped by default to ALT+\. I think this was added in Visual Studio 2017.
This is what pops up which provides the desired functionality and a couple of options:
In Visual Studio 2015, View > Other Windows > Resource View. The keyboard shortcut is Ctrl+Shift+E. I find this cleaner than Class View. With Class View Windows you can filter methods/attributes based on access modifier (private/protected/public) etc.
A nice clean way to do this is to use the command View.SynchronizeClassView by entering it into the Command Window (View > Other Windows > Command Window or Ctrl+Alt+A) but there's no way to do it automatically.
Additionally, you can:
pin your Class view window
collapse the top pane (listing all the classes)
And now it feels just like the Visual Assist's feature "List Methods in Current File" (which also list members btw).
At the top of your text editor, you should have a dropdown that lists all the methods, properties etc in the current type; and it's clickable (even if those members are defined in other files - in which case they're greyed out but you can still navigate with them).
Also, if you use the Class Explorer (Ctrl+Alt+C) to navigate your project, then you'll get a full overview of all your types. However, there doesn't appear to be a setting in Tools/Options that allows you to track the active type in that window (there is for the solution explorer) - perhaps a macro or addin is in order...
Microsoft doesn't feel like implementing this useful tool, but if by chance you can have Visual Assist, you have it in VAssistX > Tools > VA Outline. The plugin is not free though.
In Visual Studio 2005 and 2008 you can try the Source Code Outliner Power Toy.
alt text http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=SourceCodeOutliner&DownloadId=3493
Do you mean the class view window (View->Class View, or Ctrl+W,C)?
You also have the intellisence popup-window
With Visual Studio 2010
You choose Tools->Settings->Expert Settings
On the left-bottom corner, you will see the tab "Class View" right next tab "Solution Explorer"
In the top area of "Class View" layout, you will see the list of class name, enum, struct, ...
In the bottom area of "Class View layout, you will see the list of member for these class, enum or struct
I have been using USysWare DPack since forever. It is very small and not intrusive so if all you want is a quick shortcut window showing list of methods of the current file you are using, it provides just that. Good thing is that the author is still active after more than 10 years just to keep providing the same features into latest VS release.
https://marketplace.visualstudio.com/items?itemName=SergeyM.DPack-16348
After installation, just use Alt + M to bring up the method list window. I prefer to show all members instead, but it's up to you.
In VS 2012, just go to View > Class View...then you get the Class View GUI in the main tab area. Now, drag this over to the side dock and you have the exact same layout as you would in Eclipse.
-e
My best way to do this is, that i open the Code Definition Window, under View -> Code Definition Window or press Ctrl + W,D .
And then i got it floated and i have the definitions of methods in separate windows.
Regards
grep -i " sub " filename.vb > methods.txt
grep -i " function " filename.vb >> methods.txt

Alphabetizing methods in Visual Studio

Is there any sort of plug-in or tool available for Visual Studio 2008 to alphabetize methods? Ideally I'd like a tool that will alphabetize a selection, or specified type (i.e. only methods, not member variables), either automatically or on-demand.
While Resharper has many cool features it has a large impact in CPU and I/O usage and can be very complicated to use. It is also only available under commercial licensing unless you qualify for a few very specific free use licenses.
Try CodeMaid. It is free for commercial use and has a much lower performance overhead. I find it easy to use and it is very good for alphabetizing methods.
To sort your file, open the file via solution explorer:
Right click the open file
Code Maid menu (likely near the top of the right click menu)
Click Reorganize Active Document
Alternatively, using the default CodeMaid hotkeys CTRL+M,Z to sort your active file.
Resharper has a Type Members Layout, which can order members by type, accessibility and alphabetically as well.
You can also take a look into Ora , which presents a pane in visual studio that is ordered (even though your source may not be). Link's dead.
The following answer goes much further than the OP asks, because I believe, that sorting methods just by name is far not enough for most programmers. Mostly you want your methods, constructors, fields, event handlers, and interface implementations to be seperated from each other (i.e. through regions), and sorted by various criteria.
For this purpose I tried NArrange, Regionerate, and others, but I've found them not intuitive to use. So ReSharper became the tool of my choice.
As already mentioned by #DavidN, ReSharper can sort your class members (fields, constructors, methods, delegates) by name, accessibility, type, readonly, etc... You can also surround specific members with regions. What I like the most is the ability to group interface members (e.g., #region IDisposable with void Dispose() method in it) and methods that handle an event.
ReSharper provides both - an easy way to configure and trigger the sorting of class members.
Configuring the layout
Create a XML file within Visual Studio and copy-paste the default type member layout (ReSharper Options > Languages > C# > Type Members Layout) into that file. Download the latest XSD schema. Add the schema file to Visual Studio's schema files (Menu > XML > Schemas... > Add). You should be able now, to edit the XML file with IntelliSense support.
Triggering the reorder
If you use the Visual Studio keyboard scheme (ReSharper Options > Visual Studio Integration) and press Ctrl+E,F for Silent Code Cleanup. A dialog will pop up, where you can select a Code Cleanup setting. For this setting you should check Reorder type members. The second time you press the shortcut, ReSharper will automatically reorder your class members.
1: ReSharper Type Members XSD Schema
For C# you can use Regionerate to organize your code. You can create a template that simply organizes your code but doesn't use regions.
You can create such a function yourself using Devexpress' free DXCore product (the same extensibility framework used to create CodeRush).

Resources