Muokkaa

Jaa


.NET formatting options

The formatting options in this article apply to both C# and Visual Basic. These are options for code-style rule IDE0055.

Using directive options

Use these options to customize how you want using directives to be sorted and grouped:

Example .editorconfig file:

# .NET formatting rules
[*.{cs,vb}]
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = true

Tip

A separate C#-specific using directive rule IDE0065 is also available. That rule concerns whether using directives are placed inside or outside namespaces.

dotnet_sort_system_directives_first

Property Value Description
Option name dotnet_sort_system_directives_first
Applicable languages C# and Visual Basic
Introduced version Visual Studio 2017
Option values true Sort System.* using directives alphabetically, and place them before other using directives.
false Do not place System.* using directives before other using directives.
Default option value true

Code examples:

// dotnet_sort_system_directives_first = true
using System.Collections.Generic;
using System.Threading.Tasks;
using Octokit;

// dotnet_sort_system_directives_first = false
using System.Collections.Generic;
using Octokit;
using System.Threading.Tasks;

dotnet_separate_import_directive_groups

Property Value Description
Option name dotnet_separate_import_directive_groups
Applicable languages C# and Visual Basic
Introduced version Visual Studio 2017
Option values true Place a blank line between using directive groups.
false Do not place a blank line between using directive groups.
Default option value false

Code examples:

// dotnet_separate_import_directive_groups = true
using System.Collections.Generic;
using System.Threading.Tasks;

using Octokit;

// dotnet_separate_import_directive_groups = false
using System.Collections.Generic;
using System.Threading.Tasks;
using Octokit;

See also