Skip to content

[RCS0054] Rule does not trigger on partially wrapped or single-line call chains #1723

@MaksHladki

Description

@MaksHladki

Product and Version Used

Roslynator Version: 4.14.1
IDE: Visual Studio 2022
Framework: .NET 8.0

Description

Rule RCS0054 (Fix formatting of a call chain) appears to have detection gaps. It fails to report a diagnostic in scenarios where the call chain is either entirely on one line (despite being long enough to warrant wrapping) or partially wrapped (mixed single-line and multi-line formatting).

Steps to Reproduce

Create a C# file with the following code patterns:

Scenario 1: Mixed/Partial Wrapping

var filteredProfiles = profiles.Where(p => p.Id != 0).OrderBy(p => p.LastName)
    .ToList();

Scenario 2: Entire Chain on One Line

var filteredProfiles = profiles.Where(p => p.Id != 0).OrderBy(p => p.LastName).ToList();

Actual Behavior

In both scenarios, Roslynator does not report RCS0054. No lightbulb/code fix is suggested to fix the formatting, leaving the code inconsistent.

Expected Behavior

RCS0054 should detect that these chains contain multiple calls that are not consistently formatted and offer to wrap them vertically.

var filteredProfiles = profiles.Where(p => p.Id != 0)
    .OrderBy(p => p.LastName)
    .ToList();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions