Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
I'm not the most efficient coder. Things like Resharper are a waste of time for me. I prefer to repeat myself 4 million times rather than learn 23,000 keyboard shortcuts. I think it's something to do with creative flow.
However, sometime you see things that are so easy and quick to use that you just adopt them without thinking. Snippets are one of these. David reminded me of this.
So, here's a custom snippet I created for inserting properties. This is pretty much the same as the default prop snippet, but I've added summary comments and I like my member vars to have a leading underscore:
<?xml version="1.0" encoding="utf-8" ?><CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format="1.0.0"> <Header> <Title>jprop</Title> <Shortcut>jprop</Shortcut> <Description>Code snippet for property and backing field</Description> <Author>Peter G Jones (modified version of prop from Microsoft Corporation)</Author> <SnippetTypes> <SnippetType>Expansion</SnippetType> </SnippetTypes> </Header> <Snippet> <Declarations> <Literal> <ID>type</ID> <ToolTip>Property type</ToolTip> <Default>int</Default> </Literal> <Literal> <ID>property</ID> <ToolTip>Property name</ToolTip> <Default>MyProperty</Default> </Literal> <Literal> <ID>field</ID> <ToolTip>The variable backing this property</ToolTip> <Default>_myVar</Default> </Literal> </Declarations> <Code Language="csharp"> <![CDATA[/// <summary> /// Backing variable for property $property$ /// </summary> private $type$ $field$;
/// <summary> /// Property $property$ /// </summary> public $type$ $property$ { get { return $field$;} set { $field$ = value;} } $end$]]> </Code> </Snippet> </CodeSnippet></CodeSnippets>
I can see that creating more elaborate snippets is pretty easy. I wonder if it would be possible to have CodeSmith snippets? That would be really cool!