Skip to content

[FR] Option to ignore static modifier when sorting members #1081

@santo998

Description

@santo998

Feature Request: Option to ignore static modifier when sorting members

Summary

Add an option to ignore the static modifier when sorting type members (methods, fields, properties, etc.), so that static and non-static members of the same visibility are sorted together alphabetically instead of being split into separate groups.

Current behavior

Currently, CodeMaid treats static members as a separate group from non-static members of the same visibility level. For example, with the default configuration, public static methods are placed before public instance methods:

// Result with current CodeMaid behavior
public class MyService
{
    public static void DoSomethingStatic() { ... }  // public static
    public static void ProcessStatic() { ... }      // public static

    public void DoSomething() { ... }               // public instance
    public void Process() { ... }                   // public instance
}

The same split happens across all visibility levels (private static vs private, protected static vs protected, etc.).

Desired behavior

With the proposed option enabled, static and non-static members of the same visibility would be sorted together alphabetically, regardless of whether they are static or not:

// Result with the proposed option enabled
public class MyService
{
    public void DoSomething() { ... }               // alphabetical: D
    public static void DoSomethingStatic() { ... }  // alphabetical: D
    public void Process() { ... }                   // alphabetical: P
    public static void ProcessStatic() { ... }      // alphabetical: P
}

Proposed option

This could be implemented as a checkbox in the Reorganize settings, something like:

Group static members separately from instance members

When unchecked, the static modifier would be ignored for grouping purposes, and members would be sorted purely by visibility and then alphabetically.

Scope

Ideally this option would apply uniformly to all member types, not just methods — including:

  • Methods
  • Fields
  • Properties
  • Events
  • Constructors (where applicable)

Motivation

In some codebases and style guides, there is no preference for grouping static and instance members separately — they are simply kept in alphabetical order within each visibility level. Forcing a static/instance split can make it harder to locate members at a glance when the reader's mental model is purely alphabetical.

Environment

  • CodeMaid version: 12.0.300
  • Visual Studio version: Visual Studio 2022 (17.14.29)
  • Language: C#

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions