Resharper Live Templates

Posted on Apr 22, 2016 by Morten Empeño

Resharper offers some of the most powerful tools, you can add to your toolbox, if you are a software developer. You probably know that Resharper offers a lot of tools, such as intelligent IDE’s for Java, Javascript, Python, Ruby and PHP, extensions for Visual Studio, .NET unit test runner, .NET decompiler and much more.

Code Templates

One of the tools, Resharper is providing, is called Code Templates. Those templates help the developers write common code much faster. There are many different types of code templates:

All these type of templates offer different ways to quickly add or manipulate a piece of code. Well… you have to try it, to know how powerful it really is.

Live Templates

In this short blog, I will zoom into Live templates. Maybe you have already tried to use Visual Studio code snippets? Resharper Live templates is kind of the same – just a lot smarter and a lot better.
A skilled ex-colleague of mine, introduced this tool to me by describing it as Visual Studio Code Snippets on coke. You can use existing Live templates, provided by Resharper, and you can even make your own customized templates.

Existing Templates

To use an existing template, you need to have Visual Studio installed along with Resharper.
Follow these steps to create a file with a constructor:

Resharper offers a lot of pre-built templates, for C#, XML, HTML, VB.NET and much more. To check them out, click the “Resharper” tab in your main navigation in Visual Studio, then click “Tools” and finally click “Template Explorer”.

Creating a Template

You can also create your own templates. I have created several templates, for standard code, I found myself writing again and again. One of the most simple examples would be my template for an async unit test.
To create this, follow the steps: