Roslyn: Formatting of empty for loops: "for(;;)"

Created on 8 Apr 2016  路  5Comments  路  Source: dotnet/roslyn

Paste

``` C#
for (;;)


**Expected Behavior**:

``` C#
for ( ; ; )

Actual Behavior:

C# for (;;)

Area-IDE Bug help wanted

Most helpful comment

Why would for ( ; ; ) be the expected behavior? Isn't for (;;) more common, if you decide to write an infinite loop as for?

All 5 comments

Why would for ( ; ; ) be the expected behavior? Isn't for (;;) more common, if you decide to write an infinite loop as for?

VS2005 through VS2013 all formatted it as for ( ; ; ), so I would expect that to be more common.

I tested VS2010, VS2012, VS2013 (all settings were reset to the default values) and they all formatted it as for (; ; ), i.e., no space after (.

I personally prefer for (;;) though.

Sounds like neither is correct given that both ignore the formatting options specified by the user. Either it should be for (; ; ) by default, or there should be another option pertaining to the format of for loops without initializers, conditions and/or iterators.

@HaloFour The old formatting engine had a special case for this IIRC, it's not necessarily worth another option.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

codingonHP picture codingonHP  路  3Comments

OndrejPetrzilka picture OndrejPetrzilka  路  3Comments

vbcodec picture vbcodec  路  3Comments

nlwolf picture nlwolf  路  3Comments

asvishnyakov picture asvishnyakov  路  3Comments