国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

IDesign C#編程規范(之四)

2024-07-21 02:19:27
字體:
來源:轉載
供稿:網友
續之三,本文是idesign c#編程規范的第三章。



3 項目設置和項目結構
project settings and project structure


1. 總是以4級警告建立項目(圖略)。
always build your project with warning level 4
2. 在發布版中將警告作為錯誤(注意這不是vs.net的缺省設置)(圖略)。
treat warning as errors in release build (note that this is not the default of vs.net).
a) 雖然是可選的,本標準也推薦在調試版中將警告作為錯誤。
although it is optional, this standard recommend treating warnings as errors in debug builds as well.
3. 永遠不要抑制特定的編譯警告(圖略)。
never suppress specific compiler warnings.
4. 總是在應用程序的配置文件中顯式地說明支持的運行時版本。參見programming .net components第五章。
always explicitly state your supported runtime versions in the application configuration file. see 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. 避免顯式地自定義版本改向和綁定到clr程序集。
avoid explicit custom version redirection and binding to clr assemblies.
6. 避免顯式的預編譯定義(#define)。使用項目設置定義條件編譯常量。
avoid explicit preprocessor definitions (#define). use the project settings for defining conditional compilation constants.
7. 不要在assemblyinfo.cs中放任何邏輯。
do not put any logic inside assemblyinfo.cs.
8. 除了在assemblyinfo.cs,不要在任何文件中放程序集屬性。
do not put any assembly attributes in any file besides assemblyinfo.cs.
9. 在assemblyinfo.cs中提供所有字段,例如公司名稱、描述、版權等。
populate all fields in assemblyinfo.cs such as company name, description, copyright notice.
10. 所有程序集應該使用相對路徑引用。
all assembly references should use relative path.
11. 不允許在程序集中循環引用。
disallow cyclic references between assemblies.
12. 避免多模塊的程序集。
avoid multi-module assemblies.
13. 缺省總是以非檢查的方式運行(為了性能考慮),但是對易于溢出或下溢的操作顯式使用檢查模式(圖略)。
always run code unchecked by default (for performance sake), but explicitly in checked mode for overflow or underflow prone operations.
int calcpower(int number,int power)
{
int result = 1;
for(int count = 1;count <= power;count++)
{
checked
{
result *= number;
}
}
return result;
}
14. 避免使用exception窗口(debug|exceptions)篡改異常處理。
avoid tampering with exception handling using the exception window (debug|exceptions).
15. 努力對同一邏輯應用程序中(通常是一個解決方案)的所有程序集和客戶端使用統一的版本號。
strive to use uniform version numbers on all assemblies and clients in the same logical application (typically a solution).
16. visual studio.net應用的配置文件命名為app.config,并將其包括在項目中。
name your visual studio.net application configuration file as app.config, and include it in the project.
17. 避免使用顯式代碼來排除方法(#if#endif),而是使用條件方法。
avoid explicit code exclusion of method calls (#if...#endif). use conditional methods instead.
public class myclass
{
[conditional("myspecialcondition")]
public void mymethod()
{}
}
18. 將vs.net缺省的項目結構改為標準的布局,對項目文件夾和文件應用統一的結構。
modify vs.net default project structure to your project standard layout, and apply uniform structure for project folders and files.
19. 鏈接一個包含所有解決方案級信息的全局共享文件(圖略)。
link all solution-wide information to a global shared file:
20. 制表符選用"插入空格",使用3個空格代替制表符。
insert spaces for tabs. use 3 spaces instead of tabs。
a) 在工具|選項|文本編輯器|c#|制表符中設置
tools|options|text editor|c#|tabs
21. 發布版中應該包含調試符號。
release build should contain debug symbols.
22. 總是對程序集簽名,包括客戶端應用程序。
always sign your assemblies, including the client applications.
23. 總是使用項目的snk文件對互操作程序集簽名(圖略)。
always sign interop assemblies with the project's snk file

(待續)


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 西和县| 贞丰县| 宾川县| 宁河县| 新丰县| 北海市| 龙胜| 平果县| 呼图壁县| 锡林浩特市| 怀宁县| 香河县| 南昌市| 巴彦淖尔市| 齐齐哈尔市| 沛县| 大余县| 肇源县| 同仁县| 罗江县| 榆社县| 孟州市| 新昌县| 双峰县| 丹巴县| 南投市| 南丰县| 濮阳市| 洛宁县| 康定县| 郧西县| 诸城市| 正蓝旗| 乌拉特中旗| 五寨县| 南澳县| 盈江县| 得荣县| 微山县| 博爱县| 富阳市|