Switch alignment is off in ReSharper

When creating a loop (while, for, foreach), when placing the braces for the loop, they are placed at the level of the case label, not at the level of the loop statement:
Simple file to check:

using System.Collections.Generic;
namespace RulesLibraryTests
{
  class Class1
  {
    void Method1(int param, List<int> inputs)
    {
      switch(param)
      {
        case 1:
          break;
      }
    }
  }
}

Now, when I add a loop to the case, I get this:
void Method1(int param, List<int> inputs)
{
  switch(param)
  {
    case 1:
    foreach(var item in inputs)
    { //NOTE: this is indented too far to the left.

    }
      break;
  }
}

ReSharper itself complains that these are inconsistent, and offers to fix it, but it shouldn't be screwed up in the first place.

Suspending ReSharper fixes the issue.

Does anyone know how to fix this issue. I've tried playing around with the options, but nothing seemed to give me the desired effect.

 

Also, not sure if this is related, another issue is nested case alignment: each case is indented relative to the first one

Expected:


case 1:
case 2:
case 3:

actual:
case 1:
  case 2:
    case 3:

 

0
1 comment

Hello Ivan,

 

Could you please provide screenshots demonstrating the problem?

Also please collect dotSettings files via ReSharper | Manage Options | right-click on each layer | Export to file. You can do it using "Submit a request" form.

Thank you.

0

Please sign in to leave a comment.