Chapter 9: Extending the Visual Studio .NET IDE


Overview

The sign of an effective development tool is that it offers sufficient flexibility so that it works for you instead of forcing you to change your lifestyle to accommodate it. Until Microsoft Visual Studio .NET appeared, previous versions, in my opinion, were only good enough for debugging, not for editing and general use. I'm pleased to say that Visual Studio .NET, although still having some quirks, is what I'm using for my editing and development needs. The main reason is that compared to previous versions of Visual Studio, Visual Studio .NET is a paragon of extensibility. If you don't think something behaves correctly or you think a feature is missing, you'll find that Visual Studio .NET finally contains the capabilities to actually correct and fix the shortcoming.

Even better is that today I have an answer to one of the most common questions I used to get when I worked at NuMega: How did you guys get a window inside Visual Studio? Well, my answer doesn't matter anymore because anyone can do it. Nearly every developer has an idea for a tool or a view that belongs inside the IDE but until now has had no way of getting that tool or view in there. With the new Visual Studio .NET extensibility model, anyone can now put his or her own windows inside the IDE. The means of doing this is also documented and supported much better than the special Package Partner Program you had to go through in previous versions of Visual Studio to hook into the IDE.

There are three elements to the extensibility functionality: macros, add-ins, and wizards. Visual Studio .NET allows you to create macros with the built-in Visual Studio Macros IDE editor. This editor looks and behaves just like the Visual Studio .NET environment, so your investment in learning about that environment pays off when writing macros. The one limitation is that you can write macros only in Microsoft Visual Basic .NET. Since .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 semicolons—you'll still need to learn Visual Basic .NET to write macros.

The second option is through add-ins. Whereas macros are nice for small, non-UI-related 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.

The final extensibility option is the wizard. 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. Of the three extensibility options, wizards are the least used.

My goal for this chapter is to give you an idea of what macros and add-ins can do by presenting three real-world tools that I can't live without. 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 .NET 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.

The first tool I'll show you is CommenTater, a cool macro that ensures your C# documentation comments are included and up to date. The first add-in, SuperSaver, fixes a problem with the way Visual Studio .NET saves files, adds background saving, and lets you add property pages to the Options dialog box. It's an excellent example of a complete add-in but is small enough to wrap your mind around. The final add-in is SettingsMaster, which allows you to batch set or custom set build options so that with no work whatsoever you can use, for all types of projects, the build settings I recommended back in Chapter 2. Armed with SettingsMaster, keeping your team projects properly coordinated should be trivial. You won't have to manually change settings in a bunch of projects ever again! All these tools are available with this book's sample files.




Debugging Applications for Microsoft. NET and Microsoft Windows
Debugging Applications for MicrosoftВ® .NET and Microsoft WindowsВ® (Pro-Developer)
ISBN: 0735615365
EAN: 2147483647
Year: 2003
Pages: 177
Authors: John Robbins

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