Skip to content

Commit 1885aa2

Browse files
committed
Add core clr documentation
1 parent bd617d0 commit 1885aa2

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

StyleCopAnalyzers.sln

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.23107.0
4+
VisualStudioVersion = 14.0.25123.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StyleCop.Analyzers", "StyleCop.Analyzers\StyleCop.Analyzers\StyleCop.Analyzers.csproj", "{3B052737-06CE-4182-AE0F-08EB82DFA73E}"
77
EndProject
@@ -35,6 +35,7 @@ EndProject
3535
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "documentation", "documentation", "{19DD9E9D-877A-4492-9B7F-2E681DD58308}"
3636
ProjectSection(SolutionItems) = preProject
3737
documentation\Configuration.md = documentation\Configuration.md
38+
documentation\DotNetCli.md = documentation\DotNetCli.md
3839
documentation\EnableConfiguration.md = documentation\EnableConfiguration.md
3940
documentation\KnownChanges.md = documentation\KnownChanges.md
4041
documentation\SA0000Roslyn7446Workaround.md = documentation\SA0000Roslyn7446Workaround.md

documentation/DotNetCli.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
# Using StyleCop Analyzers with dotnet cli
3+
4+
StyleCop Analyzers can be used in dotnet cli projects, including asp.net core.
5+
The tooling support is currently not great and the analyzers only run when the project is compiled and there is currently no way to invoke the code fixes. What does work however is running Stylecop Analyzers in ubuntu on coreclr and OSX (probably) works too.
6+
To set this up a few steps are required:
7+
8+
First the StyleCopAnalyzers nuget package has to be added to the project. Optimally the package should be marked as `build` type so it is not included as a package by other projects consuming it.
9+
For this add the following to the dependencies section of the project.json file:
10+
```json
11+
"StyleCop.Analyzers": {
12+
"version": "1.0.0",
13+
"type": "build"
14+
}
15+
```
16+
17+
If the project is restored and built right now this will already run the analyzers. A few extra steps are needed if they should be configured.
18+
19+
## Rulesets and stylecop.json
20+
21+
To supply a ruleset file and a stylecop.json configuration file to the compiler they have to be manually added as arguments to the compiler. For this add the follwing under the `compilationOptions` node in the project.json file:
22+
```json
23+
"additionalArguments": [ "/ruleset:path/to/ruleset.ruleset", "/additionalfile:path/to/stylecop.json" ]
24+
```
25+
26+
## Enabling xml documentation processing
27+
28+
All analyzers regarding xml documentation can only run if the xml processing is enabled. To do this add
29+
```json
30+
"xmlDoc": "true"
31+
```
32+
33+
to the `compilationOptions` node of the project.json file. Note that this might cause additional CS1591 diagnostics to appear by the compiler.
34+
They can be suppressed in the ruleset file if necessary.

0 commit comments

Comments
 (0)