C # code specification and quality Check tool stylecop.analyzers

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.