All docs
V21.1
21.1
20.2
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

How to: Add a Comment in the Start of a Section

  • 2 minutes to read

Follow the steps below.

  • Open the Editor | All Languages | Organize Members options page to configure the Member Organization rules feature.

    organize-members-page

  • Select a rule (for example, “Fields”).

  • Click the Comment button.

    comment-button

  • You can change the suggested comment name, for example, to “Fields…” in the corresponding text box. Press Enter to apply the new region name.

    comment-text-field

    CodeRush shows the “Member section name” field set to “Fields” in the right part of the options page.

    NOTE

    The “Member section name” field allows CodeRush to insert a comment into a template expansion. The template should contain the “MemberHeader” string provider with the “Fields”, “Methods”, or “Properties” argument, depending on the member type for which you want to add a comment. When you expand, for example, one of the “p?type?” templates (“pb”, “ps”, and others), CodeRush adds this comment to fields.

  • Click Apply to save changes or click OK to save changes and close the Organize Members options page.

  • Place the caret in a class member in the code snippet below:

namespace Ex
{
    public class TestClass
    {
        private int age;

        //Properties...
        public int Age { get { return age; } }
        public string Name { get { return name; } }

        private string name;
    }   
}
  • Press Ctrl+. or Ctrl+~ to invoke the Code Actions Menu.
  • Choose Organize Members from the menu and press Enter.

    add-comments-to-rule

CodeRush groups fields according to the Organize Members rules and creates the “Fields…” comment for fields.

See Also