Brief introduction
Originally always use ReSharper to carry on the code quality check, but after all is the charge, therefore wants to find a free can promote to the company's colleague also uses together. Searched for, found StyleCop, but I installed StyleCop in VS 2015 or installed stylecop.msbuild through Nuget package, although the compilation can display warning in the Error list, but not through the project---right Key configuration StyleCop rules, eventually found a stylecopanalyzers is also considered a new version of StyleCop.
The main use of Visual Studio ' s Roslyn analysis tool brings the following benefits:
- can support C # 6
- Reduced performance consumption of custom parsers using the Roslyn parser
- The parser will run when you write the code and will run when you compile (no need to set up MSBuild tasks or install any vs plugins)
Installation
Installation is relatively simple, in the project management NuGet package, input stylecop.analyzers and then install it
Installation is done directly can see the effect, Stylecop.analyzers will be like ReSharper as you write code when you prompt the error, and do not compile after the discovery of errors.
But after compiling, all the error hints will be displayed.
Configure Custom Rules
In the above picture, you can see my project a total of 32 StyleCop warning, the following we will remove the SA1652 warning.
Find the reference Analyzer, right click on open Active Rule Set, you can open the rules table
Then find the Stylecop.analyzers rule SA1652, uncheck it, and save it.
The file that will eventually generate a. ruleset suffix in the project is our custom rule.
After compiling to see the effect, you will notice that the SA1652 warning of the preceding prompt is gone.
C # code specification and quality Check tool stylecop.analyzers