Skip to main content

Calling Built-in, or Add-in functionality from another Visual Studio Add-in or Macro

As a part of the Visual Studio add-in I'm creating for code formatting I'm calling 2 built-in functions.

  • "Edit.RemoveAndSort"
  • "Edit.FormatDocument"

These 2 are functions I use all the time as I code to keep things neat and tidy. I've found it great to automate these within my addin so that I don't have to worry quite so much about accidentally messing up indents and such.

What I got to thinking though, was what if I could automate calls outside of built-in functionality? One of the main purposes of the add-in is to appease StyleCop...not that it's necessary. But, what about after doing a full format, I call stylecop on the individual document? Or if I run over the entire solution, telling stylecop to run over everything? And what about other add-ins that have been mentioned previously such as GhostDoc?

After asking a question about such a thing on the MSDN forums I actually found that it was a lot easier than I expected. An MSDN Moderator, Wesley Yao, pointed me to this post on 'Dr. eX's Blog' about the EnableVSIPLogging registry entry.

Using this and finding the canonical name, I can call any menu item functionality installed into Visual Studio's menu system.

  1.     EnvDTE.Window ideWindow = projectItem.Open(Constants.vsViewKindCode);
  2.     ideWindow.Activate();
  3.     ideWindow.SetFocus();
  4.     ideWindow.DTE.ExecuteCommand("Tools.RunStyleCop", String.Empty);

I'll be toying with this a bit to see about hooking into more functionality in order to make a well-rounded code-formatting solution.

I've still got a ways to go before doing any sort of release on the add-in. I need to look into mocking some of the visual studio interfaces for unit tests and I need to look into separating some of the functionality out into a class library so I can more easily backport it to 2005 and port it to 2010. I also need to research into VSPackage which I believe doesn't require any sort of port. I also need to do a UI for choosing which tasks to enable.


search Bhulekh UP land

search Bhulekh UP land records online

Calling Built-in

These two functions have greater functionalities in coding. I am trying to know about it in the internet and your post is bestessays good in explaining about their functionalities in clearly manner.

Uber Driver Signin

Uber driver sign-on bonus when you use our most current Uber driver invite code at signup. Uber Driver Signin

Very nice and helpful

Very nice and helpful information has
aussie essays been given in this article.

Email marketing

I have very much interested in knowing new things in coding. I have always followed many websites for learning new topics. Your posted information is really useful for me to know more about functions.

because I could not stop for death

These two functions have the

These two functions have the great functionality. I have used this in coding and execute the program. This post really help me to get an idea about these to function's usage.

moonlight sonata

24option is a popular

24option is a popular brokerage firm in the Binary Options Market that has been operating for four years now and has several users around. Many users question whether 24option is legit or just another fake system. 24option reviews

The MSBSHSE will officially

The MSBSHSE will officially declare the Maharashtra SSC Result 2017 on the web portal. entrance test results

The information in the 70-461

The information in the 70-461 braindumps exam dumps is updated and in line with the latest syllabus. You never find Examsleader’s IT braindumps deficient of anything.

While working with codes, it

While working with codes, it is really a tough task. I remembered my college days when I used to take help from assignment master for help in my coding subjects.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <asp>, <c>, <cpp>, <cs>, <css>, <drupal5>, <drupal6>, <html4strict>, <java>, <javascript>, <jquery>, <php>, <python>, <ruby>, <sql>, <xml>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.