[Tool] Use codemaid for automatic program Layout

Source: Internet
Author: User
[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.

  • Bad code

    public class Class1{    private string _name = "Clark";    public string GetResult()    {        return (_count01 + _count02).ToString();    }    private int _count01 = 1;    private int _count03 = 3;    public string GetName()    {        return _name;    }    private int _count02 = 2;}

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.

  • Good Code

    public class Class1{    private int _count01 = 1;    private int _count02 = 2;    private int _count03 = 3;    private string _name = "Clark";    public string GetName()    {        return _name;    }    public string GetResult()    {        return (_count01 + _count02).ToString();    }}
Install
  1. 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

  2. Run the codemaid Installation File "codemaid_v0.7.4.vsix" to install codemaid.

Run
  1. Use Visual Studio to open a project.

  2. In the toolbar above Visual Studio, enable the codemaid menu and click Configuration to enable the codemaid setting screen.

  3. 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.

  4. 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.

  5. 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
  • No. 18-[Tool] vs2010 extension-codemaid

  • Codemaid-Documentation

[Tool] Use codemaid for automatic program Layout

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.