Skip to content

Split up formatting rules doc #29912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 20, 2022
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
8 changes: 4 additions & 4 deletions .openpublishing.redirection.fundamentals.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
"source_path_from_root": "/docs/fundamentals/code-analysis/quality-rules/publish-warnings.md",
"redirect_url": "/dotnet/core/deploying/single-file/warnings/overview"
},
{
"source_path_from_root": "/docs/fundamentals/code-analysis/style-rules/formatting-rules.md",
"redirect_url": "/dotnet/fundamentals/code-analysis/style-rules/ide0055"
},
{
"source_path_from_root": "/docs/fundamentals/code-analysis/style-rules/ide0003.md",
"redirect_url": "/dotnet/fundamentals/code-analysis/style-rules/ide0003-ide0009"
Expand Down Expand Up @@ -80,10 +84,6 @@
"source_path_from_root": "/docs/fundamentals/code-analysis/style-rules/ide0054.md",
"redirect_url": "/dotnet/fundamentals/code-analysis/style-rules/ide0054-ide0074"
},
{
"source_path_from_root": "/docs/fundamentals/code-analysis/style-rules/ide0055.md",
"redirect_url": "/dotnet/fundamentals/code-analysis/style-rules/formatting-rules"
},
{
"source_path_from_root": "/docs/fundamentals/code-analysis/style-rules/ide0074.md",
"redirect_url": "/dotnet/fundamentals/code-analysis/style-rules/ide0054-ide0074"
Expand Down
2 changes: 1 addition & 1 deletion docs/core/tools/dotnet-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ None of the options below are required for the `dotnet format` command to succee

#### Description

The `dotnet format whitespace` subcommand will only run formatting rules associated with whitespace formatting. For a complete list of possible formatting options that you can specify in your *.editorconfig* file, see the [C# formatting rules](../../fundamentals/code-analysis/style-rules/formatting-rules.md#c-formatting-rules).
The `dotnet format whitespace` subcommand will only run formatting rules associated with whitespace formatting. For a complete list of possible formatting options that you can specify in your *.editorconfig* file, see the [C# formatting options](../../fundamentals/code-analysis/style-rules/csharp-formatting-options.md).

#### Options

Expand Down
19 changes: 13 additions & 6 deletions docs/fundamentals/code-analysis/code-style-rule-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ ms.date: 09/25/2020
author: gewarren
ms.author: gewarren
---
# Code style rule options
# Code-style rule options

You can define and maintain consistent *code style* in your codebase by defining .NET code style rule options in an [EditorConfig](/visualstudio/ide/create-portable-custom-editor-options) file. These rules are surfaced by various development IDEs, such as Visual Studio, as you edit your code. For .NET projects, these rules can also be [enforced at build time](overview.md#code-style-analysis). You can enable or disable individual rules and configure the degree to which you want each rule enforced, via a severity level.
You can define and maintain consistent *code style* in your codebase by defining .NET code-style rules and their associated options in a [configuration file](configuration-files.md). These rules are surfaced by various development IDEs, such as Visual Studio, as you edit your code. For .NET projects, these rules can also be [enforced at build time](overview.md#code-style-analysis). You can enable or disable individual rules and configure the degree to which you want each rule enforced, via a severity level.

> [!TIP]
>
Expand All @@ -21,15 +21,22 @@ Code style rules are divided into following subcategories:

- [Unnecessary code rules](style-rules/unnecessary-code-rules.md)

- [Formatting rules](style-rules/formatting-rules.md)
- [Formatting rules](style-rules/ide0055.md)

- [Naming rules](style-rules/naming-rules.md)

Each of these subcategories defines its own syntax for specifying options. For more information about these rules and the corresponding options, see [Code style rule reference](style-rules/index.md).
Each of these subcategories defines its own syntax for specifying options. For more information about these rules and the corresponding options, see [Code-style rule reference](style-rules/index.md).

## Example EditorConfig file

To help you get started, here is an example *.editorconfig* file with the default options.
To help you get started, here's an example *.editorconfig* file with the default options.

> [!NOTE]
> The concise syntax seen in this file, where the severity is specified after the option value for language rules, for example, `dotnet_style_readonly_field = true:suggestion`, is only fully understood by Visual Studio. Compilers don't understand the `:<severity-level>` suffix and it is ignored if you compile your code from the command line. To set severity in a way that's understood by both Visual Studio and the C# and Visual Basic compilers, set the severity on the rule that contains the option by using the following syntax:
>
> `dotnet_diagnostic.<rule-ID>.severity = <severity-level>`
>
> For more information, see [Option format](style-rules/language-rules.md#option-format).

> [!TIP]
> In Visual Studio, you can add the following default .NET .editorconfig file to your project from the **Add New Item** dialog box.
Expand Down Expand Up @@ -95,7 +102,7 @@ dotnet_style_prefer_conditional_expression_over_return = true:silent
###############################
# Style Definitions
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
# Use PascalCase for constant fields
# Use PascalCase for constant fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
Expand Down
2 changes: 1 addition & 1 deletion docs/fundamentals/code-analysis/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The most common option you'll configure is a [rule's severity](#severity-level).
You can also configure additional options to customize rule behavior:

- Code quality rules have [options](code-quality-rule-options.md) to configure behavior, such as which method names a rule should apply to.
- Code style rules have [custom code style options](code-style-rule-options.md).
- Code style rules have [options](code-style-rule-options.md) to define style preferences, such as where new lines are desirable.
- Third-party analyzer rules can define their own configuration options, with custom key names and value formats.

## General options
Expand Down
Loading