Skip to content

Commit 1002c7e

Browse files
committed
add options
1 parent 5c5c80f commit 1002c7e

File tree

9 files changed

+221
-359
lines changed

9 files changed

+221
-359
lines changed

docs/fundamentals/code-analysis/style-rules/ide2000.md

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,62 +6,59 @@ f1_keywords:
66
- IDE2000
77
helpviewer_keywords:
88
- IDE2000
9-
author: gewarren
10-
ms.author: gewarren
119
dev_langs:
1210
- CSharp
13-
ai-usage: ai-generated
11+
ai-usage: ai-assisted
1412
---
1513
# Avoid multiple blank lines (IDE2000)
1614

17-
| Property | Value |
18-
| ------------------------ | ---------------------------------------- |
19-
| **Rule ID** | IDE2000 |
20-
| **Title** | Avoid multiple blank lines |
21-
| **Category** | Style |
22-
| **Subcategory** | Language rules (new-line preferences) |
23-
| **Applicable languages** | C# |
15+
| Property | Value |
16+
|--------------------------|--------------------------------------------------------|
17+
| **Rule ID** | IDE2000 |
18+
| **Title** | Avoid multiple blank lines |
19+
| **Category** | Style |
20+
| **Subcategory** | Language rules (new-line preferences) |
21+
| **Applicable languages** | C# and Visual Basic |
22+
| **Options** | `dotnet_style_allow_multiple_blank_lines_experimental` |
2423

2524
## Overview
2625

2726
This style rule flags the presence of multiple consecutive blank lines in source code. Having multiple blank lines can reduce code readability and is generally considered poor formatting practice.
2827

29-
[!INCLUDE [enabled-on-build-never](../includes/enabled-on-build-never.md)]
28+
## Options
3029

31-
## Example
32-
33-
```csharp
34-
// Violates IDE2000 - multiple blank lines
35-
public class Example
36-
{
30+
Options specify the behavior that you want the rule to enforce. For information about configuring options, see [Option format](language-rules.md#option-format).
3731

32+
### dotnet_style_allow_multiple_blank_lines_experimental
3833

39-
public void Method1()
40-
{
41-
// Code here.
42-
}
34+
| Property | Value | Description |
35+
|--------------------------|--------------------------------------------------------|-------------|
36+
| **Option name** | `dotnet_style_allow_multiple_blank_lines_experimental` | |
37+
| **Option values** | `true` | Allow multiple consecutive blank lines |
38+
| | `false` | Don't allow consecutive blank lines |
39+
| **Default option value** | `true` | |
4340

41+
## Example
4442

45-
public void Method2()
46-
{
47-
// Code here.
48-
}
43+
```csharp
44+
// dotnet_style_allow_multiple_blank_lines_experimental = true
45+
if (true)
46+
{
47+
DoWork();
4948
}
5049

51-
// Follows IDE2000 - single blank lines for separation
52-
public class Example
53-
{
5450

55-
public void Method1()
56-
{
57-
// Code here.
58-
}
51+
return;
52+
```
5953

60-
public void Method2()
61-
{
62-
// Code here.
63-
}
54+
```csharp
55+
// dotnet_style_allow_multiple_blank_lines_experimental = false
56+
if (true)
57+
{
58+
DoWork();
6459
}
60+
61+
return;
6562
```
6663

6764
## Suppress a warning
@@ -94,4 +91,4 @@ For more information, see [How to suppress code analysis warnings](../suppress-w
9491

9592
- [New-line preferences](language-rules.md#new-line-preferences)
9693
- [Code style language rules](language-rules.md)
97-
- [Code style rules reference](index.md)
94+
- [Code style rules reference](index.md)

docs/fundamentals/code-analysis/style-rules/ide2001.md

Lines changed: 26 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,67 +6,50 @@ f1_keywords:
66
- IDE2001
77
helpviewer_keywords:
88
- IDE2001
9-
author: gewarren
10-
ms.author: gewarren
119
dev_langs:
1210
- CSharp
1311
- VB
14-
ai-usage: ai-generated
12+
ai-usage: ai-assisted
1513
---
1614
# Embedded statements must be on their own line (IDE2001)
1715

18-
| Property | Value |
19-
| ------------------------ | ---------------------------------------- |
20-
| **Rule ID** | IDE2001 |
21-
| **Title** | Embedded statements must be on their own line |
22-
| **Category** | Style |
23-
| **Subcategory** | Language rules (new-line preferences) |
24-
| **Applicable languages** | C# and Visual Basic |
16+
| Property | Value |
17+
|--------------------------|--------------------------------------------------------------------|
18+
| **Rule ID** | IDE2001 |
19+
| **Title** | Embedded statements must be on their own line |
20+
| **Category** | Style |
21+
| **Subcategory** | Language rules (new-line preferences) |
22+
| **Applicable languages** | C# |
23+
| **Options** | `csharp_style_allow_embedded_statements_on_same_line_experimental` |
2524

2625
## Overview
2726

2827
This style rule enforces that embedded statements (statements that are part of control flow constructs like `if`, `while`, and `for`) must be placed on their own line rather than on the same line as the control keyword.
2928

30-
[!INCLUDE [enabled-on-build-never](../includes/enabled-on-build-never.md)]
29+
## Options
30+
31+
Options specify the behavior that you want the rule to enforce. For information about configuring options, see [Option format](language-rules.md#option-format).
32+
33+
### csharp_style_allow_embedded_statements_on_same_line_experimental
34+
35+
| Property | Value | Description |
36+
|--------------------------|----------------------------------------------|-------------|
37+
| **Option name** | `csharp_style_allow_embedded_statements_on_same_line_experimental` | |
38+
| **Option values** | `true` | Allow embedded statements on same line as control keyword |
39+
| | `false` | Require embedded statements to be on their own line |
40+
| **Default option value** | `true` | |
3141

3242
## Example
3343

3444
```csharp
35-
// Violates IDE2001 - embedded statement on same line
36-
if (condition) DoSomething();
37-
while (condition) ProcessItem();
45+
// csharp_style_allow_embedded_statements_on_same_line_experimental = true
3846
for (int i = 0; i < 10; i++) Console.WriteLine(i);
47+
```
3948

40-
// Follows IDE2001 - embedded statements on separate lines
41-
if (condition)
42-
DoSomething();
43-
44-
while (condition)
45-
ProcessItem();
46-
49+
```csharp
50+
// csharp_style_allow_embedded_statements_on_same_line_experimental = false
4751
for (int i = 0; i < 10; i++)
4852
Console.WriteLine(i);
49-
50-
// Also acceptable with braces
51-
if (condition)
52-
{
53-
DoSomething();
54-
}
55-
```
56-
57-
```vb
58-
' Violates IDE2001 - embedded statement on same line
59-
If condition Then DoSomething()
60-
While condition : ProcessItem() : End While
61-
62-
' Follows IDE2001 - embedded statements on separate lines
63-
If condition Then
64-
DoSomething()
65-
End If
66-
67-
While condition
68-
ProcessItem()
69-
End While
7053
```
7154

7255
## Suppress a warning
@@ -99,4 +82,4 @@ For more information, see [How to suppress code analysis warnings](../suppress-w
9982

10083
- [New-line preferences](language-rules.md#new-line-preferences)
10184
- [Code style language rules](language-rules.md)
102-
- [Code style rules reference](index.md)
85+
- [Code style rules reference](index.md)

docs/fundamentals/code-analysis/style-rules/ide2002.md

Lines changed: 33 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -6,99 +6,63 @@ f1_keywords:
66
- IDE2002
77
helpviewer_keywords:
88
- IDE2002
9-
author: gewarren
10-
ms.author: gewarren
119
dev_langs:
1210
- CSharp
13-
- VB
14-
ai-usage: ai-generated
11+
ai-usage: ai-assisted
1512
---
1613
# Consecutive braces must not have blank line between them (IDE2002)
1714

18-
| Property | Value |
19-
| ------------------------ | ---------------------------------------- |
20-
| **Rule ID** | IDE2002 |
21-
| **Title** | Consecutive braces must not have blank line between them |
22-
| **Category** | Style |
23-
| **Subcategory** | Language rules (new-line preferences) |
24-
| **Applicable languages** | C# and Visual Basic |
15+
| Property | Value |
16+
|--------------------------|--------------------------------------------------------------------------|
17+
| **Rule ID** | IDE2002 |
18+
| **Title** | Consecutive braces must not have blank line between them |
19+
| **Category** | Style |
20+
| **Subcategory** | Language rules (new-line preferences) |
21+
| **Applicable languages** | C# |
22+
| **Options** | `csharp_style_allow_blank_lines_between_consecutive_braces_experimental` |
2523

2624
## Overview
2725

28-
This style rule enforces that consecutive closing and opening braces should not have blank lines between them. This helps maintain consistent and clean code formatting.
26+
This style rule enforces that consecutive braces should not have blank lines between them. This helps maintain consistent and clean code formatting.
2927

30-
[!INCLUDE [enabled-on-build-never](../includes/enabled-on-build-never.md)]
28+
## Options
29+
30+
Options specify the behavior that you want the rule to enforce. For information about configuring options, see [Option format](language-rules.md#option-format).
31+
32+
### csharp_style_allow_blank_lines_between_consecutive_braces_experimental
33+
34+
| Property | Value | Description |
35+
|--------------------------|----------------------------------------------|-------------|
36+
| **Option name** | `csharp_style_allow_blank_lines_between_consecutive_braces_experimental` | |
37+
| **Option values** | `true` | Allow blank lines between consecutive braces |
38+
| | `false` | Don't allow blank lines between consecutive braces |
39+
| **Default option value** | `true` | |
3140

3241
## Example
3342

3443
```csharp
35-
// Violates IDE2002 - blank line between consecutive braces
36-
public class Example
44+
// csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true
45+
public void Method
3746
{
38-
public void Method1()
39-
{
40-
if (condition)
41-
{
42-
DoSomething();
43-
}
44-
45-
}
46-
47-
public void Method2()
47+
if (true)
4848
{
49-
// Another method.
49+
DoWork();
5050
}
5151

5252
}
53+
```
5354

54-
// Follows IDE2002 - no blank lines between consecutive braces
55-
public class Example
55+
```csharp
56+
// csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false
57+
public void Method
5658
{
57-
public void Method1()
59+
if (true)
5860
{
59-
if (condition)
60-
{
61-
DoSomething();
62-
}
63-
}
64-
65-
public void Method2()
66-
{
67-
// Another method.
61+
DoWork();
6862
}
6963
}
7064
```
7165

72-
```vb
73-
' Violates IDE2002 - blank line between consecutive End statements
74-
Public Class Example
75-
Public Sub Method1()
76-
If condition Then
77-
DoSomething()
78-
End If
79-
80-
End Sub
81-
82-
Public Sub Method2()
83-
' Another method.
84-
End Sub
85-
86-
End Class
87-
88-
' Follows IDE2002 - no blank lines between consecutive End statements
89-
Public Class Example
90-
Public Sub Method1()
91-
If condition Then
92-
DoSomething()
93-
End If
94-
End Sub
95-
96-
Public Sub Method2()
97-
' Another method.
98-
End Sub
99-
End Class
100-
```
101-
10266
## Suppress a warning
10367

10468
If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.
@@ -129,4 +93,4 @@ For more information, see [How to suppress code analysis warnings](../suppress-w
12993

13094
- [New-line preferences](language-rules.md#new-line-preferences)
13195
- [Code style language rules](language-rules.md)
132-
- [Code style rules reference](index.md)
96+
- [Code style rules reference](index.md)

0 commit comments

Comments
 (0)