C# Coding Conventions Inferred By Visual Studio IntelliCode

25 Jul

The Visual Studio IntelliCode Extension was updated to include 'coding convention inference' for C#. To put it differently, the extension can have a look at your present coding conventions and generate a configuration file that most matches the way your code appears.

Once generated, the configuration file can help you maintain consistency on your team's codebase. IntelliCode works out what to put in the .editconfig file by scanning code files in your selected projects to create the ideal matching pair of conventions.

How this works is that you pick the solution, project, or folder where you want the conventions to apply, and choose to add an EditorConfig file. Once created, the EditorConfig files apply authorities hierarchically to all files below it in the filesystem. If you have subfolders or projects that have various conventions, then you may make a new EditorConfig for all those subfolders or projects to override the conventions in the higher level.

Once set up, any code that doesn't conform to the design used by the majority of the code is highlighted in the error list in the Messages severity. This can be shifted to reveal the errors or warnings. Formatting offenses don't show up in the error listing.

Visual Studio IntelliCode was announced within an experimental extension for Visual Studio 2017 before this season. The extension is designed to boost developer productivity with attributes such as contextual IntelliSense, inference, and enforcement for code styles, and concentrated reviews for your draw asks.

The current version of IntelliCode relies on an Azure machine learning model that offers better signal completion and automatic code formatting to match your regular style. In addition, it looks in the code to suggest NET related APIs which are very likely to be the most relevant for you given based on the code you're writing.

Share this post with your friends!