Given a visual studio command, such as "Build.BuildSolution", how do I get a display name for it?
When a command is invoked, I'm displaying a window with the command name and the shortcut. This is actually a ReSharper plugin, and it displays the ReSharper commands just fine - descriptive text, shortcuts and everything. I'm also getting notified of invoked VS commands, and I can get the keyboard shortcuts, but I don't know how to get a display name for it. I get the VS command name, such as "Build.BuildSolution". From this I can get the DTE's Command
object, which then also gives me the keyboard shortcut bindings. But I can't find the display name.
Ideally, I'd like to display it in the same way that it's displayed in the Quick Launch search box, with the owning menu, like this: "Build → Build Solution". However, this information seems to come from a private COM interface, and I don't see how to get this information via the accessible VS interfaces.
The EnvDTE.Command interface of the automation model doesn't provide a Caption property (an oversight).
As a workaround you can add the command to a commandbar so that you get a CommandBarControl that you can cast to a CommandBarButton, get the CommandBarButton.Caption property and remove the commandBarControl. If you use the commandbar of a menu (rather than of a toolbar) the user won't notice the button appear and disappear.