Back to Devexpress

How to: Group Members by Member Type Name

coderushforroslyn-402265-getting-started-examples-organize-members-how-to-group-members-by-member-type-name.md

latest3.6 KB
Original Source

How to: Group Members by Member Type Name

  • Apr 13, 2022
  • 3 minutes to read

Organize Members can group members by the member type name (the property/field type and method return type, etc.). This example shows how to group auto-implemented properties by the ICommand type.

Add an ICommand Properties Rule to a Rule Set

  1. Open the Editor | All Languages | Organize Members options page to configure the Organize Member.

  2. Click Add Rule to add a rule for the ICommand auto-implemented properties.

  3. Change the suggested rule name to “ICommand properties” and press Enter to apply the change.

Customize the Rule

Change the Rule Priority

The Rule priority setting allows Organize Members to separate different kinds of members. For example, split auto-implemented properties of a certain type from other auto-implemented properties. Set the Rule Priority to High priority to allow Organize Members to create the ICommand properties group.

Note

The Rule priority setting does not affect the rule order specified in the rule set.

Configure Grouping

This section describes how to specify a condition to group auto-implemented properties by the type name.

  1. In the “Group by” section, click the “+” button to add a new condition to the “And” group.

  2. Repeat the previous step to add the third “Node kind”.

  3. Click the first “Node Kind” and choose the “Member type name” item from the list.

  4. Type “ICommand” in the “enter a value” text box and press Enter to apply the change.

  5. Set the second “node kind” to “Property”. For this, click “enter a value” text box and choose the “Property” item from the list.

  6. Set the last “node kind” to “Auto-implemented property”. Click “Member” and choose the corresponding item from the list.

  7. Click Apply and OK to save the changes and close the Organize Members options page.

Run Organize Members

This section shows how to apply the ICommand properties rule.

In the following code, place the caret anywhere in the class body.

csharp
using System;
using System.Windows.Input;

namespace WpfApp1.Folder
{
    class CodePlacesMenuViewModel : ItemViewModelBase
    {
        bool autoHide;

        private void SetProperty<T>(ref T autoHide, T value, string v, object onAutoHideChanged)
        {
            throw new NotImplementedException();
        }
        public ICommand ExpandAllCommand { get; set; }

        public bool AutoHide {
            get => autoHide;
            set => SetProperty(ref autoHide, value, nameof(AutoHide), OnAutoHideChanged);
        }
        public ICommand CollapseAllCommand { get; set; }
        public object OnAutoHideChanged { get; private set; }
        public ICommand AutoHideBtnCommand { get; set; }
    }
}

Press Ctrl+. or Ctrl+~ to invoke the Code Actions Menu. Select Organize Members and press Enter.

CodeRush groups auto-implemented properties of the ICommand type according to the specified rule.

See Also

Organize Members Settings