Organize Members allows you to organize type members according to specified rules. This helps you maintain a unified type structure and locate members.
Open the Editor | All Languages | Organize Members options page.
Refer to the Organize Members Settings topic for information about Organize Members configuration options.
CodeRush provides two predefined rule sets: Default and StyleCop. These sets can be helpful if you work on projects with different standards.
You can configure rules based on the predefined rule sets or create new rule sets.
To create an empty rule set:
Click New in the "Rule set" section.
Type a rule set name and click OK in the invoked dialog.
CodeRush creates an empty rule set which you can populate with organize members rules.
To create a rule set based on the existing rule set:
Choose a rule set which rules CodeRush must clone and click Clone.
The screenshot below shows the rule set cloned from StyleCop.
You can add rules to any rule set. Refer to the How to Create a Rule example for information on how to add a rule to the Default rule set.
To create rules in a new rule set:
Choose an empty rule set.
Click Add Rule.
CodeRush shows the rule options.
Type a rule name, for example, Constants.
Specify how many empty lines CodeRush should add between members in the "Empty line count between groups" text box (optional).
Change the Rule priority (optional). Possible values: Low, Normal, and High. Use this setting to group members with different kinds prior to other rules, for example, explicit interface implementations. See the How to create regions for explicit interface implementations example.
Set the Node kind to Constant in the "Group by" section.
Leave the Sort by settings as is for the Constants rule to sort constants by name.
CodeRush can also sort members by kind, access modifier, visibility, and other criteria. You can specify ascending or descending sort order.
The screenshot below shows the specified Constants rule settings.
Click Add Rule to add a rule for Fields.
Type "Fields" in the Rule name text box.
Set Node kind to Field.
Set the "Sort by" to Static.
Click Add to add the second "Sort by" criteria. Set the "Sort by" combo box to Name. This allows CodeRush to sort fields by static modifier and by name in ascending order.
The following screenshot shows the specified Fields rule settings.
Add the Methods rule.
Type "Methods" in the Rule name text box.
Set Node kind to Method.
Leave the "Sort by" settings as is.
The screenshot below shows the specified Methods rule.
Place the caret in a class member.
Press Ctrl+. or Ctrl+~ to invoke the Code Actions Menu.
Select Organize Members from the menu.
CodeRush places members into groups and applies members rules according to the specified order (Constants, Fields, and Methods).
The Organize Members feature can be also ran in Code Cleanup.