From 6da4e9286dffd5bc1ad17665bf236e66875f7388 Mon Sep 17 00:00:00 2001 From: Julien Richard Date: Tue, 3 Sep 2024 10:15:30 +0200 Subject: [PATCH 1/3] More precise explanation for dotnet format subcommands --- docs/core/tools/dotnet-format.md | 33 ++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/docs/core/tools/dotnet-format.md b/docs/core/tools/dotnet-format.md index 6e78575124d83..2208b5a7b501c 100644 --- a/docs/core/tools/dotnet-format.md +++ b/docs/core/tools/dotnet-format.md @@ -105,7 +105,7 @@ The `dotnet format style` subcommand only runs formatting rules associated with * **`--diagnostics `** - A space-separated list of diagnostic IDs to use as a filter when fixing code style or third-party issues. Default value is whichever IDs are listed in the *.editorconfig* file. For a list of built-in analyzer rule IDs that you can specify, see the [list of IDs for code-analysis style rules](../../fundamentals/code-analysis/style-rules/index.md). + A space-separated list of diagnostic IDs to use as a filter when fixing code style issues. Default value is whichever IDs are listed in the *.editorconfig* file. For a list of built-in code style analyzer rule IDs that you can specify, see the [list of IDs for code-analysis style rules](../../fundamentals/code-analysis/style-rules/index.md). * **`--severity`** @@ -113,17 +113,17 @@ The `dotnet format style` subcommand only runs formatting rules associated with ### Analyzers -`dotnet format analyzers` - Formats code to match `editorconfig` settings for analyzers. +`dotnet format analyzers` - Formats code to match `editorconfig` settings for analyzers (excluding code style rules). #### Description -The `dotnet format analyzers` subcommand only runs formatting rules associated with analyzers. For a list of analyzer rules that you can specify in your `editorconfig` file, see [Code style rules](../../fundamentals/code-analysis/style-rules/index.md). +The `dotnet format analyzers` subcommand only runs formatting rules associated with analyzers. For a list of analyzer rules that you can specify in your `editorconfig` file, see [Quality rules](../../fundamentals/code-analysis/quality-rules/index.md). ##### Options * **`--diagnostics `** - A space-separated list of diagnostic IDs to use as a filter when fixing code style or third-party issues. Default value is whichever IDs are listed in the *.editorconfig* file. For a list of built-in analyzer rule IDs that you can specify, see the [list of IDs for code-analysis style rules](../../fundamentals/code-analysis/style-rules/index.md). + A space-separated list of diagnostic IDs to use as a filter when fixing non code style issues. Default value is whichever IDs are listed in the *.editorconfig* file. For a list of built-in analyzer rule IDs that you can specify, see the [list of IDs for quality rules](../../fundamentals/code-analysis/quality-rules/index.md). For third-party analyzers please refer to their documentation. * **`--severity`** @@ -154,3 +154,28 @@ The `dotnet format analyzers` subcommand only runs formatting rules associated w ```dotnetcli dotnet format --include ./src/ ./tests/ --exclude ./src/submodule-a/ ``` +* Fix a specific **code style** issue: + + ```dotnetcli + dotnet format style --diagnostics IDExxxx --severity info + ``` + +* Fix all **code style** issues that has severity `info`, `warning` or `error`: + + ```dotnetcli + dotnet format style --severity info + ``` + +* Fix a specific (non code style) analyzer issue: + + ```dotnetcli + dotnet format analyzers --diagnostics CAxxxx --severity warn + ``` + +* Fix all non code style issues that has severity `info`, `warning` or `error`: + + ```dotnetcli + dotnet format analyzers --severity info + ``` + + From 01884362108b53b191085cddd0b80dd44fdbc052 Mon Sep 17 00:00:00 2001 From: Julien Richard Date: Tue, 3 Sep 2024 18:39:57 +0200 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Tom Dykstra --- docs/core/tools/dotnet-format.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/core/tools/dotnet-format.md b/docs/core/tools/dotnet-format.md index 2208b5a7b501c..946692cae18bb 100644 --- a/docs/core/tools/dotnet-format.md +++ b/docs/core/tools/dotnet-format.md @@ -105,7 +105,7 @@ The `dotnet format style` subcommand only runs formatting rules associated with * **`--diagnostics `** - A space-separated list of diagnostic IDs to use as a filter when fixing code style issues. Default value is whichever IDs are listed in the *.editorconfig* file. For a list of built-in code style analyzer rule IDs that you can specify, see the [list of IDs for code-analysis style rules](../../fundamentals/code-analysis/style-rules/index.md). + A space-separated list of diagnostic IDs to use as a filter when fixing code style issues. Default value is whichever IDs are listed in the *.editorconfig* file. For a list of built-in code style analyzer rule IDs that you can specify, see the [list of IDs for code-analysis style rules](../../fundamentals/code-analysis/style-rules/index.md). * **`--severity`** @@ -123,7 +123,7 @@ The `dotnet format analyzers` subcommand only runs formatting rules associated w * **`--diagnostics `** - A space-separated list of diagnostic IDs to use as a filter when fixing non code style issues. Default value is whichever IDs are listed in the *.editorconfig* file. For a list of built-in analyzer rule IDs that you can specify, see the [list of IDs for quality rules](../../fundamentals/code-analysis/quality-rules/index.md). For third-party analyzers please refer to their documentation. + A space-separated list of diagnostic IDs to use as a filter when fixing non code style issues. Default value is whichever IDs are listed in the *.editorconfig* file. For a list of built-in analyzer rule IDs that you can specify, see the [list of IDs for quality rules](../../fundamentals/code-analysis/quality-rules/index.md). For third-party analyzers refer to their documentation. * **`--severity`** @@ -157,10 +157,10 @@ The `dotnet format analyzers` subcommand only runs formatting rules associated w * Fix a specific **code style** issue: ```dotnetcli - dotnet format style --diagnostics IDExxxx --severity info + dotnet format style --diagnostics IDE0005 --severity info ``` -* Fix all **code style** issues that has severity `info`, `warning` or `error`: +* Fix all **code style** issues that have severity `info`, `warning` or `error`: ```dotnetcli dotnet format style --severity info @@ -169,13 +169,11 @@ The `dotnet format analyzers` subcommand only runs formatting rules associated w * Fix a specific (non code style) analyzer issue: ```dotnetcli - dotnet format analyzers --diagnostics CAxxxx --severity warn + dotnet format analyzers --diagnostics CA1831 --severity warn ``` -* Fix all non code style issues that has severity `info`, `warning` or `error`: +* Fix all non code style issues that have severity `info`, `warning` or `error`: ```dotnetcli dotnet format analyzers --severity info ``` - - From 7a4e39c8ec737200539b2f6b17d68c1604b4bf5b Mon Sep 17 00:00:00 2001 From: Tom Dykstra Date: Tue, 3 Sep 2024 10:09:28 -0700 Subject: [PATCH 3/3] Update docs/core/tools/dotnet-format.md --- docs/core/tools/dotnet-format.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/core/tools/dotnet-format.md b/docs/core/tools/dotnet-format.md index 946692cae18bb..6dbffdda791ac 100644 --- a/docs/core/tools/dotnet-format.md +++ b/docs/core/tools/dotnet-format.md @@ -154,6 +154,7 @@ The `dotnet format analyzers` subcommand only runs formatting rules associated w ```dotnetcli dotnet format --include ./src/ ./tests/ --exclude ./src/submodule-a/ ``` + * Fix a specific **code style** issue: ```dotnetcli