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.
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
Fancy string interpolation over concatenation? Alt+Enter will save you the effort of finding the right keys on your keyboard:
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:
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:
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
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
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
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:
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
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:
Finally, there are new context actions to help you annotate all members in a
[DataContract] type with either
[EnumMember] attributes. The longer your
[DataContract] types are, the more you’re likely to appreciate this context action:
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
- 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
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.
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.
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.