Reputation: 33589
I'm reading this article on integrating cppcheck into VS: http://www.codeproject.com/Tips/472065/Poor-Man-s-Visual-Studio-Cppcheck-Integration
I want running the check upon saving file, which is covered in the article. But, the article refers to Macros IDE, which, apparently, was taken out of VS2012. Is there any other way to do it?
Upvotes: 3
Views: 6071
Reputation: 194
This Visual Studio extension can do what you want since version 1.15.
Upvotes: 0
Reputation: 10154
Using Mark Hall's answer, I installed and used Visual Commander to do something similar. This is my extension, that runs the first external tool when files in my project ("my-project") are saved:
using EnvDTE;
using EnvDTE80;
public class E : VisualCommanderExt.IExtension
{
public void SetSite(EnvDTE80.DTE2 DTE_, Microsoft.VisualStudio.Shell.Package package)
{
DTE = DTE_;
events = DTE.Events;
documentEvents = events.DocumentEvents;
documentEvents.DocumentSaved += OnDocumentSaved;
}
public void Close()
{
documentEvents.DocumentSaved -= OnDocumentSaved;
}
private void OnDocumentSaved(EnvDTE.Document doc)
{
if(doc.Path.ToLower().Contains("my-project")) DTE.ExecuteCommand("Tools.ExternalCommand1");
}
private EnvDTE80.DTE2 DTE;
private EnvDTE.Events events;
private EnvDTE.DocumentEvents documentEvents;
}
Upvotes: 3
Reputation: 54532
There is also a free Tool available called Visual Commander
available in the Visual Studio Gallery, more information here.
from first link:
Automate repetitive tasks in Visual Studio IDE. Reuse your existing Visual Studio macros or create new commands and extensions in C# or VB.
A Visual Commander command is a class written in C# or VB implementing the Run method. It has full access to the Visual Studio automation model and .NET framework. Code of an existing Visual Studio macro from previous versions of Visual Studio can be just pasted in the Run subroutine of a new VB command.
Upvotes: 2
Reputation: 34489
You could almost certainly write a visual studio extension to do something along these lines. I wrote an extension VSFileNav which hooks up to project events to listen for items being removed/added etc. I imagine a slightly different event on a project (or possibly even some document window) would allow you to do such a thing.
DocumentEventClass.DocumentSaved
DTE.ActiveDocument
Upvotes: 1