Microsoft released the code formatting tool that is used to automatically format the code as per the prescribed coding guidelines. The tool is based on Roslyn and will work on any C# project.
“We strongly believe that having a consistent style greatly increases the readability and maintainability of a code base. The individual style decisions themselves are subjective, the key is the consistency of the decisions. As such the .NET team has a set of style guidelines for all C# code written by the team”, said Immo Landwerth, Microsoft.
The Roslyn project has the required tools to fix code formatting issues. The core features are a full fidelity parse tree and a set of APIs to safely manipulate it syntactically or semantically. You can easilt make use of the code formatting tool by pointing it at a project or solution. It will automatically convert all of the code involved into the prescribed coding style.
The whole process of code conversion only takes few minutes to complete and can be run repeatedly to make sure that a consistent style is maintained over the course of time.
Landwerth has provided a detailed example on his blog post which clearly shows the real usage of the code formatting tool.
The code formatting tool is a library with a simple command line wrapper. Microsoft is planning to provide support for Visual Studio in the near future.
The code formatting tool is available on GitHub in the codeformatter repo. Developers will be able to download precompiled binaries as well. Microsoft is currently accepting feedback from the community regarding the tool.