Chapter 7. Extending the Visual Studio IDE


In this chapter:

 

Extending with Macros

357

Visual Studio Add-Ins

370

Summary

384


As Microsoft Visual Studio has progressed over the years, more and more of a developer's day is spent inside one window frame. In the ancient past of Microsoft Visual C++ 6.0, many of us used only basic editing, building, and debugging. For bug tracking, design diagrams, and advanced editing, we were using other tools. With the advent of Visual Studio 2005, it's almost possible to spend your entire working day inside the same application. From the Visual Studio Team System version control and bug tracking, to the class designer, to Web deployment, it's all right there. We even have a Web browser included so you can "research" while still looking productive. As far as I can tell, all that's lacking are three key add-ins for Visual Studio to truly keep us there all day: e-mail integration, Internet messaging integration, and Halo integration. If those three add-ins get written, you can let your Alt+Tab fingers atrophy.

Without a doubt, the extensibility story for Visual Studio is a very strong one. Sadly, very few developers consider how much power they have at their fingertips. Countless developers have said if only Visual Studio would do "X," it would be the greatest development environment on the planet. In nearly all cases, what they were asking for was relatively easy to do given the extensibility we have in Visual Studio. Many developers complain that end users don't take the time to learn about computers. I always counter that argument with "I can't believe how many developers know almost nothing about their development environments." Developers don't need to know all the registry keys used by Visual Studio, but they do need to know what it takes to extend the environment so they can solve problems once or add a missing feature required by their development shop.

There are four elements to the extensibility functionality: macros, add-ins, wizards, and Visual Studio Industry Partner (VSIP). Visual Studio allows you to create macros with the built-in Visual Studio Macros IDE editor. This editor looks and behaves just as the Visual Studio environment does, so your investment in learning about that environment pays off when writing macros. This environment is called Visual Studio for Applications (VSA) and is something you can integrate into your products.

The one limitation of VSA is that you can write macros only in Microsoft Visual Basic. Since Microsoft .NET is supposed to be language-agnostic, I can't see why Microsoft limited the environment by not supporting C#. Basically, this limitation means that it doesn't matter that you had decided to stick to C#maybe because you have a thing for semicolonsyou'll still need to learn Visual Basic to write macros.

The second option is through add-ins and wizards. Whereas macros are nice for small, non-UIrelated tasks, add-ins are COM components that allow you to write true extensions to the IDE. For example, you can create tool windows (your own windows), add property pages to the Options dialog box, and respond to menu commands from add-ins. Anyone you give a macro to can see your macro source code, but add-ins are distributed in binary form, and you can use any language that supports COM to write them.

Wizards are most useful for tasks that require you to lead the user through the steps necessary for accomplishing a task. A perfect example is the Smart Device Application Wizard that walks you through creating a smart device application. With the advent of Visual Studio Templates, there's much less need for wizards.

The final extensibility options are Visual Studio Industry Partner (VSIP) packages. Almost any of the ideas you've had for extending Visual Studio can be handled with a macro or an add-in. However if you wanted to create a completely new project type, create an editor that handles a new language, or create a debugger that can debug binaries running on a different operating system, you would need to turn to VSIP. For more information on VSIP, visit the extensibility Web site at http://msdn.microsoft.com/vstudio/partners. The great news about VSIP is that it no longer requires a license fee to get the VSIP SDK. Now you can get the SDK free by filling out a legal agreement.

As you can imagine, VSIP is a huge topic and one worthy of an entire book on its own, so I won't be covering it here. My goal for this chapter is to give you an idea of what macros and add-ins can do by presenting real-world tools that have helped speed up my development. By seeing what these tools do, you'll get a good overview of the trials and tribulations you'll run into when writing your particular "tool that no one can live without." Given the fact that very few developers do wizards, I won't discuss those. When it comes to macros and add-ins, I won't be taking you through the usual "click this wizard button to make an add-in pop out" steps that other books will. I'm assuming that you've read the Visual Studio documentation, so I'll spend my time pointing out the holes and problems I ran into in order to save you all the time I wasted getting things to work.

I'll first cover some tricks for macros that aren't in the documentation and lead up to CommenTater, a cool macro that ensures that your XML documentation comments are included and up to date. The first add-in, WhoAmI, is an extremely simple tool to show the user account and permissions that an instance of Visual Studio is running under. As I discussed extensively in the introduction, if you are developing software with administrator privileges, you are absolutely and completely wrong. The second add-in, Hidden Settings, shows how to create custom property pages in the Options dialog box with new Visual Studio 2005 managed code registration. Hidden Settings provides a way to access various hidden and undocumented settings for Visual Studio.

The final add-in, SettingsMaster, is the most ambitious. The mission of SettingsMaster is to provide .NET batch project settings so you can change a single project or all the projects in a solution without having to manually change each project. For example, with SettingsMaster, changing a define on all projects is as simple as clicking a button. Additionally, SettingsMaster comes with settings configurations to change your build settings to those I recommended in the section "Schedule Time for Building Debugging Systems" of Chapter 2. Armed with SettingsMaster, keeping your team projects coordinated should be trivial.




Debugging Microsoft  .NET 2.0 Applications
Debugging Microsoft .NET 2.0 Applications
ISBN: 0735622027
EAN: 2147483647
Year: 2006
Pages: 99
Authors: John Robbins

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net