Skip to main content

Member Sections

  • 3 minutes to read

CodeRush can place properties, methods, and fields in dedicated target sections when you expand templates.

You can, for instance, expand the “pb“ template to create a Boolean property. To do this, type the template name and press Space or Tab depending on your settings.

PlaceMembers

Note

The Member Sections feature is initially enabled. To disable this feature, uncheck the Use Member Sections checkbox in the Editor | All Languages | Organize Members options page.

disable-selection

You can also customize whether CodeRush should add a comment to fields, methods, or properties section, or wrap this section into a region when you expand a template. See sections below for details.

Important

Visual Studio IntelliSense has priority over CodeRush templates. For information on how to prioritize a CodeRush template over Visual Studio IntelliSense, refer to the following topic section: Expand a Template Instead of Visual Studio IntelliSense.

Add a Comment in the Start of a Section

Follow the steps below.

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

    organize-members-rules

  2. Select the “Fields” rule and click the Comment button.

    comment-button

  3. Type a comment, for example, “Fields…” in the “Comment” text field and press Enter.

    CodeRush shows the “Member section name” field set to Fields.

    comment-text-field

    If you create a comment for a methods rule or properties rule, CodeRush sets the “Member section name” field to the “Methods” or “Properties” value respectively.

  4. To allow CodeRush to insert a comment into a template expansion, perform the following actions:

    1) Make sure the “Member section name” field is set to the “Fields”, “Methods”, or “Properties” value for the corresponding rule.

    2) The template should contain the “MemberHeader” string provider with the “Fields”, “Methods”, or “Properties” argument respectively. For example, the “p?type?” templates (“pb”, “ps”, and many others) meet this requirement.

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

  6. Switch to the code editor and expand a template. For example, expand the “pb“ and “ps“ templates to create Boolean and String properties, respectively.

    start-with-comment

CodeRush adds the “Field…” comment for fields.

Wrap a Section into a Region

Follow the steps below to customize this behavior.

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

  2. Select the “Fields” rule and click the Region button.

    click-region-button

  3. Type “Fields…” in the “Region name” field.

    region-text-field

    CodeRush shows the “Member section name” field set to “Fields”.

    If you create a region for a methods rule or properties rule, CodeRush sets the “Member section name” field to the “Methods” or “Properties” value, respectively.

  4. To allow CodeRush to add a region to a template expansion, perform the following actions:

    1) Make sure the “Member section name” field is set to the “Fields”, “Methods”, or “Properties” value for the corresponding rule.

    2) The template should contain the “MemberHeader” and “MemberFooter” string providers with the “Fields”, “Methods”, or “Properties” arguments, depending on the member type that you want to wrap into a region. For example, the “p?type?” templates (“pb”, “ps”, and many others) meet this requirement.

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

  6. Switch to the code editor and expand a template. For instance, expand “pb“ and “ps“ templates to create Boolean and String properties, respectively.

    wrap-into-region

CodeRush wraps the fields into the “Fields…” region.

See Also