CAML.NET Intellisense for SharePoint 2010

camelWell, I finally gone and done it!   The CAML.NET IntelliSense Extension for Visual Studio 2010 is finally out in the wild, so have at it you crazy SharePoint devheads!

For those of you already using the SharePoint 2007 version, you know the basic idea.  Extend the default CAML schema files with detailed annotations imported from the SharePoint SDK documentation so you get more information at your fingertips while editing CAML files.

But there were limitations on the amount of information you could get to show up in the Visual Studio 2008 IntelliSense tooltips.  I really wanted to include rich HTML with links and formatted scrolling text so you could basically have as much information as you need right there at your fingertips while coding.  So much better than interrupting your train of thought to go browsing through the online docs, right?

Enter Visual Studio 2010 and the simply wonderful Extension Manager.  I mean, this stuff is so cool it makes you want to quit fooling around with SharePoint and switch over to developing Visual Studio extensions full time.  (… NOT!)  But seriously, the VSIX framework really is kind of cool.  Combine that with WPF and you’ve got the makings of a really powerful tool for editing CAML files.

So, for the last 6 months or so, I’ve been working on an updated version that would take full advantage of the VSIX framework.  Here are the main features:

  • Extends the default schema files with detailed annotations imported directly from the SharePoint SDK documentation.  This is similar to the 2007 version, but way cooler.
  • Adds a custom WPF IntelliSense Presenter to the Visual Studio environment for a greatly enhanced developer experience.
  • Automatically detects and downloads schema updates so you are always working with the most current information available.
  • Links directly to the online SDK documentation for the currently visible element, so you can “drill down” into the documentation with a single click.  If no documentation link is available, it does a Bing search for the highlighted topic, which opens in the Visual Studio web browser.

You can download it directly from the Visual Studio Gallery on MSDN here.

Annotated Schemas for Richer Intellisense

The main idea behind CAML.NET Intellisense is to extend the core WSS schemas in two ways:

  1. Add as much information as possible about each element and attribute using xs:annotation elements so that it pops up in context while editing; and
  2. Identify and replace xs:string types in the schema with enumerated types so that the valid values for each attribute also popup in context while editing.

For example, using the out-of-the-box WSS schema that ships with SharePoint 2010, you get a drop-down like the following when editing a Feature element:

Rudimentary Intellisense for CAML editing

That’s better than nothing, of course, but it doesn’t say anything about what each Feature attribute is for, so unless you’re already familiar with it, you’d have to refer back to the SDK either online or in the CHM file. Kind of a drag, since you’ve got the list of valid attributes right in front of you. If you’re like most developers, this can be a real distraction because you tend to get lost in the details while searching for the information online when you should be busy coding your solution.

Instead, by using the annotated WSS schema provided by CAML.NET Intellisense, you can see the information you need right there in context. You only have to refer to the SDK documentation when you really need to learn more about the topic. Most of the time, you just need a hint, which is what Intellisense is all about, right?

New Enhanced IntelliSense Presenter

With all of the great new WPF-based enhancements that Microsoft has added to the Visual Studio 2010 user experience, why not take advantage of the improved extensibility layer and add a custom IntelliSense Presenter just for SharePoint? After all, some of the SDK descriptions of CAML elements are rather lengthy and get kind of hard to read in just a single line of text.

The CAML.NET Intellisense Presenter gives you a nifty way to get all that WPF goodness right where you need it most. Here’s an example of what you get while adding a FieldRef element to a ContentType:

Editing a FieldRef Element

Extending the Core Schemas with Enumerated Types

In addition to annotating the schemas with the corresponding SDK documentation for each element, we can go one step further and change the plain vanilla xs:string types to custom enumerated types so we get the list of valid choices for the attribute values. This comes in very handy and also helps to eliminate those nasty little typos that can be *really* hard to find (and the SharePoint CAML gets mighty snippy about).

There are lots of places in the SDK documentation where the expected attribute values are listed in the description, but are not enumerated in the schema. This again means that you’d have to go digging through the documentation to discover what SharePoint expects the attribute values to be. This can be an enormous waste of time – even if you have a pretty good idea of what the values are. Who can keep all that detail in their head?

So, CAML.NET Intellisense enumerates as many attribute values as possible so they are available at your fingertips when you need them. Each enumeration is also annotated, so you get contextual help for the available values.

Here’s another example that shows the enumeration of list template types when adding a ListInstance element to a Feature. This can be a huge time saver! How many times have you had to hunt down the table of available list template type identifiers?

ListTemplateTypeEnum

Link Back to the SDK Whenever You Need To

Microsoft has invested heavily in new and improved online SDK documentation, so I thought why not link back directly to the SDK so you can drill down whenever you need to? Sometimes you just need a little hint, but at other times, you need more detail. CAML.NET Intellisense gives you the best of both worlds. Simply click the magnifying glass icon. If there is an SDK topic for the current item, it is displayed in the Web Browser tool window. If not, then it executes a web search for more information about the topic being displayed.

MSDN Search

Stay Up To Date on the Latest Best Practices

As we all know, things change fast in our industry.  There are always new ideas, new approaches to stay on top of, new techniques for dealing with the many issues that can arise unexpectedly.

I pondered quite a bit on this one, but I felt it was very important to have a way for the extension to update itself automatically whenever new “best practices” become widely accepted.  Also, the MSDN documentation is extensible with community content.  Some of that content helps to clarify and add critical detail for various CAML tags and attributes.  I wanted a reliable way to make that information show up automatically in context, so that SharePoint developers don’t have to go looking for it.

With the extension installed, the customized SharePoint schema files are updated automatically (if a new version is available) whenever you startup the Visual Studio environment.   That way the schema authors (myself and a few dedicated MVPs) can regularly scan the SharePoint SDK and online SharePoint community resources and push new information out through the schema file.  This makes it easier for you to find the information you need, and puts it literally right at your fingertips.

Available Now from the Visual Studio Gallery

You can download the new version directly from the Visual Studio Gallery on MSDN.

Best of all, it’s free.  Free as the desert sand!  So what are you waiting for?  Get ready to ride!  Ride that CAML!  Yeah!

Sorry.

I’m just so excited it’s finally out there.

As always, your comments are welcome.

Faster.  Better.  Like a dromedary!

11 comments

  1. […] John Holiday یک ابزار یا Intellisense برای زبان CAML در ویژوال استودیو 2010 تولید کرده که پس از فعال شدن در VS 2010 به برنامه نویسان کمک زیادی در ایجاد فایلهای اسکیمای مربوط به شیرپوینت که با زبان CAML ایجاد شده، خواهد کرد. […]

  2. This is a good use of the extensibility framework. Now my warning. I hope when you’re updating these “enhanced” schema files you’re not adding new nodes. Because I’ve had the unfortunate luck of putting “extra” attributes in my xml that compiles fine on my dev environment but then fails to validate on the server I’m deploying to because the schema wasn’t at the same patch level as mine. very irritating.
    Maybe there’s a way I can turn the validation off? During deployment of my WSP?

    Thanks

    1. Brian,

      The enhanced schemas are used only by Visual Studio while editing CAML source files. They are not copied into the SharePoint runtime environment and are not referenced in any way during the execution of your code.

      John

  3. So how do we install it? The instructions in the article are incomplete.

    1) The article says “Create an XML ”Schema Catalog” file (choose any filename you like)” but doesn’t tell you where to put the file.
    2) What do we do with the .vsix file once we’ve downloaded it?

    1. Tom,

      Simply download the VSIX file and then double-click it. Everything is installed for you automatically. Restart Visual Studio and the schemas will be ready to use.

      John

      1. Ooooooooooooohhhhh! Can hardly wait to see this in action! I used your 2007 schema extensively and this looks like a massive improvement.

        I’ve installed the add-on to a VS2010 Ultimate workstation without SharPoint installed, intending to do “offline” MOSS 2007 development. Despite restarting VS, I’m getting no fancy CAML Intellisense ;(

        I’ve also got ReSharper installed.

        Is this scenario supported?

        Thanks,
        M

        1. Hi Michael,

          It should work for editing. Keep in mind, though, that the schema has been updated for 2010 and therefore includes elements and attributes that don’t work in the MOSS environment. If the presenter is not showing up, you may have more than one intellisense presenter installed for the same schema. This can happen if, for instance, you have installed both the 2007 and 2010 versions of CAML.NET Intellisense on the same machine. Try this: open your XML file for editing and then click the “schemas” link in the property pane. Deselect all but the CAML.NET.Intellisense.xsd and then go back to the XML editor and see if the presenter opens up. If you continue to have problems, let me know and I’ll investigate further.

          -John

          1. Hi John,

            Thanks for this advice. I definitely don’t have the 2007 version installed (tried uninstalling from the .msi and it told me the product isn’t installed on this machine). I do have the 2010 version installed–trying to reinstall the .vsix fails with the error “This extension is already installed to all applicable products” and I can see it as an active extension in Extension Manager.

            I checked a few of my .xml files (list, list definition, feature) and all .xsds are set to automatic. Interestingly, the CAML.NET.Intellisense.xsd isn’t in the list when I sort by File Name!

            Since my original install, I’ve restarted VS, reinstalled the extension, and rebooted my machine.

            Feel free to contact me at mediawhole at hotmail.

            Cheers,
            Michael

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.