Geeks With Blogs
Bryan Corazza for ( ; ; ) { BizTalk, Workflow, and .NET }

At its simpliest form a code snippet is nothing more than an xml file. 

Here's a sample of the schema:

    <CodeSnippet Format="1.0.0">
                My Snippet
            <Code Language="VB">
                <![CDATA[MessageBox.Show("Hello World")]]>

In the Code element, the Language attribute takes the following values: VB, CSharp, VJSharp, and XML.

  • The SnippetType element takes the following text: SurroundsWith, Expansion, Refactoring.  These specify the way Visual Studio is going to insert the snippet.

So with this, all you need to do is create an xml file with the following schema and insert your own code and you're ready to go.  Make sure that the file has a .snippet extension on it and it is placed in the snippet directory that Visual Studio is pointing to.  By default its placed in the My Documents\Visual Studio 2005\Code Snippets\ folder, under its particular coding language.  Enjoy.


Posted on Sunday, January 29, 2006 7:26 PM General .NET | Back to top

Comments on this post: How to create a simple code snippet for VS2005.

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Bryan Corazza | Powered by: