When I install or upgrade a new version of Visual Studio, or when I am on a computer of a colleague, I am always missing some snippets. So here I will collect each one.
propvm
1 2 3 4 5 6 | private $type$ _$name$; public $type$ $name$ { get => _$name$; set => SetProperty( ref _$name$, value); } |
(Windows, propvm.snippet)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | <?xml version="1.0" encoding="utf-8"?> <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format="1.0.0"> <Header> <Title>propvm</Title> <Shortcut>propvm</Shortcut> <Description>snippet for view model property including the backing field</Description> <Author>Thomas Kison</Author> <SnippetTypes> <SnippetType>Expansion</SnippetType> </SnippetTypes> </Header> <Snippet> <Declarations> <Literal> <ID>type</ID> <ToolTip>property type</ToolTip> <Default>string</Default> </Literal> <Literal> <ID>property</ID> <ToolTip>property name</ToolTip> <Default>MyProperty</Default> </Literal> </Declarations> <Code Language="csharp"> <![CDATA[private $type$ _$property$; public $type$ $property$ { get => _$property$; set => SetProperty(ref _$property$, value); } $end$]]> </Code> </Snippet> </CodeSnippet> </CodeSnippets> |
cmd
1 2 3 4 5 6 7 8 9 10 | #region $name$ ICommand _$name$Command; public ICommand $name$Command => _$name$Command = _$name$Command ?? new DelegateCommand(Do$name$); private void Do$name$() { } #endregion |
(Windows, cmd.snippet)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | <?xml version="1.0" encoding="utf-8"?> <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format="1.0.0"> <Header> <Title>cmd</Title> <Shortcut>cmd</Shortcut> <Description>snippet for a delegate command</Description> <Author>Thomas Kison</Author> <SnippetTypes> <SnippetType>Expansion</SnippetType> </SnippetTypes> </Header> <Snippet> <Declarations> <Literal> <ID>cmdName</ID> <ToolTip>name of the command</ToolTip> <Default>My</Default> </Literal> </Declarations> <Code Language="csharp"> <![CDATA[ #region $cmdName$Command ICommand _cmd$cmdName$; public ICommand $cmdName$Command { get => _cmd$cmdName$ = _cmd$cmdName$ ?? new DelegateCommand($cmdName$); } private void $cmdName$() { } #endregion $end$]]></Code> </Snippet> </CodeSnippet> </CodeSnippets> |