According to this this article for using StyleCop in Asp.net Core,
1)Add the following to the dependencies section of the project.json file:
"StyleCop.Analyzers": {
"version": "1.0.0",
"type": "build"
}
and build the project.
2) Create stylecop.json
and add your configuration on it, this is my stylecop.json
content:
{
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
"settings": {
"documentationRules": {
"documentInterfaces": true,
"documentInternalMembers": false
}
}
}
3) the following under the buildOptions node in the project.json file:
"additionalArguments": ["/additionalfile:path/to/stylecop.json" ]
but i got some errors: what is the problem?
Short Answer
Those
NullReferenceException
errors happen when StyleCop cannot find yourstylecop.json
. Here is the related GitHub issue.To fix it (assuming that your
stylecop.json
is in the root of your project) change the path to this:Full Working Example
Directory structure
Project.json
stylecop.json
StyleCop.ruleset
Clone and Run the Example