续之三,本文是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.

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

之五

IDesign C#编程规范(之四)相关推荐

  1. IDesign C#编程规范(一)

    IDesign发布了C#编程规范,小鸡射手从Only4Gurus下载浏览后决心抽时间翻译一下,以更好地学习. 目录内容如下: 1  命名规则和风格 Naming Conventions and Sty ...

  2. IDesign C#编程规范

    IDesign发布了c#编程规范,小鸡射手从only4gurus下载浏览后决心抽时间翻译一下,以更好地学习. 目录内容如下: 1  命名规则和风格 naming conventions and sty ...

  3. IDesign C#编程规范(一)

    idesign发布了c#编程规范,小鸡射手从 only4gurus 下载浏览后决心抽时间翻译一下,以更好地学习. 目录内容如下: 1  命名规则和风格 naming conventions and s ...

  4. [导入]IDesign C#编程规范[转]

    [转自 http://blog.csdn.net/zlei12/]         IDesign发布了C#编程规范,小鸡射手从Only4Gurus下载浏览后决心抽时间翻译一下,以更好地学习. 目录内 ...

  5. IDesign C#编程规范(二)

    2  编码惯例    Coding Practices 1. 避免在一个文件中放多个类.     Avoid putting multiple classes in a single file.  2 ...

  6. IDesign C#编程规范[转]

    原文转自:http://www.cnblogs.com/ShiningRay/archive/2005/04/11/135263.html 命名规则和风格  1.  类和方法名采用Pascal风格  ...

  7. Windows客户端C/C++编程规范“建议”——前言

    前言 工作中接触了很多编程规范.其中最有意思的是,公司最近发布了一版C/C++编程规范,然后我看到该规范的最后一段时,有这么一句:"该规范不适用于Windows平台开发".看来这份 ...

  8. Python编程规范及性能优化

    为什么80%的码农都做不了架构师?>>>    Ptyhon编程规范 编码 所有的 Python 脚本文件都应在文件头标上 # -*- coding:utf-8 -*- .设置编辑器 ...

  9. 【ES6】ES6编程规范 编程风格

    [ES6]ES6编程规范 编程风格 一.定义变量的规范 二.字符串 三.对象 四.数组 五.函数 查看更多ES6教学文章: 参考文献 引言:这是ES6系列教学的最后一篇.我们讲解一下ES6编程的规范. ...

最新文章

  1. 微服务之数据同步Porter
  2. poj3252 组合数学
  3. 怎么打开网卡rss_电脑任务栏右下角宽带图标提示网络电缆没插好怎么办?
  4. 分享:游戏新手引导程序框架设计3要点
  5. 如果你也会C#,那不妨了解下F#(5):模块、与C#互相调用
  6. RUNOOB python练习题19 找出1000以内的所有完数
  7. hdfs fsck命令查看HDFS文件对应的文件块信息(Block)和位置信息(Locations)
  8. 192.168.8.1手机登陆_高端机型都在鼓吹的ufs3.1是什么?对于手机使感受明显吗?...
  9. 《CCNA学习指南:Cisco网络设备互连(ICND1)(第4版)》——1.10节本章小结
  10. 配置Hadoop开发环境(Eclipse)
  11. Npm(包管理工具)
  12. STM8L RTC总结初始化和配置
  13. 新唐N76E003与ST公司STM8S003F3芯片对比 史上最全的没有之一
  14. STM32平台RT-Thread最小系统移植搭建 - STM32F107VCT6
  15. ensp mstp+vrrp配置实验
  16. 迅速学tar命令对文件的打包压缩与解压缩
  17. 百度快照劫持的解决方法
  18. Window取消快捷方式箭头(脚本方式)
  19. 2023年春节放假时间安排计划用哪一提醒备忘软件记录?
  20. 使用示波器学习变压器

热门文章

  1. 光盘出租系统mysql_碟片出租管理子系统数据库设计.doc
  2. 按键状态机消抖(上)
  3. 过亿资产地址被拉入黑名单?Tether地址冻结功能该怎么用?
  4. MySQL与Redis数据库结合——redis作为mysql的缓存服务器,实现读写分离(nginx+php+redis+mysql)
  5. 四路温度转串口模块-DS18B20
  6. vuejs使用vux出错Module build failed: Error: Cannot find module 'less'
  7. canvas画圆的几个关键点
  8. java堆栈(java堆栈信息怎么看)
  9. 营业执照经营范围怎么填写
  10. 第一行代码Android第二章读书笔记