Skip to content
| Marketplace
Sign in
Visual Studio>Tools>RArrange
RArrange

RArrange

Tobias Hein

|
136 installs
| (0) | Free
RArrange is a C# code beautifier for Visual Studio powered by Roslyn. It will automatically rearrange your code based on a highly customizable configuration, always ensuring a consistent file layout.
Download

RArrange

Visual Studio Marketplace Downloads Visual Studio Marketplace Installs Open open issues GitHub closed issues

RArrange is a C# code beautifier for Visual Studio powered by Roslyn. It will automatically arrange your code based on a highly customizable configuration, always ensuring a consistent file layout.

Installation

RArrange can be installed directly from the Visual Studio Marketplace. Currently only Visual Studio 2022 is supported.

Usage

RArrange is enabled by default and will try to arrange a file when it is being saved. However, this requires the presence of a configuration file, which will be described in more detail in the next section.

Extension menu

Besides working on a single file, RArrange can also be applied to either a single project or the entire solution via the context menus of the Solution Explorer.

Solution Explorer menu

IMPORTANT while arranging a single file on save can be undone, this is not the case if RArrange is applied to a single project or the entire solution.

Configuration File

The behavior of RArrange can be extensively customized using a configuration file named rarrange.json. The file must be located in the same directory as the solution file. It can be either created manually or by using the Solution Explorer.

  1. Right-click the solution in the Solution Explorer
  2. Select Add -> RArrange Configuration File

Add configuration file

The file consists of several sections that will be described in more detail.

Region Settings

The regionSettings section configures the general usage of #region directives.

Setting Description
regions Determines whether to use #region directives.
endRegionNames Determines whether the #endregion directives will include the name of the region.
headerRegion Determines whether header comments are moved into their own dedicated region.
headerRegionName The name of the optional header region. If not specified, the default name Header will be used.
fallbackRegionName The name of the fallback region, i.e., the region that contains all type members not covered by any sorter. If not specified, the default name Other will be used.

Example

"general": {
    "regions": true,
    "endregionNames": true,
    "headerRegion": true,
    "headerRegionName": "Header",
    "fallbackRegionName": "Other"
}

Type Order

The typeOrder list specifies the preferred order of types when using the type sort order. See Types for a list of valid values.

Example

"typeOrder": [
    "enum",
    "interface",
    "class",
    "record",
    "struct"
]

Access Modifier Order

The accessModifierOrder list specifies the preferred order of access modifiers when using the accessModifier sort order. See AccessModifiers for a list of valid values.

Example

"accessModifierOrder": [
    "public",
    "internal",
    "protected",
    "private",
    "protectedInternal",
    "privateProtected",
    "explicitInterfaceImplementation"
]

Groups

A group is a collection of sorters and nested groups that define how type members are organized within a specified region. Each group has the following properties:

Property Description
regionname The name of the region that will be used in the #region directives.
groups A collection of nested groups that allow further hierarchical organization within this group.
sorters A collection of sorters that define how individual members are sorted within this group.

Example

{
    "regionName": "Constants",
    "sorters": [
        {
            "type": "field",
            "modifiers": [
                "const"
            ],
            "sortOrder": [
                "nameAscending"
            ]
        }
    ]
}

Sorters

Sorters define the criteria for sorting individual members within a group. Each sorter has the following properties:

Property Description
type Determines which type of member will be sorted. See SorterTypes for a list of valid values.
accessmodifier A list of access modifiers that must match for a type member to be sorted. See AccessModifiers for a list of valid values.
modifiers A list of modifiers that must match for a type member to be sorted by the sorter instance. See Modifiers for a list of valid values.
sortorders A list of sort orders defining how the matched members should be sorted. See SortOrders for a list of valid values.

Example

{
    "type": "field",
    "modifiers": [
        "const"
    ],
    "sortOrder": [
        "nameAscending"
    ]
}

Types

Value
enum
interface
class
record
struc

Sorter Types

Value
constructor
conversionOperator
delegate
destructor
event
eventField
field
indexer
method
nestedType
operator
property
type

Access Modifiers

Value
public
internal
protected
private
protectedInternal
privateProtected
explicitInterfaceImplementation

Modifiers

Value
abstract
async
const
event
extern
new
override
partial
readonly
sealed
static
unsafe
virtual
volatile

Sort Orders

Value
nameAscending
nameDescending
parameterCountAscending
parameterCountDescending
accessModifier
type

Ignore File

RArrange includes a feature to ignore specific files or directories from being processed. This is accomplished through the use of an ignore file named .rarrangeignore. The file must be located in the same directory as the solution file. It can be either created manually or by using the Solution Explorer.

  1. Right-click the solution in the Solution Explorer
  2. Select Add -> RArrange Ignore File

Add ignore file

Each line in the ignore file specifies a glob pattern. All patterns are evaluated relative to the solution directory. Lines starting with # are ignored.

Here is an overview of some common patterns.

Pattern Description
dir/ Ignores all files in the directory dir and all its subdirectories
dir/file.cs Ignores the file file.cs in the directory dir
*.cs Ignores all files .cs files in the solution directory
*file*.cs Ignores all .cs files with the word file in the filename
dir/**/*.cs Ignores all .cs files in all subdirectories of the directory dir

See Also

  • File globbing in .NET

Support

To report at problem or suggest a feature visit the RArrange Issue Tracker.

Changelog

1.0.0 - 2024-06-03

  • Initial release
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft