Configuring C# code style rules built into Visual Studio 2017
In this section, we will walk you through the important categories of code style rules built into Visual Studio 2017, and also show you how to configure them in Visual Studio.
Getting ready
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.
How to do it...
- 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
. - Click on
Tools
|Options
to bring up the tools options dialog and navigate to the C# code style options (Text Editor
|C#
|Code Style
|General
):
- Change the
Severity
of'this.' preferences
toSuggestion
,predefined type preferences
toWarning
, and'var' preferences
toError
. Change...