The requested page is not available for the requested platform. You are viewing the content for Default platform.

Member Organization

  • 4 min to read

The Member Organization rules feature is configured in the Editor | All Languages | Organize Members options page.

OrganizeMembersPage

When you execute Member Organization, CodeRush places members into groups. Each group corresponds to a member organization rule. A list of member organization rules is located on the left part of the Organize Members page.

The sort order of members within a group is configured for each member organization rule individually. The order of the groups is similar to the order of member organization rules in the list.

On the right part of the Organize Members page you can see the selected rule configuration.

Each member organization rule consists of the following options:

  • Rule name.
  • Number of lines between members.
  • Grouping rules.
  • Sorting rules.

Grouping rules are designed to configure what kind of members will be grouped together by the rule.

Sorting rules are designed to configure the order of members in each group.

CodeRush can sort group items by name, kind, abstract, read-only, override, sealed, static, virtual, extern, visibility, and parameter count. Items can be sorted in ascending order or descending order.

The following image shows fields sorting rules.

Customize Rules

You can use Rule schemes to configure several configurations and switch between them.

CodeRush provides two predefined schemes: Default and StyleCop. These schemes can be helpful if you work on several projects with different standards.

You can create, remove, and re-arrange rules using corresponding buttons. Refer to the Rule Creation example for more details.

You can also customize adding a comment in the start of a member section or wrapping a section into a region.

Add a Comment in the Start of a Section

Follow the steps below.

Select a rule (for example, Fields).

  • Click the Comment button.

CommentButton

  • Type the required comment in the "Comment text" field, for example, "Fields...".

CommentTextField

  • Click Apply to save changes or click OK to save changes and close the CodeRush configuration menu.
  • Execute the Organize Members action.

Wrap a Section into a Region

Follow the steps below.

  • Select a rule (for example, Fields).
  • Click the Region button.

ClickRegionButton

  • Type the region text in the "Region name" field, for example, "Fields...".

RegionTextField

  • Click Apply to save changes or click OK to save changes and close the Coderush configuration menu.
  • Execute the Organize Members action.

The Organize Members page allows you to enable/disable the following features:

  • Insert an empty line above and below all organized members.
  • Remove existing line breaks.
  • Skip initialized fields.

See Member Organization for more information about these features.

Example: How to Create a Rule

Follow the steps below to create a new rule for non-public enumerations:

  • Use the Editor | All Languages | Organize Members options page.

  • Click the Add Rule button to add a new rule.

  • Use the Move Up and Move Down buttons to change the rule's position.

  • Enter the rule name to the Rule name field on the right. In this case, the rule name is Non-Public Enumerations.

    RuleName

  • Configure grouping:

    • Set the Node kind item to Enum.

    NodeKind

    • Switch Kind to Visibility.

    KindVisibility

    • Focus the Node kind item.

    FocusNodeKind

    • Click the And button to create the And group.

    AndButton

    • Expand the newly-created And group and set the Visibility to Public.

    CustomizeAndGroup

    • Focus the Visibility item and click the Not button to create the Not group and put the Visibility (focused) item there.

    CreateNotGroup

    • Expand the Not group and check that you have the following filter.

      Config_OrgMem_Group

  • Configure sorting (optional) or leave it as is.

    SortingGroup

  • Click Apply and OK to save the changes and close the Organize Members window.

SaveAndCloseWindow

  • Execute Organize Members (see the section below).

Organize Members According to a Specified Rule

To execute Organize Members, place the caret in a type declaration and select Organize Members from the menu.