Skip to content

Commit 6062607

Browse files
bkoelmandennisdoomen
authored andcommitted
Formatting for expr-bodied-members, initializers (#118)
1 parent e00b560 commit 6062607

1 file changed

Lines changed: 21 additions & 11 deletions

File tree

Src/Guidelines/2400_LayoutGuidelines.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,38 @@ NOTE: Requires Markdown Extra. See http://michelf.ca/projects/php-markdown/extra
1515
- Add a space around operators like `+`, `-`, `==`, etc.
1616

1717
- Always put opening and closing braces on a new line.
18-
- Don't indent object Initializers and initialize each property on a new line, so use a format like this:
19-
20-
var dto = new ConsumerDto()
21-
{
22-
Id = 123,
23-
Name = "Microsoft",
24-
PartnerShip = PartnerShip.Gold
25-
}
2618

27-
- Don't indent lambda statements and use a format like this:
19+
- Don't indent object/collection initializers and initialize each property on a new line, so use a format like this:
20+
21+
var dto = new ConsumerDto
22+
{
23+
Id = 123,
24+
Name = "Microsoft",
25+
PartnerShip = PartnerShip.Gold,
26+
ShoppingCart =
27+
{
28+
["VisualStudio"] = 1
29+
}
30+
};
31+
32+
- Don't indent lambda statement blocks and use a format like this:
2833

2934
methodThatTakesAnAction.Do(x =>
3035
{
3136
// do something like this
3237
}
3338

39+
- Keep expression-bodied-members on one line. Break long lines after the arrow sign, like this:
40+
41+
private string GetLongText =>
42+
"ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC";
43+
3444
- Put the entire LINQ statement on one line, or start each keyword at the same indentation, like this:
35-
45+
3646
var query = from product in products where product.Price > 10 select product;
3747

3848
or
39-
49+
4050
var query =
4151
from product in products
4252
where product.Price > 10

0 commit comments

Comments
 (0)