• Home
  • -
  • Visual Studio Code Snippets using ReSharper Live Templates

Visual Studio Code Snippets using ReSharper Live Templates

A really useful yet often under-utilised feature of the Resharper toolbelt are Live Templates. Its effectively yet another productive time saving technique that using Reharper brings.

Its straight forward, and the example below I use almost everyday. Its used to create a unit test stub to support GivenWhenThen.

Goto: ReSharper->Tools->Templates Explorer...

As Highlighted below. If the test scope doesnt exist then select the New Template icon on the toolbar. If it does then simply select and edit.

This takes you to the template itself where I added the following.

[Test]
public void $Method$_$Scenario$_$Expected$(){  
    // GIVEN:
    $END$
    // WHEN:
    // THEN:
}

And thats! This then gives you the following code snippet.

Really simple and incredibly effective. The example above is primitive but this shows better examples of how powerful it can be.