Product and Version Used
Roslynator Version: 4.14.1
IDE: Visual Studio 2022
Framework: .NET 8.0
Description
Currently, rule RCS0054 (Fix formatting of a call chain) enforces a style where the first method call in a chain remains on the same line as the object being operated on, while subsequent calls are wrapped to new lines.
I would like to request a configuration option for RCS0054 that enforces wrapping the first call in the chain to a new line as well. This is often preferred for "fluent" API readability.
Steps to Reproduce
- Enable rule RCS0054.
- Write a LINQ chain with formatting issues.
- Apply the code fix by
fix --supported-diagnostics RCS0054
Input
var filteredProfiles = profiles.Where(p => p.Id != 0)
.OrderBy(p => p.LastName).ToList();
Actual Behavior
var filteredProfiles = profiles.Where(p => p.Id != 0)
.OrderBy(p => p.LastName)
.ToList();
Expected Behavior
var filteredProfiles = profiles
.Where(p => p.Id != 0)
.OrderBy(p => p.LastName)
.ToList();
Handling Null-Conditional Operators (?.)
Crucially, this behavior must handle the null-conditional operator correctly by settings. If the chain initiates with ?., the operator should wrap to the new line along with the method.
var profileNames = profiles
?.Select(p => $"{p.FirstName} {p.LastName}")
.ToList();
Product and Version Used
Roslynator Version: 4.14.1
IDE: Visual Studio 2022
Framework: .NET 8.0
Description
Currently, rule RCS0054 (Fix formatting of a call chain) enforces a style where the first method call in a chain remains on the same line as the object being operated on, while subsequent calls are wrapped to new lines.
I would like to request a configuration option for RCS0054 that enforces wrapping the first call in the chain to a new line as well. This is often preferred for "fluent" API readability.
Steps to Reproduce
fix --supported-diagnostics RCS0054Input
Actual Behavior
Expected Behavior
Handling Null-Conditional Operators (?.)
Crucially, this behavior must handle the null-conditional operator correctly by settings. If the chain initiates with ?., the operator should wrap to the new line along with the method.