Hello i use the propfull snippet in VS a lot but i always have to add .this every time since the shortcut does not include it. Any idea where i can find a snippet that does that(for VS 2017 without resharper). I searched but the best i could find was a resharper version and that does not work for me. Sorry if this was posted somewhere but i could not find an answer.
Examples:
Normal propfull:
private int myVar;
public int MyProperty
{
get { return myVar; }
set { myVar = value; }
}
Desired propfull:
private int myVar;
public int MyProperty
{
get { return this.myVar; }
set { this.myVar = value; }
}
You can do this by using the snippet manager that you can find in Visual Studio, under Tools -> Code snippet manager...

I took for example the propfull implementation of the Microsoft snippet, and just changed it slightly so that it will add this in front of the properties, like so:
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>propfull with this</Title>
<Shortcut>thispropfull</Shortcut>
<Description>Code snippet for property and backing field</Description>
<Author>Icepickle</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[private $type$ $field$;
public $type$ $property$
{
get { return this.$field$;}
set { this.$field$ = value;}
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
You can save this file as your own snippet (extension .snippet), and then use the import button to add your own snippet. Then you can write the shortcut thispropfull and it would create the desired snippet

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With