How to force UpperCase in VS2008 fragment?

I decided to use the following style of creating properties (using the support field):

private _firstName; public string FirstName { get { return _firstName; } set { _firstName = value; } } 

Given that the property name is similar to the name of the support field, I improved the inline prop fragment as follows:

 <?xml version="1.0"?> <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format="1.0.0"> <Header> <Title>prop</Title> <Author>Frank Rizzo</Author> <Description>Code snippet for property and backing field - changed one (not the original).</Description> <Shortcut>prop</Shortcut> <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[private $type$ _$field$; public $type$ $field$ { get { return _$field$;} set { _$field$ = value;} } $end$ ]]></Code> </Snippet> </CodeSnippet> </CodeSnippets> 

This works to some extent, but the cover of the support field and the property name are always the same, where, as in my agreement, the support field is on a camel basis, where, since the property name has pascal.

So my question is this: does the code snippet syntax have a way to change the first letter of the property so that the snippet can fit my agreement?

+4
source share
2 answers

Unfortunately, this is not possible (yet).

I hope this will be possible in a future version of Visual Studio.

+6
source
 <CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <Header> <Title>Code File Header</Title> <Author></Author> <Shortcut>codehead</Shortcut> <Description></Description> <SnippetTypes> <SnippetType>Expansion</SnippetType> </SnippetTypes> </Header> <Snippet> <Declarations> <Literal> <ID>Name</ID> <Default>Header</Default> </Literal> <Literal> <ID>LowerName</ID> <Default>header</Default> </Literal> <Literal> <ID>Type</ID> <Default>object</Default> </Literal> </Declarations> <Code Language="CSharp"> <![CDATA[ public $Type$ $Name$ { get { return $LowerName$; } set { $LowerName$ = value; OnPropertyChanged("$Name$"); } } $Type$ $LowerName$; ]]> </Code> </Snippet> </CodeSnippet> 
-2
source

Source: https://habr.com/ru/post/1301059/


All Articles