Los Techies : Blogs about software and anything tech!

Resharper templates: Don't forget the Macros


I use Resharper templates (among other features) on a daily basis.  Most of them create very small pieces of code that I use VERY frequently.  For instance, I have a set of templates that help me build out my test classes and cases very quickly.  One of the very cool features you can add to your templates is to use Macros that let's R# do more work for you.

The lates template I created was to create the MockRepository.GenerateStub<Type>() line for me.  It’s a simple one liner, with one variable $INTERFACE$

image

I then added a Macro to the template to guess the type the variable should be.

image

Now I can use this macro ( it’s named gs) on this line.

image

And it fills out the generic type of the GenerateStub method for me.

image

As you can see, this is really a big time saver, especially for the really tedious generic types.  Small time optimizations like these add up over a few hundred tests.

Kick It on DotNetKicks.com
Posted Apr 06 2009, 12:36 AM by jcteague
Filed under:

Comments

DotNetShoutout wrote Resharper templates: Don't forget the Macros - John Teague's Blog -
on 04-06-2009 7:28 AM

Thank you for submitting this cool story - Trackback from DotNetShoutout

Arjan`s World » LINKBLOG for April 6, 2009 wrote Arjan`s World &raquo; LINKBLOG for April 6, 2009
on 04-06-2009 8:53 AM

Pingback from  Arjan`s World    » LINKBLOG for April 6, 2009

Arjan`s World » LINKBLOG for April 6, 2009 wrote Arjan`s World &raquo; LINKBLOG for April 6, 2009
on 04-06-2009 8:53 AM

Pingback from  Arjan`s World    » LINKBLOG for April 6, 2009

Donn wrote re: Resharper templates: Don't forget the Macros
on 04-06-2009 10:28 AM

Cool stuff, but if you use var for everything then it kind of falls  down. :( But cool stuff though !

Add a Comment

(required)  
(optional)
(required)  
Remember Me?

Enter the numbers above:
Copyright Los Techies 2008, 2009. All rights reserved.
Powered by Community Server (Commercial Edition), by Telligent Systems