Resharper
-
Upload
hanoh-aloni -
Category
Engineering
-
view
690 -
download
4
Transcript of Resharper
Resharper
Refactoring and productivity extension by JetBrains
Refactoring
“A disciplined technique for restructuring an existing body of code, altering its internal
structure without changing its external behavior"
Abstraction Class fragmentation
Naming convention
Refactoring - Abstraction
• Techniques that allow for more abstraction– Encapsulate Field – force code to access the field
with getter and setter methods– Generalize Type – create more general types to
allow for more code sharing– Replace Type– Replace conditional with polymorphism
Refactoring - Class fragmentation
• Techniques for breaking code apart into more logical pieces – Componentization breaks code down into reusable
semantic units which present clear, well-defined, simple-to-use interfaces.
– Extract Class moves part of the code from an existing class into a new class.
– Extract Method, to turn part of a larger method into a new method. By breaking down code in smaller pieces, it is more easily understandable. This is also applicable to functions.
Refactoring - Naming convention
• Techniques for improving names and location of code – Move Method or Move Field – move to a more
appropriate Class or source file– Rename Method or Rename Field – changing the
name into a new one that better reveals its purpose
– Pull Up – in OOP, move to a superclass– Push Down – in OOP, move to a subclass
Features
• Code browsing• Code clean-up• Refactoring• Coding assistance• Micro code generation• Other useful features
Support
• C# 5.0• VB11• JavaScript• CSS• HTML• ASP.NET • ASP.NET MVC
• Razor• XML, XAML• WinRT• MSBuild and NAnt
build scripts.
IDEA vs VS
• 2 different keyboard scheme– IDEA more familiar to Intellij IDE– VS scheme more familiar to VS users– VS scheme will never override a key mapped by
visual studio
Part 1 : Code browsing
• Navigate : ART-R-N Find : ALT-R-F• Navigate to : Alt-' File : ctrl-t / ctrl-shft-t / alt-
shift-t • Related files : ctrl - alt - f7• Goto implementation : ctrl-F12• Goto definition : alt-F12 • Find usages : shift f12
Part 2 : Code clean-up
• quickfix trio : – Alt-Enter – Alt-PgDn – Alt-PgUp
• moving code around: ctrl-alt-shift-arrows • View file structure: ctrl-alt-f • Code cleanup: ctrl-e-c • see: resharper -> options -> c# -> formatting style • Safe delete : alt-Del
Part 3 : Refactoring
• Convert• Rename• Change signature• Encapsulate/extract fields/properties/classes• Introduce field/method/variable• Inline field/method/variable• Move to folder• Pull and push memebers
Part 4 : Coding assistance
• Code generation• Code templates• Code cleanup
Part 5 : Micro code generation
• Snippets• Generators• Templates
Part 6 - other
• Stack trace explorer• goto decleration to decompiled MSIL• TODO list explorer• Test runner • Globalization • Patterns catalog • XML document support• MSBuild or nant build scripts support• Javascript and CSS support
Pros and cons
• Helps enforce standards• Boosts productivity• Helps code reviews• Good analysis tools
• Over-refactoring• Tool reliance• Shapes the way you
think
Learning tips
• Keep the keymap under your keyboard• Focus on a few commands at a time• Don’t be afraid to try new shortcuts• Keep your hands on the keyboard• Watch other people use Resharper• Learn with friends and teammates
The end
Extra
What does it do?
• solution-wide static code analysis (error detection on-the-fly, without the need to compile)
• provides additional features for error correction• code completion, navigation, search• syntax highlighting, formatting• code generation and optimization • carries out 40 automated refactorings and
streamlines unit testing using NUnit and MSTest
Sources
• http://www.jetbrains.com/resharper/webhelp/Code_Analysis__Examples_of_Quick-Fixes.html
• Wikipedia