ReSharper 2017.1 and 2017.2 both bring better support for C# 7.0 and C# 7.1, with a number of new inspections, quick-fixes and context actions. ReSharper understands the new syntax and constructs that C# 7.0 and C# 7.1 bring, and ties them into existing and new inspections, quick-fixes, navigation and refactorings:

We’re kicking off this series with out variable declarations (spec) that are available in C# 7.0.

Out variables

In earlier C# versions, using out parameters would mean declaring a variable with its full type and then making a method call:

C#

1

2

3

4

intnumber;

if(int.TryParse("42",outnumber)){

// ... work with number ...

}

With C# 7.0, we can instead make a method call and declare our variable in one go, using out variable declarations:

C#

1

2

3

if(int.TryParse("42",outintnumber)){

// ... work with number ...

}

We can use the Inline ‘out’ variable declaration inspection (and quick-fix) to inline the variable declaration in our method call.

Another inspection will check our preferred code style and suggests using var (or the use of explicit types if configured):

C# 7.0 also introduces ref returns, where a method can return a reference to a variable. ReSharper provides an inspection to verify method signatures using ref returns are valid, and comes with a quick-fix to return by reference or update the base type and make it return by value.

I find it really inconvenient that it goes to a type rather than ‘out var’ by default. So always have to repeat to commands. Also annoying that new classes are not sealed by default. Could you create two broad default non-granular R# profiles: “I am a legacy developer who loves imperative stuff” and “I am a modern developer who embraces immutability and inference”?