Menu

#615 Don't indent nested 'using' statements if they don't have curly braces

Future
closed
nobody
None
C#
5
2016-09-23
2015-01-13
Scott Bilas
No

A common programming pattern in C# is this:

using (var x = X())
using (var y = Y())
{
}

The using statements are lined up because they're sort of like variable declarations. Most importantly: this is how Microsoft Visual Studio will indent things if you use "Format Document".

However, when uncrustified with a null config, I get this:

using (X())
    using (Y())
    {
    }

The indentation of using's should only happen if there are curly braces around the nested using's. This is truly special to the using statement, and not something we should do with for, while, etc.

Discussion

  • Scott Bilas

    Scott Bilas - 2015-01-13

    Oops - the uncrustified version is incorrect. Pasted the wrong sample. Here's the output it leaves:

    using (var x = X())
        using (var y = Y())
        {
        }
    

    (Indentation is the same, just the vars were missing. Doesn't materially affect the bug.)

     
  • Mihai Popescu

    Mihai Popescu - 2016-07-15

    Issue still present. Mabye it should be moved to github.

     
  • Guy Maurel

    Guy Maurel - 2016-09-23
    • status: open --> closed
     
  • Guy Maurel

    Guy Maurel - 2016-09-23