ReSharper – A Class Creating Machine

Recently, I purchased a copy of .  I’m not even going to pretend I’ve scratched the surface of what ReSharper can do, but I can assure you it’s a massive time saver when creating classes from scratch.  I’m furiously plugging away, implementing an ORM for RADE, and to do that I needed to create a lot of classes pretty much from scratch (oh, and do I have a few things to say about that, but that’s for another day).  Let’s look at a simple example.  To get things started, create a new class.  Select the folder in the solution explorer, and press Alt+Insert:

ReSharper Class Creation

Press enter and you are prompted for the class name.  So Visual Studio has this of course, but this is a small example of some of the time savings you can achieve.  Enter the class name and you start off with an empty class.  Next, lets define a couple of private members.   Let’s run with the following example.

1: namespace RADE.BO.Domain 2: { 3: public class SampleClass 4: { 5: private Int32 _ID; 6: private String _Description; 7: private Int64 _BiggerInt; 8: } 9: }

 

Simple class.  Three member variables.  Here is where the big time savers come in.  Next, click Alt+Insert again and you will be prompted with the following options:

Some ReSharper Code Generation Tools

Choose Properties.  You will now be given the option to select one or many fields, set the access rights, read only and virtual properties as well a bunch of others. 

ReSharper Properties Generator

Execute that and all of your get/sets are defined.  My one complaint is that ReSharper is not maintaining the type on the properties.  My Int32′s become int, and Int64′s become long’s.  Apparently this is slated to be fixed.  

Page 1 of 2 | Next page