ReSharper Templates

Here are links to the Resharper User Live Templates, User File Templates, and customized Predefined File Templates we use around here.

Right-click these user template links and choose your browser specific Save Target As... or Save Link As... to download:

The most recent changes are detailed below:

  • Added xMethodWithTrace (04/02/2008)
  • Added xPropBothWithTrace (04/02/2008)
  • Added xPropGetWithTrace (04/02/2008)
  • Added xPropSetWithTrace (04/02/2008)

User Live Templates

All Live Templates start with 'x' so they are easy to find. We figured 'x' is easy to type and is infrequently used as the first letter of an identifier or type (and for those XML aficianados out there, just follow the x with an "ML" and the templates will be removed from your intellisense). :)

  • xAssertFailAfterNullCheck: Creates a check for null for a variable and an NUnit Assert.Fail call if the variable is null. Does this in such a way so as to not generate a Resharper warning.
  • xClass: Creates a class
  • xClassWithSerializableAttribute: Creates a class with the SerializableAttribute applied. You should consider using this by default, and only not using it in cases where you really don't want something to be serialized.
  • xDispose: Creates stubbed out dispose methods that follow the disposal pattern
  • xDisposeControl: Creates two separate test methods for the Dispose method on a WinForm control
  • xIList: Creates an IList<T> initialized to a List<T> instance
  • xInterface: Creates an interface
  • xlogDebug: Creates an ILog.Debug line conditional on IsDebugEnabled
  • xlogError: Creates an ILog.Error line
  • xlogger: Adds a type member for ILog. (Uses ThoughtShapes standard declaration, so modify to fit your needs.)
  • xlogInfo: Creates an ILog.Info line conditional on IsInfoEnabled
  • xlogTrace: Creates an ILog.Trace line conditional on IsTraceEnabled
  • xlogWarn: Creates an ILog.Warn line conditional on IsWarnEnabled
  • xMethodWithTrace: Creates a method with an ILog.Trace line conditional on IsTraceEnabled
  • xMockExpectationCountMethod: Creates an int variable and correlating method that checks the expected value of the variable. By adding a statement in the method of your choice that increments the variable, you can then call the generated method to see how many times the other method has been called. For instance, if you are mocking a class with a Close method, you might create a method called ExpectedCloseCalledCount via this template, and then insert a ++itsCloseCalledCount into the Close method you are mocking...or you can try NMock. :)
  • xNullArgumentCheck: Creates the code to check for a null argument, including the throw of an ArgumentNullException.
  • xNullOrEmptyStringArgumentCheck: Creates the code to check for a null or empty string, including the throw of an ArgumentException.
  • xor: if-check for null using object.ReferenceEquals
  • xorn: if-check for not null using object.ReferenceEquals
  • xPropBothWithTrace: Creates a getter and setter property with an ILog.Trace line conditional on IsTraceEnabled
  • xPropGetWithTrace: Creates a getter property with an ILog.Trace line conditional on IsTraceEnabled
  • xPropSetWithTrace: Creates a setter property with an ILog.Trace line conditional on IsTraceEnabled
  • xre: Create Assert.AreEqual
  • xStrongCollection: Creates a strongly-typed collection
  • xSyncBlock: Creates a field/property pair for thread synchronization
  • xSyncBlock: Creates a field/property pair for thread synchronization
  • xtc: Creates an NUnit test to make sure a constructor returns an instance of the correct type without encountering problems
  • xtequals: Creates an NUnit test asserting that the class under test has overridden Object.Equals and Object.GetHashcode properly
  • xTestFixture: Creates an NUnit test fixture
  • xtfs: Creates an NUnit test fixture TestFixtureSetUp method
  • xtft: Creates an NUnit TestFixtureTearDown method
  • xtm: Creates an NUnit test method
  • xtmx: Creates an NUnit test method with an ExpectedException attribute
  • xtp: Creates an NUnit test method with an assertion of equality between property value and argument passed to constructor
  • xtpLazy: Creates an NUnit test method for lazy-instantiated properties
  • xts: Creates an NUnit SetUp method
  • xtserialization: Verifies that object-under-test is serializable.
  • xtt: Creates an NUnit TearDown method
  • xTryCatch: Creates a try-catch block
  • xTryFinally: Creates a try-finally block

User File Templates

  • TestFixture: Creats a file containing a test fixture without any tests.
  • Strong Collection Fixture: Creates an NUnit test fixture for a strongly-typed collection generated from the StrongCollection template

Predefined File Templates

  • class: Our customization of the Predefined File Template.
AttachmentSize
PredefinedFileTemplates.xml2.45 KB
UserFileTemplates.xml8.87 KB
UserLiveTemplates.xml28.69 KB