-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce indentations for nested loops (#920)
* Reduce indentations for nested loops closes #867 * Keep indention for nested loops of mixed types --------- Co-authored-by: Lasath Fernando <devel@lasath.org>
- Loading branch information
1 parent
c80bab8
commit 65fbc9d
Showing
4 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
Src/CSharpier.Tests/FormattingTests/TestFiles/cs/NestedLoops.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
public class ClassName | ||
{ | ||
public void MethodName() | ||
{ | ||
foreach (var subsequence in sequence) | ||
foreach (var item in subsequence) | ||
item.DoSomething(); | ||
|
||
foreach (var item in subsequence) | ||
while (item.IsSomething()) | ||
item.DoSomething(); | ||
|
||
foreach (var item in sequence) | ||
do item.DoSomething(); | ||
while (false); | ||
|
||
foreach (var item in sequence) | ||
for (; ; ) | ||
item.DoSomething(); | ||
|
||
foreach (var subsequence in sequence) | ||
{ | ||
foreach (var item in subsequence) | ||
{ | ||
item.DoSomething(); | ||
item.DoSomething(); | ||
} | ||
} | ||
|
||
await foreach (var subsequence in sequence) | ||
await foreach (var item in subsequence) | ||
item.DoSomething(); | ||
|
||
foreach (var subsequence in sequence) | ||
await foreach (var item in subsequence) | ||
{ | ||
item.DoSomething(); | ||
item.DoSomething(); | ||
} | ||
|
||
while (true) | ||
foreach (var item in sequence) | ||
item.DoSomething(); | ||
|
||
while (true) | ||
while (true) | ||
do Console.WriteLine(); | ||
while (false); | ||
|
||
while (true) | ||
for (; ; ) | ||
Console.WriteLine(); | ||
|
||
while (true) | ||
{ | ||
foreach (var item in sequence) | ||
item.DoSomething(); | ||
} | ||
|
||
for (; ; ) | ||
foreach (var item in sequence) | ||
item.DoSomething(); | ||
|
||
for (; ; ) | ||
while (true) | ||
Console.WriteLine(); | ||
|
||
for (; ; ) | ||
do Console.WriteLine(); | ||
while (false); | ||
|
||
for (; ; ) | ||
for (; ; ) | ||
item.DoSomething(); | ||
|
||
for (; ; ) | ||
{ | ||
for (; ; ) | ||
Console.WriteLine(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters