Continuing our 45-day sprint/release cycle, today we release another update to CodeRush for Roslyn. Highlights of this release include powerful new refactorings & code providers, along with enhancements to Smart Duplicate Line.
New Refactorings and Code Providers
Convert to Function
– Allows you to easily convert a method that returns void into a function that returns the appropriate type (matching the type of the expression returned). I find myself frequently using this refactoring because it's fast, smart, and I can invoke it from inside the method (with the caret on a return statement). There’s no need to reach for the mouse or move the caret up to the declaration. Here’s what it looks like:
- Convert to Procedure – This code provider is the opposite of Convert to Function. It converts a method that returns a value of any type to a proc that returns void (or a Sub in VB).
- Extract Interface – This refactoring creates an interface based on the public members of the active class, and modifies the active class so it implements the extracted interface.
- Widen Scope (promote to field) - Use this to move a local variable declaration from inside a method body out to become a private field of the parenting class.
Smart Duplicate Line Gets Smarter
In our last release, we introduced Smart Duplicate Line (Shift+Enter). This feature is a real time saver, allowing you to create new lines of code modeled on existing lines of code. Smart Duplicate Line (SDL) looks for patterns in the surrounding code, and attempts to predict the parts you’re likely to change. As a result, SDL is great for declaring constants, enum elements, properties, and POCOs.
In this release, we make SDL even smarter.
For starters, SDL now works in XAML:
And SDL now recognizes (and increments) patterns of numeric primitives of type integer, double, decimal, octal, float, and hex:
And SDL can cycle through enum elements in the code automatically:
SDL is one of my favorite new features. Be sure to try it out (Shift+Enter) and let us know what you think, and also send us your suggestions for how we can make it even smarter.
- Paste Replace Word – Replaces the identifier under caret with the one on the clipboard in a single keystroke. Press Ctrl+B when the caret is on an identifier to immediately replace it with the contents on the clipboard.
- Navigation features now support XAML bindings.
- We added submenu support to the Code Actions menu, offering contextually-related actions (e.g., contract actions, spelling suggestions, etc.) in a single submenu (thereby cleaning up the main Code Actions menu).
- We have added the ability to collect a marker and immediately paste clipboard contents at the target location using a single keystroke (Shift+Esc).
- We have added a menu item allowing you to clear all markers dropped in the document.
- You can now group Code Issues and References by folder containing the source code file.
We also addressed a number of reported issues. As always, we welcome your feedback.
You can always download the latest version of CodeRush for Roslyn from the Visual Studio Marketplace. Give it a try and let us know what you think!