Saturday, December 13, 2008

Resharper:- Visual Studio Refactor,Maximize your productivity-(Code Generation Techniques And Code Analysis Techniques)-Part1

Resharper is one of the most widely used utility for the .net Developers who use Visual Studio,it can be either VS2005 or VS2008.Every person who wants to be more efficient,productive and do smart coding should always use refactoring.

Although VS2008 has bunch of refactoring features inbuilt but they are not sufficient if you do a lot of work in Visual Studio.For this kind of situations Resharper is a must have add-on and its price is worth its value.

In this series of my articles i will try to explain you with many of its features related to refactoring and some of its other powerful stuffs.

Although there can be a learning curve in mugging up some keys but once you practice them in your daily coding and make it a habit, you will find that your productivity has increased a lot.

 

First Let's See some of the Code Generation Techniques using Resharper

  • Creating File from Template
  1. You can just press Ctrl+Alt+L to open the solution Explorer

From inside the solution Explorer just press Alt+Insert to open the generate file from Template smart navigation as shown below

    3. This will create a new Class called Person and put it inside the required Namespace.
    4.You can create a new class,Interface,Structure in the similar fashion.

     

  • Surround With Template
    • Just Select the region you want to Surround with a region and then press Ctrl+E,U

    To remove the region surrounding again to its original just press Alt+Enter on the region bubble and Press Remove Region

  • Insert Live Template
    • To insert live template just press Ctrl+E,L
    • Live template can be used to insert various code templates some of which are frequently used such as enum,interface,#region,prop etc...
  • Insert some common code using Alt+Insert inside a file
    • Just Press Alt+Insert inside a file to get a number of code generation templates including creating Constructors,Properties,readonly properties,implementing missing members,overriding members,delegating members,equality members,formatting members.

     

    Code Assistance And Analysis using Resharper

  • Moving the Code Block Up and Down
    • Just Press Ctrl+Shift+Alt+[Up] to move up or Ctrl+Shift+Alt+[Down] to move down.

  • Show available quick fixes and context actions
    • Most of the times you will make use of this shortcut,whenever you see a bulb in front of your code line you can just press Alt+Enter to see related quick fixes and context actions.
  • Symbol Code Completion
    • Shortcut for symbol code completion is Ctrl+Space
  • Code Cleanup
    • Resharper includes a code cleanup module which can clean up your code according to some predefined set of rules
    • Just press Ctrl+E,C  prompt code cleanup and press Ctrl+E,F for silent cleanup
  • Extending And Shrinking the Selection
    • For extending the selection just press Ctrl+Alt+RightArrow
    • Fore shrinking the selection just press Ctrl+Alt+LeftArrow
  • Comment with Line Comment
    • Just Press Ctrl+Alt+/ to comment with line comment.
  • Comment with Block Comment
    • Just Press Ctrl+Shift+/ to comment with block comment.
  • Duplicate or Copy and paste a line ore selection
    • Just press Ctrl+D to duplicate the selection or the line and this duplicated copy is inserted just after the line which is duplicated.

 

If you are new to Resharper you can download it from the below given link

http://www.jetbrains.com/resharper/download/

Rest of the techniques will be covered in next article in this series which will be related to search assistance and navigation techniques using Resharper.

So stay tuned for more .........

Happy Programming!!!!

Submit this story to DotNetKicks

del.icio.usSave Total0 users

0 comments:

Post a Comment