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
Update documentation for analyzers #722
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# 3rd Party Analyzers | ||
|
||
## How to add analyzers to a project | ||
|
||
3rd party analyzers are discovered from the `<PackageReferences>` specified in the workspace project files. | ||
|
||
*Example:* | ||
|
||
Add the StyleCop analyzer package to a simple console project file. | ||
|
||
```diff | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
+ <ItemGroup> | ||
+ <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" /> | ||
+ </ItemGroup> | ||
|
||
</Project> | ||
``` | ||
|
||
## How to configure analyzer severity | ||
|
||
The options specified in .editorconfig files are recognized by the pattern `dotnet_diagnostic.<diagnostic-id>.severity = <value>`. `<diagnostic-id>` represents the diagnostic ID matched by the compiler, case-insensitively, to be configured. `<value>` must be one of the following: error, warn, info, hidden, suppress. | ||
|
||
*Example:* | ||
|
||
Configure the StyleCop analyzer so that empty comments are errors. | ||
|
||
```ini | ||
[*.{cs,vb}] | ||
|
||
# The C# comment does not contain any comment text. | ||
dotnet_diagnostic.SA1120.severity = error | ||
``` | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
The dotnet-format global tool supports the core set of EditorConfig options*: | ||
# Supported .editorconfig options | ||
The dotnet-format global tool supports the core set of [EditorConfig options](https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties)* as well as the [.NET coding convention settings for EditorConfig](https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference?view=vs-2019)**. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thought it was better to simplify this file and point users to the vs editorconfig docs. |
||
|
||
## Core options | ||
- indent_style | ||
- indent_size | ||
- tab_width | ||
|
@@ -8,61 +10,6 @@ The dotnet-format global tool supports the core set of EditorConfig options*: | |
- insert_final_newline | ||
- root | ||
|
||
[*] The option trim_trailing_whitespace is not supported. Currently insignificant whitespace is **always** removed by the formatter. | ||
[*] The options `trim_trailing_whitespace` and `max_line_length` are not supported. Currently insignificant whitespace is **always** removed by the formatter. | ||
|
||
In addition dotnet-format supports a subset of the [.NET coding convention settings for EditorConfig](https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference?view=vs-2017). | ||
|
||
# Formatting conventions | ||
Most of the rules for formatting conventions have the following format: | ||
|
||
`rule_name = false|true` | ||
|
||
You specify either `true` (prefer this style) or `false` (do not prefer this style). You do not specify a severity. For a few rules, instead of `true` or `false`, you specify other values to describe when and where to apply the rule. | ||
|
||
## C# formatting settings | ||
The formatting rules in this section apply only to C# code. | ||
|
||
**Newline options** | ||
These formatting rules concern the use of new lines to format code. | ||
|
||
- csharp_new_line_before_open_brace (default value: `all`) | ||
- csharp_new_line_before_else (default value: `true`) | ||
- csharp_new_line_before_catch (default value: `true`) | ||
- csharp_new_line_before_finally (default value: `true`) | ||
- csharp_new_line_before_members_in_object_initializers (default value: `true`) | ||
- csharp_new_line_before_members_in_anonymous_types (default value: `true`) | ||
- csharp_new_line_between_query_expression_clauses (default value: `true`) | ||
|
||
**Indentation options** | ||
These formatting rules concern the use of indentation to format code. | ||
|
||
- csharp_indent_case_contents (default value: `true`) | ||
- csharp_indent_switch_labels (default value: `true`) | ||
- csharp_indent_labels (default value: `no_change`) | ||
|
||
**Spacing options** | ||
These formatting rules concern the use of space characters to format code. | ||
|
||
- csharp_space_after_cast (default value: `false`) | ||
- csharp_space_after_keywords_in_control_flow_statements (default value: `true`) | ||
- csharp_space_between_method_declaration_parameter_list_parentheses (default value: `false`) | ||
- csharp_space_between_method_call_parameter_list_parentheses (default value: `false`) | ||
- csharp_space_between_parentheses (default value: `false`) | ||
- csharp_space_before_colon_in_inheritance_clause (default value: `true`) | ||
- csharp_space_after_colon_in_inheritance_clause (default value: `true`) | ||
- csharp_space_around_binary_operators (default value: `before_and_after`) | ||
- csharp_space_between_method_declaration_empty_parameter_list_parentheses (default value: `false`) | ||
- csharp_space_between_method_call_name_and_opening_parenthesis (default value: `false`) | ||
- csharp_space_between_method_call_empty_parameter_list_parentheses (default value: `false`) | ||
|
||
**Wrapping options** | ||
These formatting rules concern the use of single lines versus separate lines for statements and code blocks. | ||
|
||
- csharp_preserve_single_line_statements (default value: `true`) | ||
- csharp_preserve_single_line_blocks (default value: `true`) | ||
|
||
**Organize using directives** | ||
These formatting rules concern the sorting and display of using directives and Imports statements. | ||
|
||
- dotnet_sort_system_directives_first (default value: `true`) | ||
- dotnet_separate_import_directive_groups (default value: `true`) | ||
[**] [Formatting conventions](https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-formatting-conventions?view=vs-2019) are enforced by default. Use the `--fix-style` option to enforce [Language conventions](https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019) and [Naming conventions](https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions?view=vs-2019). |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably needs a section on how we apply codefixes.