CodeRush – New Release (v18.1.5) for Visual Studio

This Sprint Packs a Lot

This CodeRush release packs a number of important new features for Visual Studio developers. The training window, more feature support for XAML, XML, and CSS, automatic copyright headers, jump to symbol filtering and the somewhat mind-blowing, all-new, Mega Super Copy (see below for details).

As always, you can download CodeRush from the Visual Studio Gallery or the DevExpress Download Manager.

Training Window

  The Training Window from CodeRush Classic makes a reappearance in this release. You can access it through the CodeRush | Windows | Training menu item.

Training

This window shows shortcuts for available template expansions and CodeRush features based on the current caret position:

Training2

Available templates appear above the horizontal line. Available features, grouped by category, appear below the horizontal line. If you think you may not be getting the most of CodeRush, we suggest showing this window.

Code Cleanup

  Code Cleanup gets a new Copyright Header code provider, with the ability to add copyright comments at the file’s beginning:

CopyrightHeader

It is also available as a Code Cleanup provider and as a template - just press the letter h at the top of the file on an empty line and press your template expansion key (e.g., Space or Tab).

Before using the default header feature for the first time, set values for the “First Name”, “Last Name” and “Company” fields on the IDE | User Info options page.

The actual text of the generated header is stored in the h template expansion, and can be changed there as desired.

Clipboard and Selection Tools

  • We have added Cut, Copy, Select and Comment actions to the Member Icons menu.

    MemberIcons
  • Comment/Uncomment Selection now supports XAML, XML and CSS.

Code Analysis

Spell checker suggestions in the Code Actions menu now get their own custom icon, so they are more easily distinguished from other items in the same menu:

SpellCheck

Coding Assistance

Mega Super Copy

Okay, so first we have to confess that we maybe went a little crazy on the name of this feature, but it IS pretty cool.

You can now use Multi-Select to mark important text elements before selecting and copying/cutting a block of code to get a richer smarter version of the code on the clipboard.

Any code in the selection that has been multi-selected will become linked Text Fields upon pasting.

CopyWithFields

It’s simple: Before copying code (that you know you’ll want to change on paste), multi-select the parts you’ll want to change using Ctrl+Alt+Enter. In the example screenshots above a single instance of the variable “property” was multi-selected. Next, select the entire block of code you want to work with (including the multi-selections) and copy or cut normally. CodeRush puts a smarter/richer version of the code on the clipboard, ready to paste as rich code in Visual Studio wherever you want.

You can also create zero-length multi-selections to mark caret insertion points on the paste. Just put the caret where you want the caret to be on paste (no selection), and press Ctrl+Alt+Enter to add a zero-length multi-selection marker at that location. Later when you paste, an empty TextField will be placed at that location for easy form-based entry.

Once you have Mega-Super-Copied something onto the clipboard, you can paste it as many times as you need. This is really useful for repetitive code that needs a few changes, where you know in advance what parts you want to change (and where you want the cursor) after each paste.

You can also use the Ctrl+Alt+V shortcut to paste the most recent text Mega-Super-Copied with fields, even if it is not currently on the clipboard.

Other Coding Assistance Features

The Text Links and Text Fields behavior in Smart Duplicate Line/Selection, Mega Super Copy, and Selection to Template features is now configurable. Use the Editor | All Languages | Linked Text & Fields options page to configure when the automatic links and fields should be created.

TextLinksAndFields

These rules apply to normal selections of code (free of any multi-selections). When multi-selections are present in the selection and any of these features are invoked, the options on this page are applied to only those elements multi-selected.

Navigation

Jump To Filtering

You can now define shortcuts that bring up the Jump To window with a predefined filter. The JumpToSymbol command now accepts four parameters:

  • TypeFilter (can be: Classes, Interfaces, Structs, Enums, Delegates, and AllTypes)
  • MemberFilter (can be: Methods, Properties, Events, Fields, LocalsAndParams, and AllMembers)
  • AccessFilter (can be: Private, Protected, Internal, ProtectedInternal, Public, and AllVisibilities)
  • LocationFilter (can be: AllFiles, CurrentSolution, CurrentProject, CurrentNamespace, and CurrentFile)

You can use the “and” keyword to combine filters like this: “Classes and Structs”.

For example, if you’d like a shortcut to quickly jump to all public members in the current project, declare a new shortcut binding to the JumpToSymbol command, passing the “,AllMembers,Public,CurrentProject” filter as a parameter, like this:

ShortcutBindingFilterJumpTo

In this case, pressing this new shortcut would open the Jump to Symbol window with this predefined filter:

JumpToSymbolFilter

Note: In the screenshot above I tapped the Ctrl key after window appeared before snapping this screenshot so you could see the filtering. Jump to Symbol normally appears with the filtering options hidden.

You can use this feature to create custom shortcut bindings to make is easier to find classes, interfaces, members, etc., or to search locally, project-wide, or solution-wide, all with a single keystroke.

Marker Improvements

We have improved markers behavior. System Markers dropped by CodeRush are now cleaned up automatically when CodeRush detects they are redundant or no longer needed.

Refactorings and Code Providers

  • The Declare Method code provider is now available when the caret is located at the end of the line with an undeclared method.
  • The XPO Fields code provider now copies the [Obsolete] attribute from fields to their corresponding maintained properties.
  • We have added a Collapse Accessors code formatter, which collapses both get and set property accessors into single-line form.

Templates

Type Casting Templates

We have extended the CodeRush type-casting templates so that they now additionally support explicit type casting in expressions. The following new templates were added, and will expand as described if the caret is inside a code block (but not on an empty line):

  • c. - Expands as “(Type)” with the Type identifier embedded into a Text Field so you can quickly change it. It’s also an incredibly fast way to get parens inside an expression when you need them.
  • c?Type? - Adds a typecast to a type specified in the template name variable “?Type?”. Examples:
Template Inside an Expression On an Empty Line
cd (double) double @double = (double)Expression;
cd8 (DateTime) DateTime dateTime = (DateTime)Expression;
  • c?Generic1Type?. and c?Generic2Type?. - Adds a typecast to the specified generic type (with one or two parameters) and embeds its parameters into Text Fields. Examples:
Template Inside an Expression On an Empty Line
cl. (List<Type>) List<args> list = Expression as List<args>;
cc. (Collection<Type>) Collection<args> collection = Expression as Collection<args>;
cd. (Dictionary<Type1, Type2>) Dictionary<args> dictionary = Expression as Dictionary<args>;
  • c?Generic1Type?.?Type? and c?Generic2Type?.?Type1?,?Type2? - Adds a typecast to the specified generic type (with one or two parameters). Examples:
Template Inside an Expression On an Empty Line
cl.d (List<double>) List<double> @double = (List<double>) Expression;
cd.s,i (Dictionary<string, int>) Dictionary<string, int> @int = Expression as Dictionary<string, int>;


Notes: entries in the middle column (in the three tables above) reflect new functionality in this release. Entries in the last column show previously existing (and related) casting technology. The “Expression” referenced in the last column in these tables will be replaced by an identifier in the clipboard (if any). See the C for Casting video for more on this existing functionality.

Improved ForEach Text Command

The ForEach text command now lets you iterate through all the lines of text copied to the clipboard. You can do it with the following text command:

    «ForEach(line in clipboardText,template))»

where template is the name of the template you want to execute for each line of text on the clipboard. You can access the text of each iterated line by calling «?Get(itemName)» from inside your template.

Download the Latest Version of CodeRush Now


Download CodeRush from the Visual Studio Marketplace or use the DevExpress Download Manager. And if you're enjoying CodeRush, please leave a review here so the whole world can see.

Paul Usher (DevExpress)

Awesome work guys...  updated already :)

19 June, 2018
Ben Waters

Training window is back, makes finding my templates sooooo much easier. Thank you.

20 June, 2018
Neal

Still waiting on the ToString helper. As to all this new stuff, it's impossible to remember keystrokes on what to do such as megamassivecopy. It would be nice if a mini toolbar could appear like in MS Office when selecting a word and you have mini formatting options available in a bar? A visual UI would sure help, I cannot do much with CodeRush because I cannot remember keystrokes!!! Training window may help but it is just using up screen real estate.

20 June, 2018
Mark Miller (DevExpress)

Hi Neal,

As always, thanks for the feedback. I think your floating toolbar idea to assist with discoverability has merit. We will keep this in mind moving forward. By ToString helper, are you referring to the window that allowed you to select string formatting options?

Also, if you need some assistance remembering that Ctrl+Alt+Enter multi-selects, check out the CodeRush Cheat Sheet (v3), here:

community.devexpress.com/.../coderush-cheat-sheet-v3.aspx

20 June, 2018
Brien King

Nice update, but still missing a ton of functionality from Code Rush Classic that is annoying when I need it.

Examples of stuff I've needed in the last 5 minutes:

- Copy and Pasting Fields used to automatically create properties

- Pull up to Base Class

One I've been missing for a long time....

- Encapsulate Field

The VS version sucks because then I have to go in expand the getter and setter, add the notification call, etc... The classic version was very nice.

20 June, 2018
Neal

Mark, thanks for your reply. I realize there is a context menu and the far left icon that shows actions, it helps. For the ToString wish list item as I've seen in VS for Mac (Xam Studio) what I'm asking for is when I do a ToString on a DateTime it shows me the .net formatting options such as d with a sample, D, o, etc. Same applies to other numeric, string, etc. formats as outlined in the Microsoft docs. Again, I cannot remember the ToString options for a GUID, DateTime, etc. so I always have to go look them up. It would be of great value if CodeRush could again assist me by knowing the available ToString formatting options based on type and present them for me to pick from.

21 June, 2018

Please login or register to post comments.