Programming | Specification continued third, this article is IDesign C # Programming specification Chapter Three.
3 Project setup and project structure
Project Settings and Project Structure
1. The project is always established with a Level 4 warning (figure).
Always build your project with warning Level 4
2. Warnings as errors in the release (note that this is not the default setting for Vs.net) (figure).
Treat warning as errors in Release build ("Note" is not the default of Vs.net).
A) Although it is optional, this standard also recommends that warnings be used as errors in the Debug edition.
Although it is optional, this standard recommend treating warnings as errors in debug builds as.
3. Never suppress a specific compilation warning (figure).
Never suppress specific compiler warnings.
4. Always explicitly state the supported runtime version in the application's configuration file. See chapter fifth Programming. NET components.
Always explicitly state your supported runtime versions in the application file. Chapter 5 in programming. NET components.
<?xml version= "1.0"?>
<configuration>
<startup>
<supportedruntime version= "v2.0.0.0"/>
<supportedruntime version= "v1.1.5000.0"/>
</startup>
</configuration>
5. Avoid explicit customization of version redirection and binding to CLR assemblies.
Avoid explicit custom version redirection and binding to CLR assemblies.
6. Avoid an explicit precompiled definition (#define). Define conditional compilation constants using Project settings.
Avoid explicit preprocessor definitions (#define). Use the project settings for defining conditional compilation constants.
7. Do not put any logic in the AssemblyInfo.cs.
Don't put any logic inside AssemblyInfo.cs.
8. Do not place assembly attributes in any file except in AssemblyInfo.cs.
Do is put any assembly attributes the any file besides AssemblyInfo.cs.
9. Provide all fields in AssemblyInfo.cs, such as company name, description, copyright, etc.
Populate all fields in AssemblyInfo.cs such as company name, description, copyright notice.
10. All assemblies should use relative path references.
All assembly references should use relative path.
11. Circular references in assemblies are not allowed.
Disallow cyclic references between assemblies.
12. Avoid multiple modules of the assembly.
Avoid multi-module assemblies.
13. The default is always run in an unchecked fashion (for performance reasons), but the check mode is explicitly used for operations that are prone to overflow or underflow (figure).
Always Run code unchecked by default (for performance sake), but explicitly in checked mode for overflow or underflow pron E operations.
int calcpower (int number,int power)
{
int result = 1;
for (int count = 1;count <= power;count++)
{
Checked
{
Result *= number;
}
}
return result;
}
14. Avoid using the exception window (debug| Exceptions) tampering with exception handling.
Avoid tampering with exception handling using the Exception window (debug| exceptions).
15. Strive to use a unified version number for all assemblies and clients in the same logical application (usually a solution).
Strive to use uniform version numbers on all assemblies and clients in the same logical (application a typically) .
The configuration file that is applied by Visual Studio.NET is named App.config and included in the project.
Name your Visual Studio.NET application configuration file as app.config, and include it in the project.
17. Avoid using explicit code to exclude methods (#if #endif) instead of using conditional methods.
Avoid explicit code exclusion of method calls (#if ... #endif). Use conditional methods instead.
public class MyClass
{
[Conditional ("Myspecialcondition")]
public void MyMethod ()
{}
}
18. Change the default project structure of vs.net to a standard layout, applying a unified structure to the project folder and files.
Modify vs.net Default project structure to your project Standard layout, and apply uniform for project structure a nd files.
19. Link a global shared file that contains all the solution-level information (figure).
Link all solution-wide information to a global shared file:
20. Tab SELECTION "Insert Space", use 3 spaces instead of tabs.
Insert spaces for tabs. Use 3 spaces instead of tabs.
A) in Tools | options | text Editors | c#| tab setting
tools| options| Text editor| c#| Tabs
21. The release version should contain debug symbols.
Release build should contain debug symbols.
22. Always sign the assembly, including the client application.
Always sign your assemblies, including the client applications.
23. Always sign the interop assembly using the project's SNK file (figure).
Always sign Interop assemblies with the project ' s SNK file
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.