Skip to content

Commit 25f003a

Browse files
Bart KoelmanBart Koelman
authored andcommitted
Added documentation for rule configuration
1 parent d89c9b2 commit 25f003a

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ The latest version requires [Visual Studio 2017 with Update 5](https://www.visua
3030

3131
* Optional: [Reference CSharpGuidelines.Layer.DotSettings in your existing Resharper preferences](/docs/Resharper%20Settings.md)
3232

33+
## Rule configuration
34+
The behavior of a few rules can optionally be customized using a configuration file. See [documentation](docs/Configuration.md) for details.
35+
3336
## Suppressing rules
3437
Rule warnings can be suppressed at various scopes, ranging from per line to at the project or solution level.
3538

docs/Configuration.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Rule configuration
2+
3+
The behavior of rules can be customized by adding a file named `CSharpGuidelinesAnalyzer.config` to your C# project with the following structure:
4+
5+
```xml
6+
<?xml version="1.0" encoding="utf-8"?>
7+
<cSharpGuidelinesAnalyzerSettings>
8+
<setting rule="AV1500" name="MaxStatementCount" value="12" />
9+
<setting rule="AV1561" name="MaxParameterCount" value="5" />
10+
</cSharpGuidelinesAnalyzerSettings>
11+
```
12+
13+
The next step is to change the Build Action (Properties window) of this file to **AdditionalFiles** (or **C# analyzer additional file**, depending on project type). This should result in the following line added to your project file:
14+
15+
```xml
16+
<AdditionalFiles Include="CSharpGuidelinesAnalyzer.config" />
17+
```
18+
19+
For a complete list of the available rules and their configuration settings, see [Overview](/docs/Overview.md).
20+
21+
## Multiple projects
22+
23+
If your solution consists of multiple projects, you can share the configuration by moving `CSharpGuidelinesAnalyzer.config` to the solution folder and updating your project files to use a relative link:
24+
```xml
25+
<AdditionalFiles Include="..\CSharpGuidelinesAnalyzer.config">
26+
<Link>CSharpGuidelinesAnalyzer.config</Link>
27+
</AdditionalFiles>
28+
```

docs/Overview.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ This analyzer reports when a method return type is `IEnumerable` or `IEnumerable
4949
### [AV1500](https://github.com/dennisdoomen/CSharpGuidelines/blob/1a90b74c95225a0f7e4d0e7a341fd027e17c2320/_pages/1500_MaintainabilityGuidelines.md#av1500): Methods should not exceed 7 statements ![](/images/warn.png "severity: warning")
5050
This analyzer reports when a method body (such as a method, property getter or local function) contains more than 7 statements.
5151

52+
**Note:** This rule can be customized using a [configuration file](/docs/Configuration.md) by setting **MaxStatementCount** to a value in range 0-255.
53+
5254
### [AV1502](https://github.com/dennisdoomen/CSharpGuidelines/blob/1a90b74c95225a0f7e4d0e7a341fd027e17c2320/_pages/1500_MaintainabilityGuidelines.md#av1502): Avoid conditions with double negatives ![](/images/warn.png "severity: warning")
5355
This analyzer reports when the logical not operator is applied on an argument that has the word "No" or "Not" in its name.
5456

@@ -100,6 +102,8 @@ This analyzer reports when a method, constructor, local function, indexer or del
100102
- declares a tuple parameter
101103
- returns a tuple with more than 2 elements.
102104

105+
**Note:** This rule can be customized using a [configuration file](/docs/Configuration.md) by setting **MaxParameterCount** to a value in range 0-255.
106+
103107
### [AV1562](https://github.com/dennisdoomen/CSharpGuidelines/blob/1a90b74c95225a0f7e4d0e7a341fd027e17c2320/_pages/1500_MaintainabilityGuidelines.md#av1562): Don't use ref or out parameters ![](/images/warn.png "severity: warning")
104108
This analyzer reports when:
105109
- a parameter is declared as `ref`

0 commit comments

Comments
 (0)