resharper presentation for nugs

51
1 Introducing The most intelligent plug-in for Visual Studio

Upload: dmitri-nesteruk

Post on 26-Jun-2015

3.214 views

Category:

Business


1 download

DESCRIPTION

ReSharper presentation that can be given by .Net user group leaders.

TRANSCRIPT

Page 1: ReSharper Presentation for NUGs

1

Introducing

The most intelligent plug-in for

Visual Studio

Page 2: ReSharper Presentation for NUGs

2

ReSharper in a Nutshell

Coding productivity tool for Visual Studio users

Supports C#, VB.NET, XML, XAML, ASP.NET,

HTML/CSS/JavaScript, build scripts

Continuous code quality analysis: error detection and

quick-fixes

Navigation, coding assistance, code generation, unit

test integration…

Page 3: ReSharper Presentation for NUGs

3

Visual Studio with ReSharper

Page 4: ReSharper Presentation for NUGs

4

Syntax Highlighting

R# extends VS highlighting:

For fields, variables, constants, methods, operators, types, etc.

In C# and VB.NET:

Page 5: ReSharper Presentation for NUGs

5

Code Analysis

R# provides on-the-fly code quality analysis.

4 categories of analysis results:

Errors

Warnings

Suggestions

Hints

Page 6: ReSharper Presentation for NUGs

6

Code Inspections Wiki

Some suggestions are very technical, so ReSharper offers explanations:

Clicking on the “Why is ReSharper

Suggesting This” item opens up

the corresponding page in the

Code Inspection Wiki:

Page 7: ReSharper Presentation for NUGs

7

Marker Bar

Marker Bar is a sidebar to the right-

hand side of the text editor.

MB represents all R# highlights in

file (warnings, errors, suggestions,

to-do items and search results):

Status Indicator shows the

overall status of the current file:

It changes color if file contains

errors or warnings:

File contains compilation errors

File has warnings but no errors

File doesn't contain errors or

warnings

Page 8: ReSharper Presentation for NUGs

8

Solution-Wide Analysis

ReSharper can analyze your whole solution for errors

To turn on, double-click the bottom left icon in Visual Studio:

Circle is green if there are no errors, red otherwise

Double-click the circle to see a list of issues

Page 9: ReSharper Presentation for NUGs

9

Find Code Issues

ReSharper can locate all issues (errors

and warnings) in the current project or

the whole solution

To get a list of issues, use the menu item

ReSharper | Inspect | Code Issues in

Solution/Current Project

ReSharper presents a tree of all issues

found, with various grouping options:

ReSharper can also help find issues

similar to the one that has just been

encountered:

Similar issues can be searched at

different (including Custom) scopes:

Page 10: ReSharper Presentation for NUGs

10

Quick-Fixes

Quick-fixes make you code free of errors and smells

Available for most errors, warnings, and suggestions that R# displays

Bulbs used to indicate availability

Red bulb indicates an error

Yellow bulb indicates a warning

To display the list of available quick-fixes, press Alt+Enter:

Hundreds of quick-fixes to perform multiple fixes

Page 11: ReSharper Presentation for NUGs

11

Context Actions

Context actions are "mini-refactorings" intended for optional code

transformations in a certain context. Examples:

Modifying the structure of conditional statements

Joining local variable declaration and assignment

Iterating collections with foreach statements

Context actions are available for C#, VB.NET and XML

Pencil icon to the left a code line means CAs are available

Page 12: ReSharper Presentation for NUGs

12

Code Completion

R# complements native VS IntelliSense with 3 types of code completion:

Symbol Completion

Smart Completion

Import Symbol Completion

Enhancements compared to Visual Studio include: Immediate members are highlighted (vs inherited members)All overloads displayed in a pop-up, you can scroll between them Icons for parameters and local vars to distinguish them from fieldsCompletion list is narrowed down to match user inputCamelHumps: complete a long type name by typing “drfb"

instead of "DecoderReplacementFallbackBuffer"

Page 13: ReSharper Presentation for NUGs

13

Symbol Completion

Suggesting type-based variable names:

Suggesting members of a class:

Suggesting visible types:

Page 14: ReSharper Presentation for NUGs

14

Symbol Completion (cont.)

Suggesting C# keywords:

Symbol completion using CamelHumps:

Completing names of symbols in build scripts:

Page 15: ReSharper Presentation for NUGs

15

Smart Completion

Smart Code Completion (Ctrl+Alt+Space):

Filters the list of types, methods, and variables to match the

expected type of an expression

If several return types are possible, detects the most recently used

symbol of an applicable type and focuses it in the lookup list

Suggests creating anonymous delegates, lambda expressions, and

regular methods, as well as local variables for out parameters

In object initializers, suggests fields/properties that were not yet

assigned a value

Page 16: ReSharper Presentation for NUGs

16

Smart Completion (cont.)

In object initializers:

In lambda expressions:

Creating a local variable in place of an out parameter:

Page 17: ReSharper Presentation for NUGs

17

Import Completion

In C# for extension methods:

In C# using CamelHumps:

In ASP.NET:

Page 18: ReSharper Presentation for NUGs

18

Complete Statement

Complete Statement (Ctrl+Shift+Enter):

Inserts necessary syntax elements (braces, semicolons etc.)

and gets you in position to start the next statement

Is helpful in auto-closing parentheses, adding semicolons,

completing if, while and for statements etc.

Available for type members, statements, and expressions

Nested method invocation: before Complete Statement:

Nested method invocation: after Complete Statement:

Page 19: ReSharper Presentation for NUGs

19

Parameter Info

When you call a method, Parameter Info (Ctrl+Shift+Space):

Automatically shows all available signatures and parameters with

relevant documentation

Grays out inapplicable signatures as you add new arguments

Page 20: ReSharper Presentation for NUGs

20

Quick Documentation

Quick Documentation (Ctrl+Shift+F1):

Shows a pop-up with available doc for any documented symbol

Does so in the text editor, in any ReSharper tool window, or within

documentation comments

Provides hyperlinks to detailed information and documentation for

related symbols

Page 21: ReSharper Presentation for NUGs

21

Namespace Import Pop-Ups

When referencing a non-imported type, ReSharper helps promptly add it

to the list of namespace import directives

Adding a using directive this way doesn't interrupt your coding session

When pasting code from another part of your application, ReSharper will

offer to import all required types:

Page 22: ReSharper Presentation for NUGs

22

Live Templates

Live templates are predefined code fragments (expressions, constructs,

classes, methods etc.) that can be quickly inserted into code

By default, ReSharper 5 provides more than 20 live templates for C#, 17

for VB.NET, 6 for ASP.NET and 3 for XML

Iterating through collections

Creating assertion methods

Creating new arrays

Outputting values

Coding LINQ queries

Generating auto-properties

Page 23: ReSharper Presentation for NUGs

23

Surround Templates

Surround templates let you select code and surround it with code from a

live template (e.g., with a try-catch block)

Select the text to surround and press Ctrl+E,Ctrl+U to open up a list of

surround templates

Use keyboard shortcuts to select

one of the templates

Choose More… to see all available

templates and select which ones

appear in the quicklist

Page 24: ReSharper Presentation for NUGs

24

Structural Search and Replace (SSR)

SSR lets you create your own patterns to search for code smells, legacy

code constructs, etc.

Open the patterns catalog in ReSharper | Tools | Patterns Catalog

Define your own patterns and what to replace them with

ReSharper will highlight instances where pattern matches, and offers the

quick-fix for replacement:

Page 25: ReSharper Presentation for NUGs

25

Navigate To

Navigate To (Alt+`): context menu that shows all navigation options

available at the current caret position:

Page 26: ReSharper Presentation for NUGs

26

Navigate To (cont.)

Specifically, you can navigate to:

Declaration

Implementation

Base symbols

Derived symbols

Types of symbol

Usages of symbol

Control flow target

Function exit(s)

Overriding members

Conflicting declarations

Member overloads

Related files

To-do explorer

Test explorer

Object browser

Metadata view

Sources from symbol files

Decompiled sources

Page 27: ReSharper Presentation for NUGs

27

Navigate To (cont.)You can navigate to source files

located outside your solutionE.g., .Net Framework

Source Code

Simply select navigation to external symbol

ReSharper downloads PDBs from the source server…

And displays the source file:

Page 28: ReSharper Presentation for NUGs

28

Call & Value Tracking

ReSharper lets you can track…

Incoming and outgoing

calls to a method (method calls

resulting in this call being

made, or calls resulting from

the call of this method)

Origin and destination

of values (who provides

the value and where it goes)

Menu items are available

under ReSharper | Inspect

Inspections indicate all affected

locations up/down the call chain:

Page 29: ReSharper Presentation for NUGs

29

Generate

Generate drop-down menu (Alt+Ins) helps:

Implement and override members

Generate properties

Generate type constructors

Generate delegating members

Generate equality members

Generate formatting members

Page 30: ReSharper Presentation for NUGs

30

Refactor This

ReSharper provides 40+ solution-wide refactorings.

Refactor This (Ctrl+Shift+R): context menu to view and call refactorings

available at a certain code position:

Page 31: ReSharper Presentation for NUGs

31

Find Usages

Find Usages (Alt+F7) quickly locates usages of a symbol solution-wide

In mixed-language solutions, finds usages multiple languages

Search results are displayed in the Find Results window:

Page 32: ReSharper Presentation for NUGs

32

Navigation & Search

3 groups of "go to" navigation commands.

Group 1: Navigate from anywhere. Commands in this group open in pop-

up windows, support CamelHumps and wildcards (* for 0 or more

characters, ? for 1 or more characters):

Go to Symbol

Go to Type

Go to File Member

Go to File

Page 33: ReSharper Presentation for NUGs

33

Navigation & Search (cont.)

Group 2: Navigate from occurrence of a specific symbol. Navigate from

Here is used as a shortcut for these commands:

Go to Declaration

Go to Type Declaration

Go to Base

Go to Inheritor

Go to Usages

Page 34: ReSharper Presentation for NUGs

34

Navigation & Search (cont.)

Group 3: Navigate from anywhere within a type:

Go to Next/Previous Member

Go to Containing Declaration

+ Go to Last Edit Location navigates to the point of the most recent code

modification

Page 35: ReSharper Presentation for NUGs

35

View Recent Edits

Recent Edits (Ctrl+Shift+,) is a pop-up window similar to Recent Files

that shows files and symbols that you have recently modified:

Page 36: ReSharper Presentation for NUGs

36

Locate in Solution Explorer

Locate in Solution Explorer (Shift+Alt+L) highlights the currently opened

file in Solution Explorer and auto-scrolls to its entry:

It is especially useful in large solutions, or when screen area limitations

forces you to shrink the Solution Explorer window to the limit

Page 37: ReSharper Presentation for NUGs

37

File Structure

File Structure window (Ctrl+Alt+F) shows members or elements that the

current code or markup file contains, and lets you navigate directly to

their declarations:

Page 38: ReSharper Presentation for NUGs

38

Type Hierarchy

Type Hierarchy (Ctrl+Alt+H at a type usage) shows the inheritance

hierarchy of a specified type; its base types and inheritors:

Page 39: ReSharper Presentation for NUGs

39

ReSharper Refactorings

The richest set of automated solution-wide refactorings for C# and VB

available in Visual Studio ecosystem (40+ refactorings as of R# 5)

200+ context actions = “mini-refactorings”

Each code refactoring analyzes the entire scope of the code selection to

which it is applied (as wide as whole solution), including cross-language

code

Page 40: ReSharper Presentation for NUGs

40

ReSharper Refactorings (cont.)

Refactorings can be invoked with:

Individual keyboard shortcuts (whenever available)

Refactor This (Ctrl+Shift+R) context menu that lists contextually

available refactorings

ReSharper | Refactor menu

Some refactorings can be triggered with context actions (watch the

yellow bulb)

If a conflict is detected that prevents running a refactoring, a special

warning screen is shown, and the user can modify the code to resolve

the issue

Page 41: ReSharper Presentation for NUGs

41

In-Place Refactorings

ReSharper can detect when changes in code lead to a refactoring. In

this case, the refactoring is offered in-place via a context action.

For example, when a variable is renamed, the Rename refactoring is

offered in-place:

Page 42: ReSharper Presentation for NUGs

42

Code Cleanup

Code Cleanup (Ctrl+E,C) combines customizable code formatting in any

scope with a set of other useful actions, including:

Removing code redundancies (C#)

Optimizing namespace import directives (C#, VB.NET)

Reordering type members (C#)

Migrating to C# 3.0/4.0

For example, you can simply run Code Cleanup to remove code

redundancies instead of navigating between individual warnings and

fixing them one-by-one

Page 43: ReSharper Presentation for NUGs

43

Unit Testing

ReSharper recognizes NUnit

tests and lets you run or debug

them

in Visual Studio

You can run or debug:

A single unit test

All tests in a test class

All tests in a project

All tests in a solution

ReSharper provides two tool

windows – Unit Test Explorer and

Unit Test Sessions – to view, run

and manage unit tests

Page 44: ReSharper Presentation for NUGs

44

Support for ASP.NET MVC

Navigation to/from actions and controllers

Creation of new controllers and actions from usage

Special syntax highlighting for ASP.NET MVC method calls and parameters

Dedicated code completion to help you reference actions and controllers in string literals:

Page 45: ReSharper Presentation for NUGs

45

Support for HTML/CSS/JavaScript

ReSharper comes with comprehensive support for HTML, CSS and JavaScript, including

Inspections

Refactorings

Navigation

And a lot more…

Page 46: ReSharper Presentation for NUGs

46

LocalizationLocalizable strings are highlighted

and context actions are available for moving them to resources

This functionality is available not just in code, but also in web apps and arbitrary HTML strings

Refactorings (move, rename, inline, safe delete) are available on resources

A special version of the File Structure window is available for viewing resource files

Resource-specific code inspections are available

Find Usages works naturally on resources

Navigation items “Go to Inheritor” and “Go to Base” help you move between culture-neutral and culture-specific resource files

Page 47: ReSharper Presentation for NUGs

47

Color Assistance

ReSharper helps identify colors in code (C#, VB) and markup (XAML, CSS) by using the color to underline the identifier:

Completion menus are stylizedto show colors:

CSS support also comes with a dedicated color palette:

Page 48: ReSharper Presentation for NUGs

48

Decompiler

No source? No problem! ReSharper comes with a built-in decompiler*

*Also available separately as dotPeek, see http://jetbrains.com/decompiler

Page 49: ReSharper Presentation for NUGs

49

Optimize References

ReSharper can show you details of how project references are used in your project:

Alternatively, you can just quickly remove all unused ones:

Page 50: ReSharper Presentation for NUGs

50

ReSharper Plugins

Some of ReSharper plug-ins include:

Gallio: support for MbUnit, MSTest, NBehave, NUnit and xUnit.Net

Agent Smith: validation of XML comments and naming

conventions; spell checking in XML comments, string literals,

identifiers and resources

Agent Johnson: miscellaneous tools and refactorings

StyleCop for ReSharper: support for Microsoft StyleCop

Page 51: ReSharper Presentation for NUGs

51

Summary: Most Important Shortcuts

Alt+Enter: display the list of available quick-fixes and/or context actions

Alt+Ins: show code generation options

Alt+` (Navigate To): show available navigation options

Ctrl+Shift+R (Refactor This): show available refactorings

Ctrl+Space (Symbol Completion), Ctrl+Alt+Space (Smart Completion),

Shift+Alt+Space (Import Symbol Completion)

Ctrl+E,C (Code Cleanup)