Dotnet logo

.NET Tools

Essential productivity kit for .NET and game developers

How-To's

ReSharper Ultimate 10.1 EAP Build 1 (Part 1)

Have you felt like it’s been all about Project Rider lately? Guess what, it hasn’t. We’ve been busy updating ReSharper Ultimate tools, and yesterday opened a new Early Access Program: ReSharper Ultimate 10.1 EAP 1 is now available for download.

This initial ReSharper Ultimate 10.1 EAP build accumulates a lot of changes across ReSharper and ReSharper C++; a few notable improvements in dotPeek and dotTrace; while changes in dotMemory and dotCover are so far limited to bug fixing and cosmetics.

Well, in fact, there are so many changes that this post only unveils those of them that relate to C# support in mainline ReSharper. Changes in support for other languages, as well as improvements to ReSharper C++, dotPeek and dotTrace will be described in a separate post later this week.

Anyway, please read on.

ReSharper

New context actions around strings

C# 6.0 as a whole and string interpolation in particular has been supported for a while, and this update adds a bunch of actions that help you switch between different ways of handling strings, such as interpolation, concatenation, and string.Format(), and makes sure all this is just an Alt+Enter away.

For instance, there’s now a context action to rewrite a string interpolation expression as a string.Format() call:
Convert to string.Format() call

Fancy string interpolation over concatenation? Alt+Enter will save you the effort of finding the right keys on your keyboard:
Convert string concatenation to interpolation

Gone way overboard experimenting with C# 6.0 features? No problem, ReSharper will detect whenever there’s nested string interpolation that should can be simplified:
Inline nested string interpolation

In some contexts, you just don’t need to use verbatim characters to differentiate identifiers from keywords. ReSharper can now point you at this kind of redundancy, and help you get rid of it locally or in a wider scope:
Remove redundant verbatim character

Other new actions around strings help:

  • Make a string equality check case-insensitive
  • Insert new arguments into string interpolation expressions
  • Use string interpolation expressions with various logger frameworks

New context actions to check argument values

Another group of context actions serves to generate checks upon method parameters based on their types:

  • For string parameters, ReSharper helps generate checks not only for nullness but for empty and whitespace strings
  • For numeric parameters such as int, double or decimal, ReSharper can write a check that ensures that only non-negative values are passed
  • For enum parameters, ReSharper generates a check that makes sure that an enum value being passed is in fact defined in the appropriate enum declaration, therefore guarding against ill-fated casts
  • Finally, for collection parameters, ReSharper helps set up a check against empty collections

Context actions to check parameter values

WCF-specific context actions, inspections and quick-fixes

Something clicked, and we’ve come up with a few inspections and actions that address some of the most common issues in WCF service development.

For example, whenever you have a WCF service method that is marked as [OperationContract(IsOneWay=true)] but it returns anything other than void or Task, ReSharper will spot this and suggest a fix to prevent a runtime error: you can either change return type to void or make the method two-way:

WCF quick-fix for a one-way operation that returns a non-Task type

If you have a [ServiceContract]-annotated interface that doesn’t have a single [OperationContract] member, then there’s something clearly going wrong: ReSharper will spot this and provide a quick-fix to annotate all members of the interface with [OperationContract].

Likewise, if you have methods marked as [OperationContract] in an interface that doesn’t have a [ServiceContract] annotation, ReSharper will spot this and suggest two options to resolve the issue:

WCF: containing type not marked as ServiceContract

Finally, there are new context actions to help you annotate all members in a [DataContract] type with either [DataMember] or [EnumMember] attributes. The longer your [DataContract] types are, the more you’re likely to appreciate this context action:

Context action to annotate WCF DataContract members with EnumMember

More new context actions and quick-fixes

There’s an assortment of new context actions and quick-fixes that can’t be classified as easily. These include:

  • A pair of context actions, one of which comments out a selection (effectively serving as an Alt+Enter equivalent of dedicated ReSharper shortcuts for commenting code), and the other uncomments whatever comment is under caret
  • A context action to delegate implementation of a non-implemented interface to a new field of the corresponding type
  • A pair of context actions to split or join attribute sections
    Context actions to split or join attributes
  • A context action to create another part of a partial type
  • A context action to add braces around switch case statements

Invert Boolean Member refactoring

When you modify a member that returns a boolean so that it gets an opposite meaning (say, refactor a method called IsNotAvailable() to IsAvailable()), you likely want to invert the value that it returns, and update other members that receive values from it.

This is what the new Invert Boolean Member refactoring can do for you. For example, by invoking it on a method, you can choose to rename the method and either invert values inside the method, and/or invert usages of the method.

Invert Boolean refactoring

The refactoring can be invoked on a method, property, local variable or a parameter.

More ReSharper improvements; changes to ReSharper C++, dotTrace and dotPeek…

…will be described in a follow-up post shortly.

What’s next?

Please download ReSharper Ultimate 10.1 EAP and make sure to put it to good use.

If you are experiencing issues with the EAP, please report them to issue trackers of affected products. Links to issue trackers that you can use to report or track issues are as follows: ReSharper, ReSharper C++, dotTrace, dotCover, dotMemory, dotPeek.

image description