C# formatting question break; after a block

Answered

I could use a little help as I am asure I am missing something.  I'd like to get Resharper to format my switch statements a little differently then it is, but can't find a way to adjust the behevior.

What I'd like to see is my break statements outside of my case blocks to be directly underneath the closing brace of the case block.

     switch(foo)
     {
          case BAR.one:
          {
          }
          break;

          case BAR.two:
          {
          }
          break;

          .     
          .
          .

          default::
          {
          }
          break;
     }

What I get is the break ends up indented an extra tab:

     switch(foo)
     {
          case BAR.one:
          {
          }
               break;

          case BAR.two:
          {
          }
               break;

          .     
          .
          .

          default::
          {
          }
               break;
     }



This isn't a problem when writing the code as it is quick to fix, but it is a pain when auto formatting kicks in.

Any help woudl be appreciated.


4
8 comments

I have this same problem in C++ (with Resharper++).

This seems to have been a problem since 2014...?

No one has any ideas how to fix this?

1

I would like to be able to configure the same behavior Douglas specified in his original post. In my case, this is also specific to using switch blocks as noted by Douglas. I am using RS 2018.1.2 and cannot figure out how to stop RS from adding the blank line before the break statement.

1

Is there an update on this?

 

It's not a huge pain, but it is a pain when you quickly write 10 case/break in a switch statement, and hitting backspace on the break moves it one row up, and when you hit enter again it moves it down. You have to go to the beginning of the row and hit delete to move it manually.

1

Hello,

there's a known issue reported here - https://youtrack.jetbrains.com/issue/RSRP-478502.

You are welcome to comment or vote for it.

Thank you.

1

When I tried looking for it, I couldn't find it, that's why I responded here.

The question remains however - any update?

If you look at the list you can see my name as one person that DID vote for it, I even wrote a long example of why we want this.

 

EDIT: Two now, added some more information.

1

Hello Stefan Smietanowski

The issue is definitely in our plans and we are looking into it though I cannot specify certain estimates.

Please accept my apologies for the inconvenience.

1

Tomorrow it will have been two years since you said this was in your plans. Please fix it or tell us how to disable this particular behavior.

1

Hello Eisenberg,

I'm sorry that I cannot provide any update on the progress. As you see the request is not rejected so we consider implementing it. The thing is that we have quite a lot of feature requests and we cannot implement them all at once. I'd suggest all who need its implementing to vote and comment on it to make it more visible to the team. I myself will also bring it to the notice.

1

Please sign in to leave a comment.