#VS2017 – Code Style configuration in Visual Studio 2017 IDE

Hello!

A few months ago, before the official launch of Visual Studio 2017, one of the cool IDE innovations was the chance to define code style configurations to be applied in the IDE while we are coding apps. These configurations were stored in files named “.editorconfig”, and of course, the best way to learn on these files is navigating EditorConfig.org.

The interesting thing about the model is that, when we copy this file into a folder, the settings of it are applied for all the files and sub folders. If we want to have a special configuration in any sub folder, we must create another file in that location with the changes we need. The best introduction to this topic can be found in this .Net Team post (link).

Well, today in one of the sessions of Visual Studio live, I find that we can also configure these options directly from the IDE.

Important: The changes that are defined here apply to all projects that we edit with Visual Studio, not for a special solution or project.

The options can be edited in the “text editor//Code Style” section and you can see the different code editing rules.

 

Clipboard01

If for example, we define that the non-use of “this” is marked as an Error for local fields, we will be able to get a behavior in the Code Editor as the following:

Clipboard03

An interesting detail is that even ReSharper recognizes the configuration and proposes the necessary changes.

Clipboard05

Finally, we can also define some rules for defining class names, delegates, interfaces, etc.

Clipboard06

And when they are not met, define the type of notification that will be displayed.

Clipboard07

Finally, I have to clarify that while we can have many “errors” in our code, it may built without problems, as these errors are errors in style of code not compilation.

Greetings @ VSLive at Austin

El Bruno

References

Advertisements

3 thoughts on “#VS2017 – Code Style configuration in Visual Studio 2017 IDE

  1. Hi! When I config my rules with errors I can see that in the error list and in the code, but, when I tried Build or Start my project there was sucessful. How I can configure my code style options for my builds will fail if I have some code style errors?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s