Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions docs/fundamentals/code-analysis/style-rules/ide2000.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
title: "IDE2000: Avoid multiple blank lines"
description: "Learn about code analysis rule IDE2000: Avoid multiple blank lines"
ms.date: 08/19/2025
f1_keywords:
- IDE2000
helpviewer_keywords:
- IDE2000
dev_langs:
- CSharp
ai-usage: ai-assisted
---
# Avoid multiple blank lines (IDE2000)

| Property | Value |
|--------------------------|--------------------------------------------------------|
| **Rule ID** | IDE2000 |
| **Title** | Avoid multiple blank lines |
| **Category** | Style |
| **Subcategory** | Language rules (new-line preferences) |
| **Applicable languages** | C# and Visual Basic |
| **Options** | `dotnet_style_allow_multiple_blank_lines_experimental` |

> [!NOTE]
> This rule is experimental and subject to change or removal.

## Overview

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.

## Options

Options specify the behavior that you want the rule to enforce. For information about configuring options, see [Option format](language-rules.md#option-format).

### dotnet_style_allow_multiple_blank_lines_experimental

| Property | Value | Description |
|--------------------------|--------------------------------------------------------|-------------|
| **Option name** | `dotnet_style_allow_multiple_blank_lines_experimental` | |
| **Option values** | `true` | Allow multiple consecutive blank lines |
| | `false` | Don't allow consecutive blank lines |
| **Default option value** | `true` | |

## Example

```csharp
// dotnet_style_allow_multiple_blank_lines_experimental = true
if (true)
{
DoWork();
}


return;
```

```csharp
// dotnet_style_allow_multiple_blank_lines_experimental = false
if (true)
{
DoWork();
}

return;
```

## Suppress a warning

If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

```csharp
#pragma warning disable IDE2000
// The code that's violating the rule is on this line.
#pragma warning restore IDE2000
```

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.IDE2000.severity = none
```

To disable all of the code-style rules, set the severity for the category `Style` to `none` in the [configuration file](../configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_analyzer_diagnostic.category-style.severity = none
```

For more information, see [How to suppress code analysis warnings](../suppress-warnings.md).

## See also

- [New-line preferences](language-rules.md#new-line-preferences)
- [Code style language rules](language-rules.md)
- [Code style rules reference](index.md)
88 changes: 88 additions & 0 deletions docs/fundamentals/code-analysis/style-rules/ide2001.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
title: "IDE2001: Embedded statements must be on their own line"
description: "Learn about code analysis rule IDE2001: Embedded statements must be on their own line"
ms.date: 08/19/2025
f1_keywords:
- IDE2001
helpviewer_keywords:
- IDE2001
dev_langs:
- CSharp
- VB
ai-usage: ai-assisted
---
# Embedded statements must be on their own line (IDE2001)

| Property | Value |
|--------------------------|--------------------------------------------------------------------|
| **Rule ID** | IDE2001 |
| **Title** | Embedded statements must be on their own line |
| **Category** | Style |
| **Subcategory** | Language rules (new-line preferences) |
| **Applicable languages** | C# |
| **Options** | `csharp_style_allow_embedded_statements_on_same_line_experimental` |

> [!NOTE]
> This rule is experimental and subject to change or removal.

## Overview

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.

## Options

Options specify the behavior that you want the rule to enforce. For information about configuring options, see [Option format](language-rules.md#option-format).

### csharp_style_allow_embedded_statements_on_same_line_experimental

| Property | Value | Description |
|--------------------------|----------------------------------------------|-------------|
| **Option name** | `csharp_style_allow_embedded_statements_on_same_line_experimental` | |
| **Option values** | `true` | Allow embedded statements on same line as control keyword |
| | `false` | Require embedded statements to be on their own line |
| **Default option value** | `true` | |

## Example

```csharp
// csharp_style_allow_embedded_statements_on_same_line_experimental = true
for (int i = 0; i < 10; i++) Console.WriteLine(i);
```

```csharp
// csharp_style_allow_embedded_statements_on_same_line_experimental = false
for (int i = 0; i < 10; i++)
Console.WriteLine(i);
```

## Suppress a warning

If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

```csharp
#pragma warning disable IDE2001
// The code that's violating the rule is on this line.
#pragma warning restore IDE2001
```

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.IDE2001.severity = none
```

To disable all of the code-style rules, set the severity for the category `Style` to `none` in the [configuration file](../configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_analyzer_diagnostic.category-style.severity = none
```

For more information, see [How to suppress code analysis warnings](../suppress-warnings.md).

## See also

- [New-line preferences](language-rules.md#new-line-preferences)
- [Code style language rules](language-rules.md)
- [Code style rules reference](index.md)
99 changes: 99 additions & 0 deletions docs/fundamentals/code-analysis/style-rules/ide2002.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
title: "IDE2002: Consecutive braces must not have blank line between them"
description: "Learn about code analysis rule IDE2002: Consecutive braces must not have blank line between them"
ms.date: 08/19/2025
f1_keywords:
- IDE2002
helpviewer_keywords:
- IDE2002
dev_langs:
- CSharp
ai-usage: ai-assisted
---
# Consecutive braces must not have blank line between them (IDE2002)

| Property | Value |
|--------------------------|--------------------------------------------------------------------------|
| **Rule ID** | IDE2002 |
| **Title** | Consecutive braces must not have blank line between them |
| **Category** | Style |
| **Subcategory** | Language rules (new-line preferences) |
| **Applicable languages** | C# |
| **Options** | `csharp_style_allow_blank_lines_between_consecutive_braces_experimental` |

> [!NOTE]
> This rule is experimental and subject to change or removal.

## Overview

This style rule enforces that consecutive braces should not have blank lines between them. This helps maintain consistent and clean code formatting.

## Options

Options specify the behavior that you want the rule to enforce. For information about configuring options, see [Option format](language-rules.md#option-format).

### csharp_style_allow_blank_lines_between_consecutive_braces_experimental

| Property | Value | Description |
|--------------------------|----------------------------------------------|-------------|
| **Option name** | `csharp_style_allow_blank_lines_between_consecutive_braces_experimental` | |
| **Option values** | `true` | Allow blank lines between consecutive braces |
| | `false` | Don't allow blank lines between consecutive braces |
| **Default option value** | `true` | |

## Example

```csharp
// csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true
public void Method
{
if (true)
{
DoWork();
}

}
```

```csharp
// csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false
public void Method
{
if (true)
{
DoWork();
}
}
```

## Suppress a warning

If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

```csharp
#pragma warning disable IDE2002
// The code that's violating the rule is on this line.
#pragma warning restore IDE2002
```

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.IDE2002.severity = none
```

To disable all of the code-style rules, set the severity for the category `Style` to `none` in the [configuration file](../configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_analyzer_diagnostic.category-style.severity = none
```

For more information, see [How to suppress code analysis warnings](../suppress-warnings.md).

## See also

- [New-line preferences](language-rules.md#new-line-preferences)
- [Code style language rules](language-rules.md)
- [Code style rules reference](index.md)
95 changes: 95 additions & 0 deletions docs/fundamentals/code-analysis/style-rules/ide2003.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
title: "IDE2003: Blank line required between block and subsequent statement"
description: "Learn about code analysis rule IDE2003: Blank line required between block and subsequent statement"
ms.date: 08/19/2025
f1_keywords:
- IDE2003
helpviewer_keywords:
- IDE2003
dev_langs:
- CSharp
ai-usage: ai-assisted
---
# Blank line required between block and subsequent statement (IDE2003)

| Property | Value |
|--------------------------|---------------------------------------------------------------------|
| **Rule ID** | IDE2003 |
| **Title** | Blank line required between block and subsequent statement |
| **Category** | Style |
| **Subcategory** | Language rules (new-line preferences) |
| **Applicable languages** | C# and Visual Basic |
| **Options** | `dotnet_style_allow_statement_immediately_after_block_experimental` |

> [!NOTE]
> This rule is experimental and subject to change or removal.

## Overview

This style rule enforces that there should be a blank line between a block statement and any subsequent statement at the same scope level. This improves code readability by visually separating different logical sections of code.

## Options

Options specify the behavior that you want the rule to enforce. For information about configuring options, see [Option format](language-rules.md#option-format).

### dotnet_style_allow_statement_immediately_after_block_experimental

| Property | Value | Description |
|--------------------------|----------------------------------------------|-------------|
| **Option name** | `dotnet_style_allow_statement_immediately_after_block_experimental` | |
| **Option values** | `true` | Allow subsequent statement to immediately follow block statement without a blank line in between |
| | `false` | Require a blank line between a block statement and the subsequent statement |
| **Default option value** | `true` | |

## Example

```csharp
// dotnet_style_allow_statement_immediately_after_block_experimental = true
if (true)
{
DoWork();
}
return;
```

```csharp
// dotnet_style_allow_statement_immediately_after_block_experimental = false
if (true)
{
DoWork();
}

return;
```

## Suppress a warning

If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

```csharp
#pragma warning disable IDE2003
// The code that's violating the rule is on this line.
#pragma warning restore IDE2003
```

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.IDE2003.severity = none
```

To disable all of the code-style rules, set the severity for the category `Style` to `none` in the [configuration file](../configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_analyzer_diagnostic.category-style.severity = none
```

For more information, see [How to suppress code analysis warnings](../suppress-warnings.md).

## See also

- [New-line preferences](language-rules.md#new-line-preferences)
- [Code style language rules](language-rules.md)
- [Code style rules reference](index.md)
Loading