[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Collapse]CodeRush Classic
  What's New
 [Expand]System Requirements
 [Collapse]Concepts
  [Expand]Code Analysis
  [Collapse]Code Style
    Code Cleanup and Member Organization
    Code Formatting
   Feature Advisor
   FrictionFree Mode
   Mastering CodeRush Classic Features
  [Expand]Visualization Tools
  [Expand]Navigation
  [Expand]Advanced Selection Tools
  [Expand]Clipboard Tools
  [Expand]Coding Assistance
   Unit Test Runner
 [Expand]Visual Elements
 [Expand]Tool Windows
 [Expand]CodeRush Classic Options
 [Expand]Examples
  Get More Help
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Code Cleanup and Member Organization

Code Cleanup is useful when your solution contains much code that needs refactoring. It analyzes the code contained in the current file, project or entire solution, and applies certain refactorings where required.

Note

Current Code Formatting settings are also applied to code during cleanup.

To start the cleanup, click the Cleanup button in the DXCore Visualize toolbar or choose the appropriate item from the Solution Explorer context menu.

To specify the changes that Code Cleanup should apply to code, use the Rules options page. Below is a list of available changes.

C# rules:

  • Convert "" to string.Empty
  • Force braces in "do", "while" statements
  • Force braces in a "fixed" statement
  • Force braces in "for", "foreach" statements
  • Force braces in an "if..else" statement
  • Organize members
  • Force braces in "using", "lock" statements
  • Make properties auto-implemented
  • Make the variable implicit
  • Remove all comments, excluding XML comments
  • Remove all regions
  • Remove the redundant "base" qualifier
  • Remove the redundant "this" qualifier
  • Remove unreachable code
  • Remove unused namespace references
  • Remove unused variables
  • Remove user blocks
  • Use an explicit internal modifier
  • Use an explicit private modifier

XAML rules:

  • Remove all comments
  • Remove default values
Note

The member organizer removes regions containing more than one member, regardless of the Remove All Regions rule availability.

Pay close attention to the Organize members item. This item has an additional options section that enables you to modify member organization rules as required. This section appears when you set focus to the Organize members checkbox on the Rules options page.

The member organizer groups code elements and sorts elements within groups. For example, the member organizer can create groups such as "Private fields", "Internal fields", "Public methods", etc. The member organizer can also sort group items by name, parameter count, Generic parameter count, and return type name. CodeRush Classic locates code element groups in the same order as they are listed on the options page.

Note

The member organizer does not process files containing preprocessor directives, with the exception of #region and #endregion.

Note

This product is designed for outdated versions of Visual Studio. Although Visual Studio 2015 is supported, consider using the CodeRush extension with Visual Studio 2015 or higher.

Is this topic helpful?​​​​​​​