If there's a problem with the new Code Snippets feature in VS2005 it's the name "Code Snippets." Kinda faggy if you ask me. But hey, I plan on using Code Snippets anyway, and often.
I've known about Code Snippets for a while now and used them for creating properties and such. Sweet. But then it struck me that they're like CodeSmith's adolescent cousins, great to have around when you only need to move a couch or something. Call them to move the couch, then afterward slip them a few brewskies and send them on their way.
Before Code Snippets we had to drag blocks of code from the Toolbox sidebar. Dragging code from the toolbox is like getting a fax: its nice to look at but has no built-in intelligence. Code Snippets on the other hand contain types, properties and fields that can be tabbed through and modified easily.
Here's
a great article from Scott Mitchell on Code Snippets. At the end of the article is a link to a Code Snippet not included in VS2005, setting a ViewState Property. It will be a good way to introduce yourself to the simplicity of the Code Snippet model.
The Sex Factor definitely comes to the surface when you start thinking of Code Snippets as Code Generators. Rrrrph! Rrrrph!
Lots of code snippets in VS2005 for both C# and Visual Basic. (Lots more for VB than for C#. What's up with that???) Below is a C# VS2005 snippet directory. Here's
a sample .snippet file (the snippet provided from Scott Mitchell's article.) The bottom screenshot is the ViewState Property snippet in action. Well, sort of.
Technorati Tags: CodeSnippets, .NET, CodeSmith, VS2005