Intellisense is wonderful. It's so useful it's actually scary because it doesn't force you to remember a lot class names, enum values, etc. This is good for productivity but bad when you need to recall something without the Visual Studio IDE!
In any case, I like to get Intellisense whenever I can. One area that I kept putting off was adding Intellisense for custom configuration sections I create. I dislike loads of <add> tags in the <appSettings> section because it becomes hard to navigate. I prefer to create custom config sections. However, I don't get the benefit - out of the box - of Intellisense and schema validation. To get this, you need to create your own XSD file to support your custom config sections.
XSDs for config sections are not hard to write. In fact, its best to just take a look at the XSD file for the .NET config file which can be found in your Visual Studio installation folder. For example, on my machine for VS 2008, I navigate to:
C:\Program Files\Microsoft Visual Studio 9.0\Xml\Schemas
Here you'll find loads of XSD files for all sorts of things. The most important one however is called DotNetConfig.xsd. This contains the schema definitions for the base .NET config file. There are also supplimental files for .NET 2.0 and 3.0 config sections in DotNetConfig20.xsd and DotNetConfig30.xsd respectively.
Here's a simple example of a config section:
<
The xsd schema (MyConfig.xsd) for this config section is:
<?
I placed this file in the ...\Xml\Schemas folder in the Visual Studio installation folder as noted above. Now, to hook this into VS, you need to add it to the xsd catalog. You do this by editing the file catalog.xml. Add the following line to the bottom of this file before the closing <schemaCatalog> tag:
<Association extension="config" schema="%InstallRoot%/xml/schemas/MyConfig.xsd" condition="%TargetFrameworkVersion% != 2.0 and %TargetFrameworkVersion% != 3.0" />
That's it! Now when you go into VS and edit a config file, you'll get Intellisense!
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.