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.
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:
An interesting detail is that even ReSharper recognizes the configuration and proposes the necessary changes.
Finally, we can also define some rules for defining class names, delegates, interfaces, etc.
And when they are not met, define the type of notification that will be displayed.
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