FxCop 国际化和互操作性规则

二、 Globalization(全球化)
1. Avoid duplicate accelerators
避免在顶层控件中使用重复的快捷键(加速键)

2. Do not hardcode locale specific strings
不要对本地的特殊字符串(比如特殊的系统路径)进行硬编码

3. Do not pass literals as localized parameters
不要把文本作为需要本地化的参数直接传递(尽量使用资源文件)

4. Set locale for data types
为某些数据类型设定区域和语言属性(DataSet和DataTable的locale属性)

5. Specify CultureInfo
指定文化信息(地域和语言信息),在调用接受System.Globalization.CultureInfo 类型参数的方法时应该传递文化信息

6. Specify IFormatProvider
指定格式供应器,在调用接受System.IFormatProvider 类型参数的方法时应该传递格式供应器

7. Specify MessageBoxOptions
指定MessageBox的选项,在调用MessageBox.Show方法时应该传递System.Windows.Forms.MessageBoxOptions,特别在某些从右向左阅读习惯的区域
 
三、 Interoperability(互操作性)
1. Auto layout types should not be ComVisible
自动布局的类型不应该对Com可见(设置System.Runtime.InteropServices.ComVisibleAttribute特性为false)

2. Avoid int64 arguments for VB6 clients
避免使用int64类型,如果成员可能被Visual Basic 6 COM clients调用

3. Avoid non-public fields in ComVisible value types
避免在一个标记有ComVisible特性的值类型里面包含非公有的实例域
 
4. Avoid overloads in ComVisible interfaces
避免在一个标记有ComVisible特性的接口内声明重载

5. Avoid static members in ComVisible types
避免在一个标记有ComVisible特性的类型

6. Call GetLastError immediately after pinvoke
进行pinvoke以后应该立即使用GetLastError读取错误信息

7. Com registration methods should be matched
Com注册方法(标记有System.Runtime.InteropServices.ComRegisterFunctionAttribute特性的方法)应该是配对的(同时具有一个标记有System.Runtime.InteropServices.ComUnregisterFunctionAttribute的方法与之匹配)

8. Com registration methods should not be visible
Com注册方法应该是不可见的

9. Com visible type base types should be ComVisible
标记有ComVisible特性的类型的基类同样应从标记有ComVisible特性的类继承

10. Com visible types should be creatable
标记有ComVisible特性的类型应该能够使用默认构造器构造

11. Declare PInvokes correctly
正确定义PInvokes

12. Do not use AutoDual ClassInterfaceType
不要把System.Runtime.InteropServices.ClassInterfaceAttribute特性的值设置为System.Runtime.InteropServices.ClassInterfaceType.AutoDual

13. Mark boolean pinvoke arguments with MarshalAs
布尔型的pinvoke参数应该使用System.Runtime.InteropServices.MarshalAsAttribute特性标记

14. Mark ComSource interfaces as IDispatch
将System.Runtime.InteropServices.ComSourceInterfacesAttribute特性标记为System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIDispatch.

15. PInvoke entry points should exist
Pinvoke应该存在入口点

16. PInvokes should not be visible
Pinvoke应该是可见的

posted @ 2005-08-24 08:53  quitgame  阅读(508)  评论(0编辑  收藏  举报