What's New in v20.2.7
Code Formatting
EditorConfig Support
CodeRush now uses Visual Studio's format settings defined in the EditorConfig file.
EditorConfig settings will have a higher priority than formatting preferences set in the CodeRush Options dialog.
For example, the csharp_new_line_before_open_brace setting (shown above) overrides the Wrap open brace option set to After (for namespaces, types, methods, and simple methods) on the Editor | C# | Formatting | Braces options page (shown below).
The screencast below shows an example of EditorConfig settings influencing the Format Document command.
Blazor Support
Declare Providers
CodeRush declaration providers are now available in .razor markup. You can use them to declare local variables, methods, parameters, fields, properties, and constants.
For example, you can apply Declare Field to create a field for the active Blazor component.
Organize Members
Improved Options Page
The "Group by" section now contains an improved filter editor that simplifies group rule creation.
Resolved Issues
- T950477 - Blazor - Duplicated 'Rename' items are shown in the light bulb menu
- T959749 - Code Cleanup - The "Sort Namespace References" cleanup rule should sort namespace aliases alphabetically
- T953611 - Code Templates - Template expansion does not work for C#9 records
- T736487 - Formatting removes a space between the 'async' keyword and the list of lambda-expression parameters
- T957927 - Performance - The "What's New" notification window increases loading time
- T967230 - Performance - Typing slowdowns sometimes occur when editing large HTML documents
- T960440 - Performance - The initialization of painting plugins affects the startup performance
- T956349 - Shortcuts - The "Ctrl + S" shortcut used to strikethrough selected text within Rich Comments overrides the "Save document" command
- T953614 - Typing Helpers - The "Cycle Scope Up/Down" feature does not change a member's visibility modifier for C# 9 records
What's New in v20.2.6
Resolved Issues
- T958903 - Code Analysis - Static code analysis is running even if it is disabled and unregistered from Visual Studio in Visual Studio v16.8+
- T958831 - Visual Studio constantly displays the 'Gathering suggestions' message on an attempt to show the 'light bulb' menu
What's New in v20.2.5
Exclude Generated Code from Analysis
CodeRush now allows you to exclude files and code regions that contain generated code from code analysis and code cleanup. Just open the Editor | All Languages | Generated Code options page and add the necessary file patterns or region titles to bypass during analysis and code cleanup.
Note that this page already includes default file masks and regions typically used for generated code (see for example, the "\*.Designer.cs" file entry).
Smart Dot Enhancement
You can now quickly multi-press the dot key (".") when the caret is inside parens in a method call with parameters. CodeRush will move the dot and caret outside the closing parenthesis, allowing you to quickly access a member of the method's return value. Each additional press of the dot key will move the dot out to the right of the next closest closing parenthesis.
You can also place the caret inside square brackets ("[ ]"), for example, in a list element or array element, and double press the dot. CodeRush will move the dot and caret to the right of the closing bracket.
You can set the multi-press speed in the Smart Keys options page. The default value is 500 milliseconds. If two back-to-back dots are pressed within this time frame CodeRush applies the Smart Dot feature and suppresses IntelliSense. This setting lets you determine which feature to use when both Smart Dot and IntelliSense are available.
Resolved Issues
- T952960 - General - Visual Studio freezes when build configuration is changed from Debug to DebugTest
- T946725 - Code Cleanup should not use an implicit variable declaration for new target-typed expressions in C# 9.0
- T951418 - Code Cleanup throws an exception for a lambda statement
- T952539 - Feature Advisor - Shortcuts shown in notifications are not localized for different keyboards
- T953489 - Organize Members - Event handlers are incorrectly wrapped into a region if methods already contain regions
- T950478 - Refactorings - The "Reorder Parameters" refactoring does not support local function declarations
- T953970 - Region Painting - Regions are drawn incorrectly when #region and #endregion directives are shifted relative to each other
- T958087 - Smart Constructor - The parameter type is wrong for a member with a nullable reference type
- T952032 - Spell Checker does not work in the code editor
- T958289 - Templates - The "in" template is expanded incorrectly in HTML comments
- T951770 - Test Runner crashes if .NET 5 tests run on multi-targeting project layouts
- T957092 - Test Runner does not work in VS 2019 16.9.0 Preview 2.0
What's New in v20.2.4
Naming Conventions
EditorConfig Support
You can now configure naming conventions in CodeRush using the Visual Studio's naming styles options and corresponding settings in the EditorConfig file.
For example, the following EditorConfig defines a naming convention for classes and structures. This convention specifies all public classes and structs be capitalized and include a required "Name" suffix.
After making this example change, CodeRush features such as Name Anonymous Type will use the specified naming conventions:
Blazor Support
Declare Providers
CodeRush declaration providers are now available from @code sections in .razor files. You can use them to declare local variables, methods, parameters, fields, properties, and constants. Type is intelligently inferred from the surrounding code.
For example, you can run Declare Constant to create a constant of the corresponding type:
The red target picker marker allows you to choose the place where the created constant can be inserted.
You can configure which code providers use the target picker on the Editor | All Languages | Code Actions | Target Picker options page.
Resolved Issues
- T941086 – Blazor - Event names are removed when the "Smart Duplicate Line" feature is applied
- T949974 – Code Cleanup - The "Convert to string interpolation" rule throws an exception when the code contains a concatenation of interpolated strings
- T949987 – Code Coverage - Node filtering does not work
- T941407 – Debug Visualizer - Navigation from the Call Stack window is broken
- T948582 – Formatting - Default settings of wrapping parameters conflict with the SA1116 and SA1117 StyleCop rules
- T947961 – Formatting - The blank lines option is incorrectly processed for auto-implemented properties with the initializer
- T949144 – General - An error is thrown when a light-bulb menu is opened in a multi-target project if the caret is placed on an undeclared identifier
- T907131 – General - Some assemblies are not loaded from native images in Visual Studio 2017
- T947644 – Organize Members - Properties with expression-bodied accessors are wrongly treated as auto-implemented properties
- T946090 – Performance - A delay occurs on applying refactoring or Code Cleanup if a large number of assemblies is loaded
- T944093 – Settings - A combo box crops text on the Organize Members options page
- T938633 – Setup Wizard - The "Disable Markers" option is always selected on the Markers wizard page
What's New in v20.2.3
Blazor Support
Refactorings - Declare Event Handler
This release introduces the "Declare Event Handler (Razor code block)" and "Declare Event Handler (Razor code behind)" refactorings. These refactorings generate an event handler in the @code block of a .razor file and in a Razor code-behind file (razor.cs) for the selected method reference. The following screencasts show these refactorings in action:
- Declare Event Handler (Razor code block)
- Declare Event Handler (Razor code behind)
Organize Members Enhancements
You can now create rules to group members by:
- Member type name (property/field type, method return type, etc.)
- Member name
You can use Contains, StartsWith, and Equals string operations and RegEx expressions to group members. The screencast below shows event handler grouping:
Organize Members also allows you to sort members by their type name.
Navigation
Jump to Window
The Jump to window now clearly indicates entries found in the active file/type.
Resolved Issues
- T934252 – Code Providers - The "Add to Interface" provider processes the "default" value of a parameter as the "null" value
What's New in v20.1.8
Blazor Support
Extract Razor Component
This release introduces the "Extract Razor Component" code provider. This code provider allows you to extract a selected HTML markup into a new Razor component file (Component.razor). You can then reuse and share the Razor component in all your projects.
To use this code provider, just select the desired HTML markup you want to extract, invoke the Code Actions menu, and choose "Extract Razor Component". CodeRush creates the Component.razor file containing the extracted HTML markup and places this file in the Components project folder. After extraction is complete, you can modify the suggested component name.
This code provider also adds new Blazor usings to the _Imports.razor file. If you prefer to add Blazor usings to the original .razor file you extracted from, disable the "Generate new Blazor usings in the _Imports.razor file" option on the Editor | C# | Programming Style CodeRush options page.
Note: The "Extract Razor Component" code provider is unable to extract code from the @code section and it will not extract code dependencies for HTML markup variables and events (for example, @onclick). You may need to add corresponding dependencies to the component's @code section after extraction to resolve any dependencies.
XAML Support
Element Spacing Formatting Options
We now support Visual Studio's Element Spacing formatting options. These settings allow you to control the arrangement of elements and text lines in your XAML document. You can override these settings, for example, to apply the "Place empty lines between elements in text content" option.
Unit Test Runner
Filtering Enhancements
The Test Runner now maintains grouping in the tests tree when filtering.
Resolved Issues
- T925052 – Code Cleanup - Some lines are moved to the right by one indent when Code Cleanup is executed
- T928558 – Test Runner - Categories are wrongly recognized for MSTest .Net Core tests
What's New in v20.1.7
Code Templates
Blazor Support
New Blazor templates are here to help you create Blazor apps faster.
For example, typing bht followed by pressing Tab (or Space, depending on your settings) will create a Blazor component with an HTTP call.
Components
Template | Description |
bch |
Creates a child component with a parameter.
|
bcmp |
Creates a blank component.
|
bht |
Creates a component with an HTTP call.
|
cv |
Creates a <CascadingValue> component.
|
dav |
Creates a <DataAnnotationsValidator> component.
|
en |
Creates an <EditForm> component.
|
Input
Template | Description |
icb |
Creates an <InputCheckbox> component.
|
idt |
Creates an <InputDate> component.
|
in |
Creates an <InputNumber> component.
|
it |
Creates an <InputText> component.
|
ita |
Creates an <InputTextArea> component.
|
isel |
Creates an <InputSelect> component.
|
Blazor Directives
Template | Description |
ba |
Creates an @attribute directive.
|
bc |
Creates a Blazor @code block.
|
bf |
Creates a Blazor @functions block.
|
bh |
Creates an @inherits directive.
|
bj |
Creates an @inject directive.
|
bjc |
Creates an @inject IConfiguration configuration directive.
|
bjh |
Creates an @inject HttpClient Http directive.
|
bl |
Creates a @layout directive.
|
bm |
Creates a @model directive.
|
bp |
Creates a @page "/" directive.
|
Conditionals & Control Statements
Template | Description |
do, dw |
Creates a @do (do/while) control statement.
|
fe |
Creates a @foreach control statement.
|
for, fri, frj |
Creates @for control statement.
|
if |
Creates an @if conditional.
|
ife, ifl |
Creates an @if @else conditional.
|
sw |
Creates a @switch conditional.
|
tc |
Creates a @try/catch block.
|
tcf |
Creates a @try/catch/finally block.
|
tf |
Creates a @try/finally block.
|
u |
Creates a @using statement.
|
wh, while |
Creates a @while control statement.
|
Lifecycle Methods
Template | Description |
oar |
Creates an OnAfterRenderAsync override.
|
oar, |
Creates an OnAfterRender synchronous override.
|
oi |
Creates an OnInitializedAsync override.
|
oi, |
Creates an OnInitialized synchronous override.
|
onch |
Creates an OnChangeAsync override.
|
onch, |
Creates an OnChange synchronous override.
|
ops |
Creates an OnParametersSetAsync override.
|
ops, |
Creates an OnParametersSet synchronous override.
|
sr |
Creates a ShouldRender override.
|
Note: A comma at the end of a lifecycle method override template generates a synchronous version of the event.
HTML Support
We have also ported templates for HTML from CodeRush Classic. You can use these templates, for example, to create an HTML table:
For a complete list of ported templates, choose the HTML language and expand the "Raw HTML" folder on the "Editor | All Languages | Templates" options page.
Resolved Issues
- T921366 – IntelliRush breaks auto-formatting on tag completion for XAML in Visual Studio 2019
- T924268 – Performance – CodeRush causes typing slowdowns after opening a solution
- T919754 – Refactoring - The "Use String.Format" refactoring is not available for the code that contains a variable's value or the result of an expression
- T919254 – Spell Checker - The Spell Checker throws System.NullReferenceException in Visual Basic
- T919007 – Test Runner – The Test Runner used with code coverage should ignore assemblies with the [ExcludeFromCodeCoverage] attribute
What's New in v20.1.6
Changes in CodeRush Menu Position Customization for Visual Studio 2019
Visual Studio 2019 16.4 and up now allows you to specify where CodeRush menus should be placed, and so the older CodeRush option (on the Quick Setup options page) has been removed, which also gives you a slight performance boost on startup (saving about 1600ms on a typical dev machine).
By default, the CodeRush menu is placed in Visual Studio Extensions menu.
If you want to reposition the CodeRush menu back to the top level of the Visual Studio menu bar (recommended for most devs who use CodeRush for a higher efficiency coding experience), follow these steps:
- Open Visual Studio 2019
- Select Extensions -> Customize Menu...
- Uncheck the CodeRush entry in Extensions Menu tab
- Restart Visual Studio
Blazor Support
The following CodeRush features are now available in @code sections inside .razor files:
'Smart Dot' and 'Smart Semicolon' are disabled by default. You can enable these features on the Editor | C# | Smart Keys options page.
Refactorings
We have added the 'Move to Code Behind' refactoring. This refactoring moves code located in a razor page's @code section to a code-behind file (.razor.cs). If a code-behind file does not exist, this refactoring will create one. This refactoring also brings leading comments, attributes, and any necessary references to the code-behind file.
To use this refactoring, just place the caret in code within a @code section, press Ctrl+. or Ctrl+~ to invoke the Code Actions menu, select "Move to Code Behind" and press Enter.
Code Style Enhancements
You can now configure code style in CodeRush using the following Visual Studio's options and corresponding settings located in the EditorConfig file:
- 'this.' and 'Me.' preferences;
- predefined type preferences;
- 'var' preferences;
- use expression body.
You can also run code cleanup to apply these settings to your code.
The previously redundant Local Declaration style; Use this/Me qualifier; Use Expression Bodies, and Built-in Type Names code style settings have been removed and no longer exist on the Editor | C# (Visual Basic) | Programming Style page of the CodeRush options dialog.
Resolved Issues
- T890796 – General - CodeRush causes the System.NullReferenceException in the Visual Studio's Extract Method refactoring
- T903177 – Refactoring - The "Sync Namespace with Folder Structure" command is unavailable in a multiple-target framework project
- T917662 – Unit Testing - Test debugging stops working with .NET Core 3.1.400-preview-015203 installed
What's New in v20.1.5
Unit Testing - Run Settings File Support
You can now exclude the following members, files, and assemblies from Code Coverage analysis using a .runsettings file:
- Source files matching a specified path/name pattern.
- Signed assemblies matching a specified public key token.
- Members with a specified matching attribute.
- Assemblies having a specified AssemblyCompany attribute value.
For more information on the run settings file, see Customizing Code Coverage Analysis on Microsoft's website.
Blazor Support
Blazor developers get improved template and refactoring support in this release.
Code Templates
CodeRush now declares dependent namespaces when corresponding C# templates are expanded in .razor files. For example, the 'nsb' template (to create new StringBuilder instances) automatically adds the necessary '@using System.Text' namespace reference at the top of the .razor file.
Refactorings
Remove Type Quallifier is now available from the @code sections in .razor files.
Make Explicit now properly declares any needed namespace references when changing implicit variable declarations to variables that are explicitly-declared.
Resolved Issues
T895178 – Code Templates - The 'ms' template is expanded inside a variable declaration
What's New in v20.1.4
Unit Testing
In this release the CodeRush Test Runner gains the ability to show and run tests for all target frameworks in multi-framework projects. You can run tests for all target frameworks or for only tests in a selected framework.
Code Formatting
CodeRush lets you configure line breaks around and within simple statements (statements that consist of a single line of code that ends in a semicolon, for example, method calls, return statements, throw statements, etc.) and empty code blocks.
Code Style
We have added new Code Style options for expression bodies in methods, constructors, operators, properties, and other members.
These code style settings are used by Declaration Providers, Declare Menu, Templates, and other features that generate new members from scratch.
You can also use the "Apply expression body styles" code cleanup rule to apply this new code style.
ExecuteRefactoring Command
The new ExecuteRefactoring command allows you to quickly run a specified refactoring without the UI overhead of invoking the Code Actions menu. To bind a refactoring to a new shortcut, bring up the IDE | Shortcuts options page, create a new shortcut, select the ExecuteRefactoring command, and specify the name of the refactoring you want to invoke in the 'Parameters' text box. With the shortcut bound, you can invoke this refactoring instantly by pressing the shortcut when the caret or selection is over the code you want to change.
You can find names of supported refactorings on the Editor | Language | Code Actions | Code Actions Catalog options page.
The screencast below shows the "Ctrl+Shift+3" shortcut invoking Extract String to Resource.
Resolved Issues
- T893013 – Clipboard History stops working when the "Discover Tests from Assembly" option of Test Runner is enabled
- T892197 – Code Cleanup - An error occurred when saving a Visual Basic file
- T883411 – Code Places - Impossible to change font family and font size when the "Auto hide Code Places" option is enabled in the options page
- T885388 – Debug Visualizer incorrectly displays lambda expressions
- T892437 – Debug Visualizer - An error occurred while parsing stack trace in Visual Basic
- T886841 – IntelliRush - Committing a selected item by pressing "Enter" inserts a redundant line break in Visual Studio 16.5.0 Preview 5.0
- T893563 – Code Cleanup with Convert to string interpolation fails
- T890704 – Unit Testing - Test icons for newly added test methods are lost after building a project
What's New in v20.1.3
Duplicate Code Detection
Now you can detect structurally similar blocks of С# code, in a solution or an active project, making it easier to identify improve the quality of your code bases.
To find duplicate code in a C# solution, open the solution, from the Visual Studio main menu select CodeRush | Windows | Duplicate Code, and then click Refresh in the Duplicate Code tool window to run duplicate code analysis.
To restrict code analysis to the active project, toggle the 'Limit analysis to the active project' and click Refresh.
When duplicate code analysis is complete, CodeRush shows found code blocks in the cluster list and highlights duplicate code in the code preview.
To open the highlighted code in the Visual Studio editor, double-click it in the code preview.
Duplicate code analysis results can be imported/exported to XML.
You can configure the search engine's granularity level on the Editor | C# | Code Analysis | Duplicate Code page in the CodeRush Options dialog. The granularity setting lets you balance performance and memory usage against the quality and size of the result set.
When the granularity is small, duplicate code analysis can find smaller blocks of duplicated code, but may take a long time and use a significant amount of memory during analysis.
When the granularity is large, the engine will use less memory and will collect results faster, but may not find smaller blocks of duplicated code.
Unit Testing
Run Settings File Support
With this release, you can exclude specific functions from Code Coverage analysis using a *.runsettings file.
For more information on the run settings file, see the Customizing Code Coverage Analysis article on Microsoft's web site.
Test Discovery Enhancements
The CodeRush Unit Test Runner can now discover tests in source code and assemblies when you open a solution. This background discovery process aborts when tests are run or when the code is built. Once a project is built successfully, the Unit Test Runner will discover tests located inside these project assemblies.
Blazor Support
Code Templates
You can now expand C# templates inside @code sections in .razor files. For example, you can type in 'ps' and press Tab (or Space, depending on your settings) to create a property of type string.
Performance Enhancements
This release includes faster performance and lower memory use in the code formatting and unused code analysis engines.
Resolved Issues
- T874178 – Code Analysis - The 'Type can be moved to a separate file' diagnostic produces false positives for partial types
- T872946 – Code Providers - The 'Add to Interface' provider links different methods to one renaming group if the previous rename operation is not confirmed
- T871663 – Formatting - A single line comment in C# switch statements is duplicated and wrapped if it is initially positioned at the end of a code line
- T871655 – Formatting - Incorrect indentation inside case statements after the wrapping rule is applied
- T875390 – Spell Checker - The Spell Checker does not work with interpolated strings in Visual Basic