FxCop命名规则

四、 Naming(命名)
1. Avoid language specific type names in parameters
避免在参数中使用与特定语言相关的类型(用Uint16代替Ushort)

2. Avoid type names in parameters
避免在外部可见的参数中使用类型名

3. Compound words should be cased correctly
复合词应该使用正确的大小写(不要将Mutlipart写成MultiPart,也不要将ToolBar写成Toolbar,FileName写成Filename)

4. Do not name enum values 'Reserved'
不要在枚举值中使用保留字

5. Do not prefix enum values with type name
不要在枚举值使用类型前缀(比如不要使用Digital之类的前缀)

6. Events should not have before or after prefix
事件的名称不应该包含before和after前缀(尽量使用ing和ed的后缀)

7. Flags enums should have plural names
标记有System.FlagsAttribute特性的枚举应该使用复数形式的名称

8. Identifiers should be cased correctly
标示符(名字空间、类名、属性名、接口名、方法名等)应该使用正确的大小写(通常以大写开头,以后的每个单词都首字母大写)

9. Identifiers should be spelled correctly
标示符应该可以被正确的划分为不同的单词

10. Identifiers should differ by more than case
标示符应该不止有大小写上的不同(因为某些语言是不区分大小写的)

11. Identifiers should have correct prefix
标示符应该使用正确的前缀(接口应该使用字母I开头)

12. Identifiers should have correct suffix
标示符应该使用正确的后缀
System.Attribute/Attribute
System.EventArgs/EventArgs
System.Exception/Exception
System.Collections.ICollection/Collection
System.Collections.IDictionary/Dictionary
System.Collections.IEnumerable/Collection
System.Collections.Queue/Collection or Queue
System.Collections.Stack/Collection or Stack
System.Collections.Generic.ICollection/Collection
System.Collections.Generic.IDictionary/Dictionary
System.Data.DataSet/DataSet
System.Data.DataTable/Collection or DataTable
System.IO.Stream/Stream
System.Security.IPermission/Permission
System.Security.Policy.IMembershipCondition/Condition
An event-handlerdelegate./EventHandler

13. Identifiers should not contain underscores
标示符不应该使用下划线

14. Identifiers should not have incorrect prefix
标示符不应该使用不正确的前缀(比如不应使用一个字母作为前缀)

15. Identifiers should not have incorrect suffix
标示符不应该使用不正确的后缀(不要在不正确的地方使用12中提及的后缀名,和Delegate、Enum、Flags for an enumeration、Impl等后缀名)

16. Identifiers should not match keywords
标示符不应该与系统关键字冲突

17. Long acronyms should be pascal-cased
长度大于等于3的缩写词应该使用pascal的命名规则,即首字母大写

18. Only FlagsAttribute enums should have plural names
只有标记有System.FlagsAttribute特性的枚举的名称才应该使用复数,其他时候应该使用单数

19. Parameter names should match base declaration
派生项的参数名应该同基项相吻合(派生类重写或实现的方法应该同基项具有相同的参数名)

20. Parameter names should not match member names
方法的参数名不应该同类或接口的成员名一样

21. Property names should not match get methods
属性名字不应该同Get开头的方法的名称的后半部分相同

22. Resource string compound words should be cased correctly
包含符合单词的资源字符串应该使用正确的大小写(每个单词的首字母大写)

23. Resource strings should be spelled correctly
资源字符串应该正确的拼写

24. Short acronyms should be uppercase
短的首字母缩写词应该全部大写(比如DB,CR)

25. Type names should not match namespaces
类型的名字不应该与名字空间的名字相同
 
26. Use preferred terms
优先使用某些项目或者名称,以下这些,后者为优先使用的
ComPlus/EnterpriseServices
Cancelled/Canceled
Indices/Indexes
LogIn/LogOn
LogOut/LogOff
SignOn/SignIn
SignOff/SignOut
Writeable/Writable


 

posted @ 2005-08-25 09:48  quitgame  阅读(696)  评论(2编辑  收藏  举报