浏览器大全:是一个提供流行浏览器教程、在线学习分享的学习平台!

IDesign C#编程规范(之4)

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

相关软件

2345加速浏览器官方版

2345加速浏览器官方版 | 56.2MB

2345加速浏览器官方版

新一代2345加速浏览器采用Chromium和IE双内核,主打极速与安全特性。基于Chromium深度定制,引入网页智能预加载技术,访问网页更快速..

QQ浏览器官方正式版

QQ浏览器官方正式版 | 49.67MB

QQ浏览器官方正式版

QQ浏览器秉承TT浏览器1-4系列方便易用的特点,但技术架构不同,交互和视觉表现也重新设计,采用Chromium内核+IE双内核,让浏览快速稳定...

百度浏览器最新版下载

百度浏览器最新版下载 | 13.3MB

百度浏览器最新版下载

q百度浏览器,是一款简洁轻快、智能懂你的浏览器。依靠百度强大的搜索平台,在满足用户浏览网页的基础上,它整合百度体系业务优势,带给用户更方便的浏览方式功能...

UC浏览器官方正式版

UC浏览器官方正式版 | 44.2MB

UC浏览器官方正式版

UC浏览器(UC Browser)是UC Mobile Limited在2004年8月开发的一款软件,分uc手机浏览器和uc浏览器电脑版。UC浏览器是全球使用量最大的第三方手机浏览器...

猎豹浏览器2022最新版下载

猎豹浏览器2022下载 | 45MB

猎豹浏览器2022最新版下载

猎豹安全浏览器对Chrome的Webkit内核进行了超过100项的技术优化,访问网页速度更快。其具有首创的智能切换引擎,动态选择内核匹配不同网页...

360安全浏览器官方版下载

360安全浏览器下载 | 21.4MB

360安全浏览器官方版下载

360安全浏览器拥有全国最大的恶意网址库,采用恶意网址拦截技术,可自动拦截挂马、欺诈、网银仿冒等恶意网址。独创沙箱技术,在隔离模式即使访问****也不会感染...