How can i extend the menu bar of visual studio code by adding my own menu? - menu

I would like to develop a debugger extension in visual studio code so that new menu in the menu bar is created when the debugger is launched for my c code.
Is it possible to create such a plugin extension in visual studio code?
Is it possible to extend menu bar at all in visual studio code ?

You can contribute commands to several menus in vscode. Here is a list to which parts you can contribute your command items.
For example, if you want to add an item to the debug toolbar, you can do so by adding it to the related menu:
{
"contributes": {
"menus": {
"debug/toolBar": [
{
"command": "yourExtension.yourCommand",
"when": "inDebugMode",
}
]
}
}
}
Note, that you have to register your command in your extension.ts/extension.js and and also in your package.json first, e.g.:
extension.ts:
vscode.commands.registerCommand('yourExtension.yourCommand', () => {
console.log("Hello World");
});
and in your package.json
"commands": [
{
"command": "yourExtension.yourCommand",
"title": "Hello World"
}
]
If you want to specify conditions, when the command should be shown, you can do so by adding when conditions. In the given example, the item is only shown, while debugMode is active.
Here is a list of possible arguments in your when clause:
link

Related

Visual Studio 2022 (C++) "Add Event Handler..." generating bad names

I am working on an MFC application with a Ribbon Bar and am experiencing difficulty adding event handlers for new controls from the Ribbon Designer. This was working fine the last time I edited the Ribbon roughly 2 months ago. For instance, adding a new button ("Test Function") I change the resource ID to "ID_BUTTON_TESTFUNC" then right click the button and select "Add Event Handler...". The dialog comes up with a Function Name "On18" rather than "OnButtonTestfunc" and adds a message map and function that don't respond to the button.
BEGIN_MESSAGE_MAP(CMFCApplication2View, CView)
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CMFCApplication2View::OnFilePrintPreview)
ON_WM_CONTEXTMENU()
ON_WM_RBUTTONUP()
ON_COMMAND(18, &CMFCApplication2View::On18)
...
void CMFCApplication2View::On18()
{
}
I have tried the following, expecting (hoping) VS would return to normal behavior:
The same process on 2 computers with the same results
Updating Visual Studio to 17.4.4 (from 17.4.3)
Repairing Visual Studio
Creating a new blank MFC application - same results
In Account Options: UNchecking "Syncronize Visual Studio settings across devices and installs..."
Clearing all Visual Studio settings (Tools, Import Export Settings, Reset all settings)
Changed IDE Tools menu -> Options -> Text Editor -> C/C++ -> Advanced -> Rescan Solution Interval = 0 per Alen Wesker post on: Can't add event handler in visual studio 2010 (mfc project)
Manually adding the message map entry, function declaration and function definition works and responds to the button press:
MFCApplication2View.h:
afx_msg void OnButtonTestfunc();
MFCApplication2View.cpp:
ON_COMMAND(ID_BUTTON_TESTFUNC, &CMFCApplication2View::OnButtonTestfunc)
...
void CMFCApplication2View::OnButtonTestfunc()
{
//my code here
}
But I am concerned about what else might be corrupted in VS. Any thoughts would be very welcome.
Microsoft indicates that this is an issue and had been previously fixed in version 17.5 Preview 2. See: https://developercommunity.visualstudio.com/t/MFC-Add-Event-Handler-Dialog--not-prope/10211759.

How to add not html syntax snippet in Sublime with Emmet?

The old Emmet work fined, but now my Sublime has upgraded Emmet plugin to the latest version automatically, and the following snippets doesn't work anymore...
The latest Emmet can only accept HTML syntax on custom snippets
These snippets my seems odd, since these are my custom tag which will be convert into php code in Template Engine, so the code aren't HTML syntax.
For instance, when I type p1 and press tab, I want it give me <!--{if }-->:
{
"config": {
// Configure snippets/options for HTML syntax only.
// For a list of supported syntaxes, check out keys of `syntax_scopes`
// dictionary of `Emmet.sublime-settings`
"html": {
"snippets": {
"p1": "<!--{if }-->",
"l1": "<!--{/if}-->",
"p2": "<!--{loop }-->",
"l2": "<!--{/loop}-->",
"p3": "<!--{eval }-->",
"p4": "<!--{block }-->",
"l4": "<!--{/block}-->",
"else": "<!--{else}-->",
"elif": "<!--{elseif }-->"
}
}
}
}
New Emmet accepts snippet values as Emmet abbreviations (yep, a recursion) and plays better with native ST snippets. Thus, you should either add your snippets as native in ST, or if you still want to use Emmet for such snippets, you should write them as valid Emmet abbreviation. To output arbitrary text in Emmet abbreviation, you should write it as text node, e.g. wrap with { and }.
So, your snippet should look like this:
"p1": "{<!--{if }-->}"

How does "Save as Live Template..." work in Android Studio?

I select the following code:
//This is for debugging Live Template
try {
} catch (Exception ex) {
}
then click Tools > Save as Live Template...
Nothing happens. Could anyone offer a tip on how to select a snippet and save as a live template?
https://youtrack.jetbrains.com/issue/IDEA-174644 -- this looks like your case.
It's fixed for 172/173.xxx branches -- no idea what Android Studio version it would be.
Workaround for now -- make selection with no leading whitespace .. and edit created Live Template after if required.

Is it possible to add solution-specific tools to Visual Studio 2012

Can you do something to the .SLN/.CSPROJ files in VS2012 so that when you right-click the solution/project in the Solution Explorer, there would be a new item on the context-menu which runs a tool you specify?
I know you can add custom entries to the Tools menu, but in this case the tools are specific to that particular solution.
You can add buttons to Solution context menu like below from an Add-In:
Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["Solution"];
try
{
//Add a command to the Commands collection:
Command command = commands.AddNamedCommand2(_addInInstance, "MyAddinMenuBar", "MyAddinMenuBar", "Executes the command for MyAddinMenuBar", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);
//Add a control for the command to the solution context menu:
if (command != null)
{
command.AddControl(menuBarCommandBar, 1);
}
}
catch (System.ArgumentException)
{
// safely ignore the exception.
}
The specification of tools for different solutions should be handled internally by your Add-In. You can extract the full path of a solution (from _applicationObject.Solution.FullName) also the properties of contained projects (from _applicationObject.Solution.Projects ).
If you are using a VSPackage you should define a vsct file to add the command and the menu item.

ReSharper doesn't see my Machine.Specification tests

I'm having a problem getting ReSharper to see the Machine.Specification "tests" I've written.
The specs run in the ConsoleRunner from mSpec. When I try to "Run Unit Tests" in ReSharper, I get a message: "No tests found in file." The specs don't show the test markers.
I created a folder in the ReSharper /bin/ folder and put the proper .dlls there. The mSpec plug in appears in ReSharper.
What might I be missing?
Also, I'm using xUnit.NET if that makes a difference.
The ReSharper runner do not take nested context classes into account. Instead of nesting context classes:
namespace SomeNamespace
{
public class Specs
{
public class when_something_happens
{
Because of = () => {};
It should_do_something = () => {};
}
}
}
Author contexts that are not nested, i.e. root classes inside a namespace:
namespace SomeNamespace
{
public class when_something_happens
{
Because of = () => {};
It should_do_something = () => {};
}
}
ReSharper's green-and-yellow test icons do appear if all of the conditions are met:
class is public
class is not abstract
class is not nested
has >= 1 specification field (It),
or has >= 1 behavior field
(Behaves_like<>)
In order to have good integration of MSpec with Visual Studio and ReSharper install MSpec using installer which is available here: http://marcinobel.com/index.php/mspec-bdd-installer/
Had also the same problem with "No tests found in file" when try to use ReSharper and XUnit.net together. However I could see my tests in Test Explorer window and was able to run them from there.

Resources