-
-
Notifications
You must be signed in to change notification settings - Fork 277
Description
Product and Version Used
Roslynator Version: 4.14.1
IDE: Visual Studio 2022
Framework: .NET 8.0
Description
When running dotnet format or using the Roslyn CLI with Roslynator enabled, the code fix for RCS1077 incorrectly formats the generated code. Specifically, the semicolon after a transformed method call is placed at an incorrect indentation level.
Steps to Reproduce
- Enable rule RCS1077.
- Write a LINQ query with formatting issues.
- Call dotnet format or Roslynator CLI to fix issues.
Input
eventPublisher.EnqueueLowPriorityEvent(() =>
{
IReadOnlyList<IEvent> events = normalizedSpecialistBios
.Select(sb => new SpecialistBioUpdatedEvent(sb.ProfileId))
.ToList();
return new BatchEvent(events);
});
Actual Behavior
eventPublisher.EnqueueLowPriorityEvent(() =>
{
IReadOnlyList<IEvent> events = normalizedSpecialistBios
.ConvertAll(sb => new SpecialistBioUpdatedEvent(sb.ProfileId))
;
return new BatchEvent(events);
});
Notice that the semicolon is placed on a new line with indentation based on the start of the original expression rather than aligned with the transformed method call.
It appears that the indentation is calculated relative to the original Select(...).ToList() call instead of the new ConvertAll(...) call inserted by the code fix.
Expected Behavior
The semicolon should remain properly aligned with the preceding method call, e.g.:
IReadOnlyList<IEvent> events = normalizedSpecialistBios
.ConvertAll(sb => new SpecialistBioUpdatedEvent(sb.ProfileId));