ReSharper Live Templates

Live Templates are very much like Visual Studio's built in snippets feature. They expand a couple of characters into something useful. For example, the Live Template provided in the release expands the word "fact" to:


This template has the method name highlighted and is ready to edit. When you hit enter, it places the cursor in the body of the method. It also automatically adds any necessary using statments.

These are very useful, especially with the smart Intellisense shown for the assert templates:


The release comes with two sets of Live Templates. They both map to the same output, but one has acronyms that begin with "a", such as "ae", "an", etc and the other begins with "x" ("xe", "xn", etc - this is to prevent a clash with templates for other unit testing frameworks).

The following table shows the shortcuts, and what it expands to (words wrapped in dollar signs are substitution variables and are quickly edited by pressing tab, and usually display some sort of useful intellisense):

xunit-ae.xml xunit-xe.xml Expands to
ae xe Assert.Equal($expected$, $actual$)
at xt Assert.True($value$)
af xf Assert.False($value$)
ac xc Assert.Contains($expected$, $actual$)
an xn Assert.Null($value$)
ann xnn Assert.NotNull($value$)
athr xthr Assert.Throws<$T$>()
aiaf xiaf Assert.IsAssignableFrom<$T$>($object$)
ait xit Assert.IsType<$T$>($object$)
fact fact Creates an attributed test/fact method
fa fa [Fact]
theory theory Creates an attributes theory method
ta ta [Theory]
ida ida [InlineData(x)]

Note that not all of the assert methods are there. Only the most common have been added. And I haven’t added Assert.Same, namely because “as” is a poor acronym to go for.


There are two ways to install support for this.

  • Start Visual Studio
  • Go to ReSharper -> Live Templates and click the import button
  • Select one of xunit-ae.xml or xunit-xe.xml


ReSharper lets you mount a Live Templates file, which means the contents are used in place, rather than being copied internally. The file is read at start up, and the templates are written back again when Visual Studio is closing. This makes it easier to edit and copy around the templates, but at the cost of managing the file.
  • Choose a place to store the file
  • Start Visual Studio
  • Go to ReSharper -> Live Templates and click the mount button
  • Select one of xunit-ae.xml or xunit-xe.xml

Last edited Jul 10, 2009 at 1:03 AM by mattellis, version 3