Introduction

As good as Visual Studio .NET is, I still miss some features in it. But MS knew that they couldn't fulfill every wish so they provided a way to write addins. That's what I've done. Sure, most of the functions in my Tools could also be done with macros, but I wanted them all packed together with an installer.

Tools

Run Doxygen

Insert Doxygen comments

Build Solution stats

Dependency Graph

Inheritance Graph

Swap .h<->.cpp

Colorize

} End of

#region/#endregion for c++

Search the web

Run Doxygen

This command first pops up a dialog box in which you can configure the output Doxygen should produce. For those who don't know Doxygen: it's a free tool to generate source documentations. It can produce documentation in different formats like html and even windows help format! See http://www.doxygen.org/ for details. Since the dialog box doesn't offer all possible settings for doxygen, you can always edit the file Doxyfile.cfg manually which is created the first time you run it. All settings in that file override the settings you enter in the dialog box.

If you set Doxygen to generate html output, the resulting index.html is opened inside the IDE. A winhelp output (index.chm) will be opened outside the IDE.

The command available from the Tools menu builds the documentation for the whole solution. If you don't want that for example if you have several third party projects in your solution then you can build the documentation also for single projects. To do that the KingsTools add a command to the right click menu in the solution explorer.

If you want to update Doxygen to a newer version (as soon as one is released) simply overwrite the doxygen.exe in the installation directory. The same applies to the dot.exe.

TODO: find a way to integrate the generated windows help file into VS help.

Insert Doxygen comments

Doxygen needs comments that follow certain conventions to build documentation from. This part of the tools inserts them for you. Either from the right click menu in the code editor window or from the submenu under Tools->Kings Tools. Just place the caret over a method or class header. The inserted comment for a method or function would look like this:

You now have to simply insert a description in the second comment line and descriptions for each parameter of the function/method. And of course a description of the return value.

You can customize the function comments by editing the files "functionheadertop.txt", "functionparams.txt" and "functionheaderbottom.txt". Please read the comments inside those files on how to do that. If you don't want to change the function comments for all your projects then you can place any of those files into your project directory (that way it will be used for your project) or inside the folder of your source files (that way it will be used only for the files inside that specific folder).

The '\ingroup projectname' means that the class is inside the project 'projectname'. That statement helps Doxygen to group classes together. Insert the description of the class right after that statement. If you want to include pictures to illustrate the class, use '\image html "picture.jpg"'. For more helpful tags you can use please check out the Doxygen website. The '\par requirements' section you have to modify yourself to fit the truth of your class. It's not necessary for Doxygen, but I found it very useful to give that information inside a class documentation. The name after the '\author' tag is the currently logged in user. Maybe you want to change that too to include an email address.

You can customize the class comments by editing the file "classheader.txt" Please read the comments inside that file on how to do that. If you don't want to change the class comments for all your projects then you can place that files into your project directory (that way it will be used for your project) or inside the folder of your source files (that way it will be used only for the files inside that specific folder).

The last few tags should be self-explanatory. Under the line '\version' I usually insert short descriptions of what changed between versions.

Build Solution stats

This is a simple line counter. It counts all the lines of all files in your solution, grouped by projects. The generated html file with the counted lines (code, comments, empty) is then opened in the IDE. Since I haven't found a way to add a file directly to a solution and not to a project the file is just opened for view in the IDE.

Dependency and Inheritance graph

These two commands build graphs of the class relations in your solution. See my previous article about this. The difference to my old tool is that it now generates graphs for all projects in the solution and puts all the graphs in one single html page.

Swap .h<->.cpp

This is something a simple macro could also do: it swaps between header and code files. For better accessibility it also is on the right click menu of the code editor. Really nothing special but it can be useful sometimes.

Colorize

This tool goes through all files of the current solution and looks for class, function and macronames. It then writes them to a usertype.dat file, makes the IDE to read that file and deletes it again. After you run this tool, all class, function and macronames of your solution appear colored in the code editor. Default color is the same color as normal keywords, but you can change that under Tools->Options, in the Options dialog select Environment->Fonts and Colors.

If you don't want the colors anymore, just run the command 'disable coloring' and everything will be in normal colors again. I didn't want to overwrite some possible usertype.dat file already created by some user so the tool simply creates a temporary usertype.dat file instead. If you want to have the colors again the next time the IDE starts, you either have to rerun the command (doesn't take very long to execute) or change the code of the tool yourself.

} End of

Have you ever wrote a bunch of code which looked like this:

Ok, I admit this isn't a very good style of programming, but sometimes it can't be avoided. And in those cases the code is horrible to read because you don't know which closing brace belongs to which opening statement without scrolling or using the macro 'Edit.GotoBrace' several times. This tool provides a function which inserts comments after the closing brace automatically. The code snippet above would look like this:

Comments are only inserted for closing braces of if, while, for and switch statements.

If you don't want to insert comments automatically while editing, you can turn off this function. If you just don't want those comments at specific places you have to move the caret either upwards (instead of downwards which happens if you press enter) or click with the mouse so that the caret doesn't go to the line below the closing brace. Comments are also not inserted when the opening brace is less than two lines above.

#region/#endregion for C++

VS.NET introduced to possibility to outline portions of text in the code editor. That's a very useful feature wthat helps navigating through big bunches of code. But the outlined sections are not saved between sessions. VB and C# provide keywords to outline sections. In VB its '#Region' and '#End Region', in C# its '#region' and '#endregion'. Only for C++ MS didn't provide such keywords (at least I haven't found them yet). With this tool you can now enable that feature for C++ too. To prevent compiler errors for those who have not installed this tool I used '//#region' and '//#endregion' as the keywords. With the comment lines before the compiler won't complain. Use those keywords like this:

Whenever you open a document with such keywords the tool will automatically create outlining sections. The section are also created when you type the '//#endregion' keyword and a matching '//#region' is found. As you can see, you can easily nest the sections. The code above would then look like this:

This function can't be deactivated. If you don't want it, simply don't use those keywords :)

Search the web

These two small addons perform a simple web site search either in the google groups or on CP. Select a piece of text in the code editor, right click to pop up the menu and then select where to search for the selected text. That's all. The search results will be opened inside VS.NET.

Install

To install the tools, just double-click the *.msi file and follow the instructions. If the tools are not automatically activated the next time you start the IDE, then please activate them under Tools->Add-In Manager. Make sure you select both the addin and the box 'startup'.

All additional files needed for the tools are also packed in the installer, including Doxygen and the dot files. So you don't have to grab them separately from the web.

Source

Full source code is provided with these tools. The addin is written in VB.NET cause first there was just one simple tool that I wanted immediately - and VB is good enough for that. Then the tool grew and I added more functions. So the code is surely not the best example for good programming (no plan, no structure -> chaos). But maybe it might still be of interest for those who want to write their own addins. It shows a way to create submenus and how to add a toolbar.

Revision History

24.06.03

fixed bug in Doxygen part: the path to the binaries weren't enclosed in ""

made necessary changes to make the addin work with VS.NET2003 (projectitems are now recursive!)

updated the Doxygen binaries to the newest version

the dialogs are now centered to the IDE

18.04.03

fixed some bugs in the }EndOf function

added template files for doxygen comments

fixed bug in the graph functions if the solution contained "misc" files

Doxygen 1.3 is now included

removed the toolbar - it slowed the editor down

for most commands disabled the check for project type (C++, C#, VB, ...) - if you use a function for a project type for what it isn't designed it just won't work...

04.10.02

enabled }EndOf and the solution statistics also for C# projects

21.9.02

fixed a bug in the }EndOf tool

fixed bug where Doxygen couldn't be started when a file was in the Solution->Misc folder

added possibility to run Doxygen for single projects (right click menu in solution explorer)

included newest Doxygen and Dot version

added a proper uninstaller. The uninstaller now deletes all added commands.

7.9.02

fixed a bug reported by Darren Schroeder

8.8.02

removed forgotten test code which caused annoying behaviour

made sure that for WinHelp output (Doxygen) also html output is selected

10.8.02

fixed a bug reported by Jeff Combs: now the addin is only loaded when the IDE is started (the IDE is NOT started when devenv is called with /build, /clean or /deploy command line switches!)

12.8.02

Run Doxygen now includes not only project directories but all directories of the project files.

The Toolbar can now be altered and the altered state is saved by the IDE

Uninstalling now works better: the toolbar is gone after the second start of the IDE after uninstalling without modifying the source.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

I want to give a big thank-you to Florian George for providing the solution for language incompatibility.

I've just updated the KingsTools2008/2010 setup files with the fixes that Florian George suggested.
(KingsTools 2003/2005 versions does not contain the lines with "Text Edit," so they are same as previous)

What I have done is I just commented out the lines which contain "Text Editor" for KingsTools 2008 and 2010 version and recompiled them. (so both of English version and other language version can be used together with single setup file)

It will lose the keyboard short-cuts by commenting those lines out, but I think not using short-cut is better than impossible to use at all due to language incompatibility.

I never have used "inserting doxygen comment" functionality, and after your comment, I tested out with other versions (VS2003/2005/2008/2010) of Kings Tools also.
And I found out that all versions of KingsTools(2003/2005/2008/2010) somehow corrupting Visual Studio's Text Editor.
Corruption of Visual Studio's Text Editor by 2003/2005/2008 versions of KingsTools was not severe (It just corrupts some indentation functionality of Visual Studio's Text Editor), however in VS 2010, it seems it's causing severe problem such as "Enter keys malfunctioning," or "Inserting doxygen comment" outputs weird text.

After some debugging, I found out that the problem was from the original source of KingsTools, and the location of the bug was at "ToolsConnect.vb::Tools:: textEditorEvents_LineChanged"
So if you comment out below two lines of code like below,

the Kings Tools no longer corrupts the VS's Text Editor, and "Inserting doxygen comments" works fine for all versions of Kings Tools. I am not sure if this will corrupt other functionality of KingsTools. (I didn't have enough time to test all functionalities out.)

If you change the installer to install by default for all users instead of the current user, this error couldn't accidentally happen to users. I assume this can be predefined when building the installer.msi?

Yes, after your post, I have looked at the properties, and there was property call "InstallAllUsers," and it seems it was set as "False" as default. I have changed it to "True" and recompiled the setup file (msi). It has been updated to download page. So now, if you re-download the setup file, and when you run the installer, Install for "Everyone" will be the default option.

I wanted to use Kings Tools but ran into the issue of getting the following error message after the second start of Visual Studio with Kings Tools enabled:

The Add-in "Kings Tools2008" could not be loaded or has triggered an Exception.
Do you want to remove this Add-In?
If you click "Yes", you have to install the Add-In again if you want to use it again.
Error Message: Wrong Parameter
Error Code: 80070057

Today, I was able to set up Visual Studio to debug Kings Tools based on the source Green Chili posted here on August 3rd 2008.

As Woong Gyu La already suggested, the error is caused by a localization incompatibilty.

In the ToolsConnect.vbs, there are several calls similar to this:

doxyruncom.Bindings = "Text Editor::ctrl+d, ctrl+r"

When debugging, it showed that this line will cause the Error Message.

Hi Ryan, I double checked with a german version of Visual Studio 2008 and you are right. Modifiers (Ctrl, Alt, Shift) must be specified in english. However, the scope (Global, Text Editor, etc) must be specified using the localized name. For example it's "Text Editor" in english and "Text-Editor" in german (with a dash in the middle).
Can you think of any workaround that would do the job? I don't try to win a beauty contest, it should just get the job right.

So that's the solution. Adding that tiny dash to make all those lines look like this will fix the problem (for me on a German System):

doxyruncom.Bindings = "Text-Editor::ctrl+d, ctrl+r"

I don't have my own persistent webspace but I can upload the compiled exe/msi to a filehoster if needed.

First of all, thank you, Steve King, for providing such a great tool.
I am using multiple versions of Visual Studio2003/2005/2008/2010 concurrently, and I wished to use KingsTool in all versions of Visual Studio.
Therefore, I changed the code a little so Kings Tool can support multiple versions of Visual Studio, and also multiple versions of Kings Tool2003/2005/2008/2010 can be installed all together. And I thought it would be better to share with everyone.

p.s.
I am using Visual Studio 2003/2005/2008/2010 on Windows7 32bit.
I am using English versions for Visual Studios and also Windows.
It might not be compatible with other (language) versions of Visual Studio/Windows(32bit/64bit).
I don't have environment to test on other versions of Visual Studio and Windows instead of my environment, so I won't be able to help you if you are having compatibility issues. So please use this on your own risk.

p.s.2
I have updated the doxygen.exe(1.8.0), neato.exe(2.28.0), dot.exe(2.28.0) to up to date. If you have a problem, the solutions can be...After installation, in your installed directory,
- Replace the "doxygen.exe" with the version you prefer.
- Either remove original "neato.exe," and rename the "old_neato.exe" to "neato.exe", or use your preferred version of "neato.exe" with the dependencies.
- Either remove original "dot.exe," and rename the "old_dot.exe" to "dot.exe", or use your preferred version of "dot.exe" with the dependencies.

I assume you are using German language version of Visual Studio. As I said in my post, for different language version of Visual Studio, compatibility issue might occur. I think I had similar problem with Korean version of Visual Studio long time ago, so it seems like King's Tools are only compatible with English version only. Sadly I could not find the solution for that, so I am only using English version of Visual Studios. (I don't have Korean version of Visual Studio anymore anyway)

To solve that issue, what I tried at that time was,
- re-compiling with Korean version of Visual studio, but didn't help. (the same problem persisted)

Has anyone tried to get KingsTools to work in VS2010? If so, I would appreciate any help I can get.
...
Nevermind, I've ported the two features that I use to VS2010 in a separate addin.

I fixed problems in the swap h/cpp feature so it works for all the location combinations that failed in KingsTools.

I fixed a whole bunch of issues in the insert doxygen comments - it now correctly handles constructors/destructors, correctly filters out pointers and comments for parameter lists, can ignore dllexport declarations, struct support, member variable support.

Guys, I used to have this beautiful add-in in VS2005 and VS2008 on WinXP and it worked great.
However, I migrated to win7 x64 and it sucks now. The addin is just not mentioned in the Addin list of the studio. Has anybody an idea? I compiled the newest source for VS2008 on my win7 x64 PC but it didn't change anything.

I had similar problem on Windows7 32bit, and have changed little bit of code(Seemed like there was issue with naming convention of addin features. Not sure exactly what it was). It seems like it works on Windows7 32bit Visual Studio 2008 now, but have not test on 64bit. I think it's worth giving a try.

p.s. After the installation, I think you should replace doxygen.exe in installed directory with 64bit version of doxygen.exe

I often use the shortcut Ctrl-M-O in order to collapse all the code of a file. Unfortunately, after installing Kings Tools, I found that there is a side effect. Now, hitting enter puts the cursor on the original line, above the new line. This is incredibly annoying. I like this tool but can't live with this bug.

I never made the association with King's Tools, but yes I get this every once in a while (even cursor-ing down a line will throw it back to the line I just cursor-ed from, unless I'm at the left most position). Only fix I've found is restarting Visual Studio. I'll have to investigate further for other ways to get it to stop doing this. Drives me absolutely insane when it starts happening, and I hate having to restart to fix it.