dotnet / dotnet/roslynator

RCS1239 doesn't apply to loops with addAssignments instead of postIncrements

Open
#598 0 comments 0 reactions 0 assignees View on GitHub
Area-Analyzers
Dominant language
C#
Stars
3.5k
Forks
294
Avg merge
2h 30m
Merged PRs (30d)
4

Description

**Product and Version Used**:
Roslynator 2019 2.1.3

**Steps to Reproduce**:
This analyzer does not apply to the following snippet
```C#
int i = 0;
while (i < 10)
{
Console.WriteLine(i);
i += 3;
}
```
**Suggested Behavior**:
```csharp
for (int i = 0; i < 10; i += 3) {
Console.WriteLine(i);
}
```

I have a proposed solution that is ready to submit for a Pull Request if you agree with the suggested behavior.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the RCS1239 case with the while loop and add-assignment shown in the issue, then compare it with the post-increment case the analyzer already handles. Check whether the proposed conversion to a for loop is the intended completed behavior, and verify that the transformed loop preserves i += 3 and the loop condition.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.