How to get an Eclipse-like class outline in VS 2008/C#? - c#

I've just recently started using VS2008 for a new tools project, and have been spending a lot of time in Eclipse/Java. The one thing I am missing is the thing I could have sworn was in VS2005 the last time I worked with it - the class outline.
I'm speaking of the basic outline in Eclipse, where you can see the class members, methods, etc and click on them to navigate to them.
The only thing that sounds like it might be it (but is not) is the Class View.
Any help?

This is probably the closest addin that you'll find that has it:
Source Code Outliner Power Toy
(The window on the left is what it adds to Visual Studio)
alt text http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=SourceCodeOutliner&DownloadId=3493
"You can dock the Source Code Outliner anywhere, like to the left side of the Visual Studio window next to the Code Editor window."
"Click a method or variable name in Source Outliner and the code associated with what you clicked displays near the top of the Code Editor window."

JetBrains Reshaper.

This is what I had to do:
Open the Object Browser (View->Object Browser). It will open as a tab.
Right click the tab and select the "dockable" option. Then it will open as a window floating around.
I have 2 monitors, so in one of them I have visual studio, and in the other I put the Object Browser window. If you click something in the Object Browser, it will take you to where it is defined in the visual studio editor.
Not the same as the Eclipse outline (I miss it too), but this is the closest to it I'have found without adding pluggins.

Try this menu option:
View > Class View
The default keyboard shortcut is
Control + Shift + C

Related

Finding occurrences of a method or variable in Visual Studio

So I've been working with Visual Studio 2010 lately. While I'm not a huge fan of Eclipse, I do miss one feature: the fact that if you click on a function or variable in your code, it will mark all occurrences of that thing on the right frame of the text editor with a yellow or white rectangle. Does such a feature exist in Visual Studio? If not, is there a plugin out there that'll do this? I really don't want to resort to Find All every time I need to keep track where something is used.
Highlight References is feature in Visual Studio 2010 for C# and VB only. Any time you place the blinking caret on a symbol, Visual Studio will automatically highlight all instances of that symbol for you You can actually cycle through these highlighted references – just use Ctrl+Shift+up arrow and Ctrl+Shift+down arrow to move to the previous or next highlighted symbol.
The ProductivityPowerTools is what you may need. There you have a bar where you can see a minimized view of all your code. If you click there you can also navigate your code. But if you click within your actual code on a member, all occurences of this member are shown in the map.
Press Ctrl-K then Ctrl-R, this will find all references to the method (or object, variable, etc.)

Visual Studio Debug and variable watching

I'm having a really annoying issue with visual studio 2012.
During Debug I was used to look at the results of objects setting breakpoints and then moving mouse over the object and start exploring.
Now on my laptop that has a screen width of 1280px, it's not possible because the variable values are not wrapped, and the box goes completely out of the screen.
see the picture below:
and I'm not able anymore to click on the plus sign on the far left to view all the elements of the IEnumerable, or List...etc..
Is there some settings I have to modify to make it work also on 1280px screen?
At the root level, it (a DataTip dialog) has an unpin icon. Click the icon and the dialog floats above any open windows, and you can drag the dialog to a comfortable place, so you can expand to view all the elements in the IEnumerable (hopefully 1280px is enough).
View data values in Data Tips in the code editor
1920px (or higher) is a better resolution.

Visual Studio 2012/2013 Navigation Back/Forward with Mouse confliting with Mouse Plugin

The Navigate Backward (Ctrl+-) and Forward (Ctrl+SHIFT+-) buttons on the IDE use to be controlled by the mouse lateral Back/Forward buttons in VS 2010.
In VS 2012, the mouse buttons only works in some cases, like going back after clicking in "Go To Definition" in a method call. They are not attached to the IDE buttons.
Trying to fix that, I've installed this plugin: Mouse Navigation
Well, it works fine until you use the "Go To Definition", after that, the embedded VS Back/Forward mouse functionality start to conflict with the plugin, resulting in messy behavior!
Am I the only one with this problem? I've tried to Google it, but I've found nothing.
This is really annoying! I hope someone can help me to solve that.
Edit:
As you can see at the marked answer, the plugin have been fixed by its developer thanks to this topic. The last version (2.2.0) is working fine.
Some clarifying:
Visual Studio (2012) separates the normal navigation from "click to go" navigation.
Normal navigation: mouse click anywhere in code editor, tab change also.
Click to go navigation: Go to definition, search result click. It is controlled by the buttons named: "Browse Back / Next" "Previous/Next Definition, Declaration or Reference". You can find it in the View custom toolbar.
The default VS mouse back/forward buttons are attached to the "Browse Back / Next" buttons, not to the Navigate back/forward.
The VS plugin Mouse Navigation sets the mouse buttons to the Navigate back/forward. The only remaining problem is that because VS doesn't consider "click to go" as normal navigation, when you click to go to a definition and try to go back using the Ctrl+- or mouse back, you will not return to the last position, but to the previous "Normal navigation" position.
My suggestion to the plugin developer is to try to make VS consider "click to go" navigation as normal ones, completely solving this issue.
I just updated the Mouse Navigation extension to improve reliability of the commands. For some reason I never updated the extension to properly use the new IMouseProcessorProvider interface when I migrated from Visual Studio 2008 to Visual Studio 2010, and that bug never bothered me enough to revisit the extension until today.
You should find that version 2.1.0 behaves properly in Visual Studio 2010-2013.
The reason it only half works without the plug-in is because the mouse forward/back buttons do not map to navigate forward/back but rather some other navigation command (which never made sense to me as to what it was doing).
The way I solved this problem is to use my mouse software (SetPoint from Logitech in my case) to bind mouse forward/back to CTRL+SHIFT+- and CTRL+- respectively, while Visual Studio is in the foreground. This leaves my back/forward buttons working correctly in other applications (web browser) but while in Visual Studio I get the expected functionality.
Also, Visual Studio 2013 does seem to have better mouse back/forward control... though I haven't been using it long enough to be able to say whether the problem is truly fixed.

Is there a shortcut to open resharper menu?

When i type something and i want to open the little menu integrated in visual studio i press CTRL + .
Unfortunately this menu has very few options, and the things I need are in the Resharper menu (which is represented by the red lamp on left)
I want him to generate empty method..
The way I do it now is by clicking on the lamp, and then choosing the option i want (like generate method, add readonly to field, convert to lambda ... )
I can't find a way to open that menu otherwise and i'm sure that some keyboard shortcut must exist.
I know that the question seems dumb, but it will save me lots of time in the long run :)
Thank and have a good day.
The Shortcut for Quick Fix is Alt + Enter, which is the same than add reference with the Visual Studio scheme.
You can change it in Tools->Options->Environment->Keyboard, look for the command named ReSharper_QuickFix (I also heard it was renamed to ReSharper_AltEnter in some versions).
You want the Action List. To access it hit..
Alt + Enter
Here is the full list of R# commands
Here is more info on the Action List.
The below extension is for VS2012 will helps you to see the available shortcuts. Sometimes this will suites for your needs
http://visualstudiogallery.msdn.microsoft.com/f2964c90-68e2-4ddd-861a-bd66e5cd4434

Visual studio 2010 showing available events from code behind

In work and in home I have VS2010 installed. But in work I have this one cool feature. On the code behind file I have two drop downs. When I select some object in the left one lets say a testButton or Default2 (a page class), on the right one I get all available events for that object and when I select an event Visual Studio autogenerates it in my code-behind file. In my home VS I actually have does 2 drop downs but they work different. I have available objects on the right one but when I select for example the testButton it shows me the aspx page and points this button :/ Should I set sommething in the VS configuration or maybe in work I have some addon which I'm not aware of? Any ideas?
This is not a VB-exclusive feature.
What you're looking for is called a navigation bar. In Visual Studio options, open Text Editor → C# → General, and you'll see an option called Navigation Bar. Enable it and click OK.
However, I believe this bar works a bit differently in VB and in C#. In C#, it only lists the existing classes and their methods; in VB, it will list all your controls and their events even if those don't exist yet.
Ok I think I've found the answer. It seems that this feature is only available when the current file is in VB.Net. In my opinion this suks :/
You need to go the design view, in the Properties box, click on Events (lighting bolt) and double click on the events you want to code behind:
(source: byte.net)
#shin is correct, this is a VB.NET only feature; Microsoft only had feedback reports dating back to 2004 mentioning this feature, so I have opened a new bug request with Microsoft regarding this; and also added feedback to Visual Studios account on UserVoice...
https://connect.microsoft.com/VisualStudio/feedback/details/688175/vs2010-c-add-page-event-handlers-to-asp-net-using-codebehind-navigation-bar-the-same-way-as-in-vb-net
http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2244558-allow-c-to-add-event-handlers-to-classes-using-co
I encourage everyone who this issue effects to go and vote up & confirm this issue with them.
I dislike that C# doesn't provide such a useful time-saving function.
Up to Visual Studio 2010, only Vb.net has this feature: on code-behind page, the code panel upper-left drop down shows a control's name, and the right drop down shows this control's available events. When clicking this event we can get the code-block for this event. This feature is not available in C#.
Without above feature, we can still get a control's available events for both C# and Vb.net: We must select the control on the aspx page and choose the design view at the lower left corner, then on the Properties panel click the Event button (the lighting sign), then available actions will be shown, double-click the name of the event you want, the event code will be generated in code-behind.
It is most certainly is a VB only feature and has been reported on numerous occassions to Microsoft.
It is possible to see all the available Events in C# & Asp.net too, but not inside code window as possible in VB. But you can see all Events of any selected Control in its Property Window. Open Properties, then Click Events.
This and the feature to generate event handlers without having to switch to Design view for C# is finally coming in Visual Studio 2012. It was about time.
Even the 2012 feature is not enough. You still have to guess for Page level events (Init, PreRender, etc) and also files that haven't already been filled out for you like Global.asax, which depending on the template you started with may or may not have all the event handlers already specified.
Agreed that Event Handlers is one of the things VB has for years and years and years handled way better than C#. I can't count the number of times I've had to remind a fellow C# developer that some events do, in fact, exist.

Categories