In this section, we will introduce you to a popular third-party analyzer package for code style rules for C# projects, StyleCop analyzers. We will walk through how to install the StyleCop analyzers NuGet package, give example violations for each of the StyleCop rule categories, and show you how to configure and tune individual StyleCop rules.
You will need to have Visual Studio 2017 installed on your machine to execute the recipes in this chapter. You can install a free community version of Visual Studio 2017 from https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=Community&rel=15.
- Start Visual Studio, navigate to
File
|New
|Project...
, create a new C# class library project, and replace the code inClass1.cs
with code from the code sample atClassLibrary/Class1.cs
. - Install the
StyleCop.Analyzers
NuGet package (as of this writing, the latest prerelease version is 1.1.0-beta001). For...