[Tool] Using codemaid for automatic program formatting
The article "use stylecop to verify naming rules" guides developers to automatically verify that program code generated in the project complies with naming rules through the stylecop tool.
- [Tool] Use stylecop to verify naming rules
However, during project development, if only naming rules are verified without unified program layout, program code production similar to the following examples may easily appear in the project. Although such outputs can normally provide project functions and comply with Microsoft naming rules, the maintainability of the program code is greatly reduced due to the messy program layout.
This article describes how to use the codemaid tool to automatically organize the layout of program code in the project without increasing the burden on developers, the team's program code production tends to be consistent, greatly improving the quality of program code production. I mainly keep a record for myself and hope to help developers who need it.
Install
Go to Microsoft's official website and download the codemaid Installation File "codemaid_v0.7.4.vsix 」.
- Http://visualstudiogallery.msdn.microsoft.com/76293c4d-8c16-4f4a-aee6-21f83a571496
Run the codemaid Installation File "codemaid_v0.7.4.vsix" to install codemaid.
Run
Use Visual Studio to open a project.
In the toolbar above Visual Studio, enable the codemaid menu and click Configuration to enable the codemaid setting screen.
On the codemaid setting screen, go to the reorganizing-> General settings page, select "Run organize at start cleanup", and click "save" to complete the setting.
You can enable the codemaid menu in the toolbar at the top of Visual Studio and click "cleanup all code" to automatically print all program codes in the project.
After the automatic typographical function is executed, open the program code in the project and you will find that the program code content is neatly arranged and clean, greatly improving the maintainability of the program code.
Extension
Codemaid provides the program code automatic typographical function, which is convenient to use and has simple typographical results. However, there are always some typographical definitions in some details, which do not meet the requirements of team members for program code quality. But fortunately, codemaid opened many projects for setting typographical conditions, allowing developers to adjust typographical conditions to bring typographical results closer to the requirements of team members for program code output.
1. automatically run cleanup on File Save
Automatically run cleanup on File Save: On the cleaning-> General settings page. When this option is selected, the program code layout function is automatically executed while saving the file disk.
2. Run Remove unused using statements
Run Remove unused using statements: on the cleaning-> Visual Studio settings page. When this option is selected, the unused using definition is removed when the Code layout function is executed. (We recommend that you do not select this option during the development phase because removing unused using definitions will cause the problem that the extension method cannot be found when using LINQ .)
3. Remove Multple consecutive blank lines
「 Remove Multple consecutive blank lines 」: Located on the cleaning-> remove settings page. When this option is set to checked, the blank lines of multiple consecutive rows are removed when the Code layout function is executed.
4. Update # endregion tag with region name
"Update # endregion tag with region name": Located on the cleaning-> updae settings page. When this option is selected, the region name is added to the # endregion region volume when the Code layout function is executed.
5. alphabetize members of the same group
"Alphabetize members of the same group": Located on the reorganizing-> General settings page. When this option is set to checked, a work item that is sorted alphabetically by the member type will be added when the Code layout function is executed.
Reference data
[Tool] Use codemaid for automatic program Layout