Skip to content

SA1503 code fix indents incorrectly with custom indentation size #3581

@bjornhellander

Description

@bjornhellander

Consider the following file:

namespace TestNamespace
{
 public class TestClass
 {
  public void TestMethod(int i)
  {
   if (i == 0)
    return;
  }
 }
}

If this is included in a project with settings.indentation.indentationSize=1, then the code fix for SA1503 provides the following incorrect fix:

namespace TestNamespace
{
 internal class TestClass
 {
  public void TestMethod(int i)
  {
   if (i == 0)
            {
                return;
            }
        }
 }
}

StyleCop.Analyzers 1.2.0-beta.435.
Visual Studio 17.4 (Roslyn 4.4.0). Does not happen in earlier versions.
dotnet/roslyn#63013 filed on earlier preview version of Roslyn, but the same applies for 4.4.0.
PR #3580, created to bump Roslyn version to 4.4.0 in the c#11 test project, fails because of the same problem.

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