C # Introduction to standardized programming tools,
1. Objectives
Code writing is standardized, neat, neat, and readable.
No error
No warning
2. Layout
Install PowerCommands Extension
"Tools"-"Extension Management Library", search for installation.
Set the selected Format document on save and Remove and Sort Usings on save
In this way, the code is automatically formatted and sorted by reference units when it is saved.
3. Notes
Set Project "property"-"generate"-"output"
Select "XML document file (X )"
The purpose is to prompt comments for each public visible type.
4. Code Analysis Optimization
ReSharper
Code Analysis
ReSharper can be used for C #, XAML, XML, and ASP. NET and ASP. net mvc's continuous code quality analysis can detect errors and problems even before you compile them. ReSharper provides over 900 code checks for your code, allowing you to immediately detect errors and faults in your current file or even the entire solution.
Highlight error and quick correction
ReSharper analyzes the code when the user inputs it and highlights the error. The user does not even need to compile the code. It can even quickly provide suggestions for most errors to help users solve problems quickly.
Code Reconstruction
Compared with Visual Studio 2005/2008/2010, ReSharper provides richer Automatic Code refactoring functions. You can use many different refactoring methods to rename, move, and safely delete identifiers, import and inline fields, variables, and parameters.
A yellow exclamation point triangle and a yellow line are displayed on the right. Select and modify. A green check box is displayed.
5. Code check
StyleCop
The ultimate goal of StyleCop is to allow everyone to write elegant and consistent code, which is highly readable. StyleCop is not a Code formatting tool, but a Code Review tool. It not only checks the Code format, but also Code specifications, including names and comments. It checks our source code based on the predefined best practices of c # code format and provides error messages that do not conform to the encoding style.
Project file, right-click, and select "Run StyleCop (Rescan All )"
Show warning list"
The rule number starts with SA. For example, "SA1305" can search for the corresponding rule and modify it according to the rule. Eliminate all warnings.
6. Summary
If there are no errors or warnings about the code after the above tools are used, the code quality should be OK. Check the code using one or two projects with the tools,
According to Huawei's programming specifications, many of them are correct. There are not many blog posts, so I hope they will be useful to everyone.
Original article, reprinted please keep link yhuse's blog