Visual Studio - I want "Go To Definition" to open Object Browser, not "metadata" - visual-studio

In Visual Studio version 2002 and 2003 "Go To Definition" would find the selected type or member in the Object Browser. In 2005 onwards it opens a source window "generated from metadata" instead. How do I configure these newer versions to go to Object Browser? (In other words, I have the opposite problem to this one.)
Installing ReSharper makes this change, so I know it must be possible, but how do I do it without ReSharper?

As workaround you can create the following macro:
Sub GoToDefinitionUsingObjectBrowser()
DTE.ExecuteCommand("Edit.SelectCurrentWord")
DTE.ExecuteCommand("View.ObjectBrowser")
DTE.ExecuteCommand("View.ObjectBrowserSearch", DTE.ActiveDocument.Selection.Text)
End Sub
Then go to Tools/Options/Keyboard and assign hot key for this macro.
Tested in Visual Studio 2010.

I believe what re-sharper is doing is doing some hooks on that click event with the Visual Studio SDK I do not think there is any simple menu or location that can change that setting.
Instructions (pulled from CODE Magazine) edited down a bit to the part that pertainst to making the right click menus.
Creating a VSPackage
...The VS SDK installs a few more project
templates in Visual Studio, one of
them being the Visual Studio
Integration Package (Figure 1),
located under Other Project Types >
Extensibility on the New Project
dialog box.
After this standard dialog box, the
Visual Studio Integration Package
Wizard guides you through creating the
new package project:
Select a programming language. The wizard currently supports Visual
C++ and Visual C#. You can create or
pick a key file to sign the new
package.
Supply basic VSPackage information. The wizard prompts you
for details such as the company name,
VSPackage name, version, icon,
detailed information, and minimum
Visual Studio edition (such as
Professional or Enterprise) that the
package is designed to at this step.
This information goes into the Visual
Studio splash screen and About dialog
box and is also used to request a PLK
for the package (covered later).
Select VSPackage options. A package may add three types of
functionality: Menu Command, Tool
Window, and Custom Editor.
A menu command is a command added either to the menu
at the top of Visual Studio or
to a context menu (right-click).
When the wizard finishes its job, the
VS SDK adds core elements to the
solution to support the new package.
For instance, if you selected Tool
Window as part of the functionality
for the package, the project contains
a user control where you should place
the visual controls for the window.
The project also contains files for
.NET code to handle the functionality
that you will add to the package.
A CtcComponents folder contains
pseudo-C++ files (ctc files) where you
define things like menu, groups,
buttons, etc. Fortunately, Microsoft
is phasing out CTC files and replacing
them with a friendlier, XML-based VSCT
file format (which will ship in the
SDK for Visual Studio 2008).
The wizard creates a few other files
with .NET code required for the
plumbing of the package within Visual
Studio. Some of these files contain
classes that map the C++ constants to
.NET constants and other files contain
configuration information for the
package when it’s installed.

I know it has been a long time, but it appears, at least in newer versions of Visual Studio for the VB (Basic) language, to be an setting in the options.
Text Editor > Basic > Advanced
Under "Go to Definition".
I don't know why they don't have that for other languages...

Place the mouse cursor on the object you want to access on the object browser. Then, use the keyboard shortcut ctrl + alt + j, which will take you directly to the Object Browser window.

Related

Add ATL Simple Object in Visual Studio 2017

I am working with an old ATL/COM project in Visual Studio 2017.
In previous versions of Visual Studio you could select "Add Class" and then select the option "Add simple ATL object" to add a COM class to the project. This option appears to be completely missing in Visual Studio 2017.
Has the option been moved?
Have I missed an installation option?
Does Visual Studio fail to recognize my project as an ATL project? (It was created with a much older version.)
Or is this the end of the road for ATL?
I'm not sure whether this an answer, but it is too much for a comment and more than just an edit to the question.
I have tested on two systems, with
Visual Studio Community 2017, Version 15.1
Visual Studio Professional 2017, Version 15.3.2
and I believe that the functionality has changed between these two versions. I think it is unlikely to be a difference between the Community and Professional versions.
In both cases I created a new ATL project and tried three ways to add a class:
Add class... from the context menu in the Class View
Add class... from the context menu in the Solution Explorer
Add New Item... from the context menu in the Solution Explorer
With version 15.1, Add Class opens the following dialog, from which I can add an ATL Simple Object.
With version 15.3.2, Add Class opens the following dialog, without any option for an ATL Simple Object.
However, with version 15.3.2, Add New Item opens the following dialog, with a new option to create an ATL Simple Object, which was previously not available in this dialog.
So, it seems that the functionality has been moved. Curiously, it is no longer available in the Class View (which in my opinion is a mistake).
This problem is caused by changes in the project template and code wizard in version 15.3 of Visual Studio 2017.
The operation procedure has changed between version 15.2 or earlier and version 15.3 or later.
The blog article that explained this change is as follows.
Changes to Project Templates and Code Wizards in 15.3
Although it is described as an item in the release notes, there are few people who are watching, and details on how the actual is going on is unknown.
Visual Studio 2017 version 15.3 Release Notes
C++ Language Services
Project and Code Wizard
•We have rewritten several project and code wizards in the signature dialogue style.
•Add Class launches the Add Class wizard directly. All of the other items that were previously here are available under "Add > New Item".
•Win32 projects are under the Windows Desktop category in the New Project dialog.
•The Windows Console and Desktop Application templates now create the projects without displaying a wizard. There's a new Windows Desktop Wizard under the same category that displays the same options as before.
My experience with Visual Studio 2015 version 15.9.2 is that I had to uncheck Security Development Lifecycle (SDL) checks when I added an ATL Project, otherwise when I add the Simple ATL Object I get a messagebox with the error "did not find a .idl file in project name of my project".

Visual Studio files association in Windows

In Windows Explorer when I double-click on any Visual Studio file (*.cs, *.csproj, etc.), it's opening an old version of VS instead of the latest one (VS 2017). And VS has associations with too many file types.
How can I change the default Visual Studio (for all those files that VS can handle)?
There is a similar old question about Visual Studio 2008 (Move file associations from Visual Studio 2005 to 2008) but the solution in there doesn't work anymore (there is no "Restore File Associations" button on the settings of Visual Studio 2017).
Each version of Visual Studio registers itself in the Set Default Programs panel of the Control Panel.
Go to Control Panel\Programs\Default Programs
Then choose Set Default Programs:
In there you can simply choose the Visual studio version of your choice and then click the button Set this program as default in order to associate every file type that VS handles.
Or you might prefer to click the button Choose defaults for this program to review the current associations of those file types and change only the ones you want.
Yet another in a long list of previously working-just-fine things which Microsoft have managed totally #$#%# up. If I try to change defaults the 'right' way I get this kind of thing:
i.e. completely ignored. The only way I've managed to solve it is by removing the file association entirely through the registry. Let's take .asm as an example:
Open Registry Editor / "regedit.exe"
Navigate to HKEY_CLASSES_ROOT\.asm\OpenWithProgIds
Delete any Visual Studio values you see
From there, you can (finally) open files with whatever you choose instead of having the association clamped to Visual Studio:
For the record, I believe this to be a problem with Windows 10. Not with Visual Studio. See: https://answers.microsoft.com/en-us/windows/forum/windows_10-files/cant-change-default-programs-in-windows-10/229fc3a9-25c9-433b-a333-5806bc5090db
On the file you will always open with vs17, click right and choose open with and there choose another app. On win10 it pop out a dialog with some proposals. If vs17 is there, choose your favorite and activate the always open with. then ok and your done.

Refactor menu missing from Visual Studio 2015

I am having trouble finding the right-click context menu in Visual Studio 2015. I know that nothing is wrong with my project or the file I am working. I can find the right-click context refactor menu in Visual Studio 2013. However, in Visual Studio 2015 there isn't a refactor context menu in the right-click context menu.
Where did it go? How do I get it back?
Your suggestion cannot include menu Edit → Refactor.
I have tried to reset my Visual Studio settings back to default using menu Tools → Import and Export Settings and that didn't bring the menu back either.
Some of the refactoring tools have been relocated or are at least accessible in a different manner than they were previously.
Using the extract method refactor as an example, you can still use this function; it is just not done the same as before:
Right click
Quick actions
Click extract Method
I think they've changed it to feel more "ReSharper"ey. All of the functionality should still be there however.
Here's more information on refactoring in Visual Studio 2015 - hopefully this helps! Refactoring (C#)
You no longer need to access the refactoring using the mouse right click.
It is recommended that you use the keyboard shortcut keys within Visual Studio.
For all possible shortcut keys, see Default Keyboard Shortcuts in Visual Studio, Refactor.
You might need to build the project to get it to work.
See Code Editing ASP.NET Web Forms in Visual Studio 2013 | Microsoft Docs. (If it is missing then the point is that I am using an example provided by Microsoft.). In Refactoring and Renaming see To extract a method in a C# page. When I follow the instructions I cannot find the feature to extract the code to a method. When I tried the Edit menu it said I did not have valid code. Then I built the project and the feature to extract the code was available and worked.
If you change the name of the object you are refactoring, the light bulb then appears to the left which asks if you wish to change the name of the object (i.e. refactor) or generate a new constructor for the new named object.
Ctrl + . is the shortcut key for extracting a method in Visual Studio 2015 and onward.
Ctrl+M, R does not work anymore in new versions.

Where does Visual Studio save code blocks that are dragged on the Toolbox

You can drag and drop code blocks from the Codeeditor to the Toolbox of VisualStudio, but where does Visual Studio save those code blocks.
Are they globally available (for other projects) or only available in the solution/project they are dragged?
Any code blocks that you drag to the Toolbox are stored in your Visual Studio settings file. The default path to that file is under your "My Documents" folder:
..\My Documents\Visual Studio 2010\Settings\CurrentSettings.vssettings
but of course, the exact location can be specified from the Options dialog in Visual Studio.
They are globally available for all projects in the applicable language. For example, if you create a code snippet in a C# project, it will be available for any C# projects that you create. However, it will not be available in a VB.NET project.
Also note that you can rename the individual snippets by right-clicking on them in the Toolbox, and selecting "Rename Item" from the context menu.
But there is a better and much more powerful way to manage code snippets rather than dragging them to your Toolbox. See this article on Sara Ford's blog (a great resource for tips and tricks relating to VS).

How do I install component designers in Visual Studio?

If I add [DesignerAttribute("somenamespace.mycomponentdesigner, mydesignerlibrary.dll")] to the top of a class and then install that class into the tool palette, how do I then get the mydesignerlibrary.dll installed into VS so that VS can find the designer?
This page describes the process you'd need to follow, but effectively you'd need to:
Copy the designer assembly into a folder and configure Visual Studio to search that path by creating a registry entry under HKLM\Software\Microsoft\.NETFramework\<version>\AssemblyFoldersEx, where <version> is the lowest framework version your designer assembly is compatible with.
Note that your control projects target the earliest version of the Framework that your control will support. This is referred to as the minimum Framework version. A restart of Visual Studio is needed before the new search path can take effect.
Copy the runtime assembly into another folder; add your custom controls to Toolbox. This can be done either manually through “Choose Items…” dialog or programmatically with a Toolbox installation package.
You can do it using Toolbox in the Visual Studio.
In the toolbox window, click right button on the mouse and choose menu 'Choose Items', then you use 'Browse' button for adding your dll component, then you can see it in the toolbox window in the Advanced Section(in the bottom).

Resources