Javascript Intellisense in Visual Studio "Orcas"
In February I did a blog post called My "First Look at Orcas" Presentation. It provided a good summary of some of the cool web development features coming with Visual Studio "Orcas". If you haven't had a chance to read it, I recommend checking it out here.
One of the most highly anticipated features is the support for client Javascript Intellisense within Visual Studio "Orcas" (this feature also works in the free Visual Web Developer Express edition).
If you have ever been frustrated by manually typing Javascript before, you are going to be in for a pleasant treat with "Orcas". Visual Studio now provides full Javascript Intellisense completion in .aspx files, .htm files, as well as in external .js files. It delivers Intellisense for vanilla Javascript code, as well as provides rich support for the new ASP.NET AJAX client Javascript framework and Javascript code built with it.
You can read more about some of the Visual Studio "Orcas" Javascript features in these two overview posts from the VS Web Tools Team here:
As Wally recently blogged about, one of the cool things about the VS "Orcas" Javascript Intellisense support is that it has been designed to "just work" out of the box. This means you don't have to run any tools on your Javascript files to build-up the Intellisense hints. Nor do you have to decorate your Javascript in a specific way in order to make it work. If you have a standard Javascript function or prototype class you've built in your external Javascript file, you should get Intellisense completion against it within Visual Studio automatically.
Optional Javascript Doc Comments
Visual Studio also allows you to optionally add documentation comments to your code/libraries that can further help the Intellisense engine, as well as enable developers to provide documentation comments that the VS Intellisense engine can pick up and use for summary comments and type descriptors/validation checking.
For example, if you added this XML summary comment to your code:
Visual Studio will automatically display the summary details, as well as provide in-line help when typing the parameter values:
The Format for Javascript Doc Comments
Bertrand Le Roy from the ASP.NET Team recently made a great blog post that details the documentation summary comment format that is used by both ASP.NET AJAX and Visual Studio "Orcas". Among other great things it includes details on:
- How to Add Summary Details for Classes, Methods and Parameters
- How to localize Documentation in Javascript
- How to indicate that one external Javascript file requires (or references) another external Javascript file and should have its Javascript Intellisense assume that the other methods and classes are "in-scope" when the external JavaScript file is used (which is super useful anytime you are using any AJAX framework library).
I highly recommend checking out his blog post here.
The ASP.NET AJAX Control Toolkit also now has a built-in MSBuild task that you can add to your web projects that can automatically strip out these documentation comments (along with whitespace and other non-needed content) from your JavaScript files when compiling a project in "release" mode. This provides a really useful utility that enables you to maintain debug/descriptive versions of your Javascript at development time, and then allow you to throw a switch to generate versions optimized for efficient download at runtime.
Hope this helps,
Scott