DesignRules(设计规则)

版权声明:全部文章版权归我所有。转载除外。 https://blog.csdn.net/kesshei/article/details/85599667

一、DesignRules(设计规则)

【01】、Abstract types should not have constructors(抽象类型不应具有构造函数)

【02】、Declare types in namespaces(在命名空间中声明类型)

【03】、Define accessors for attribute arguments(定义属性参数的访问器)

【04】、Do not declare protected members in sealed types(不要在密封类型中声明受保护的成员)

【05】、DoNotDeclareVirtualMembersInSealedTypes(不要在密封类型中声明虚拟成员)

【06】、DoNotHideBaseClassMethods(不要隐藏基类方法)

【07】、DoNotOverloadOperatorEqualsOnReferenceTypes(不要对引用类型重载等号运算符)

【08】、Exceptions should be public(异常应该是公共的)

【09】、Implement IDisposable correctly(正确实现 IDisposable)

【10】、Implement standard exception constructors(实现标准异常构造函数)

【11】、IndexersShouldNotBeMultidimensional(索引器不应是多维的)

【12】、MarkAttributesWithAttributeUsage(用 AttributeUsageAttribute 标记属性)

【13】、Mark enums with FlagsAttribute(用 FlagsAttribute 标记枚举)

【14】、MembersShouldNotExposeCertainConcreteTypes(成员不应公开某些具体类型)

【15】、OverloadOperatorEqualsOnOverloadingAddAndSubtract(重载加运算符和减运算符时应重载相等运算符)

【16】、PropertiesShouldNotBeWriteOnly(属性不应是只写的)

【17】、ProvideObsoleteAttributeMessage(提供 ObsoleteAttribute 消息)

【18】、ReplaceRepetitiveArgumentsWithParamsArray(用参数数组替换重复的变量)

【19】、Static holder types should be sealed(应密封静态容器类型)

【20】、Static holder types should not have constructors(静态容器类型不应具有构造函数)

【21】、StringUriOverloadsCallSystemUriOverloads(字符串 URI 重载调用 System.Uri 重载)

【22】、Types should not extend certain base types(类型不应扩展某些基类型)

【23】、Types that own disposable fields should be disposable(具有可释放字段的类型应该是可释放的)

【24】、Types that own native resources should be disposable(拥有本机资源的类型应是可释放的)

【25】、UriParametersShouldNotBeStrings(URI 参数不应为字符串)

【26】、UriPropertiesShouldNotBeStrings(URI 属性不应是字符串)

【27】、ValidateArgumentsOfPublicMethods(验证公共方法的参数)

二、Globalization Rules (全球化规则)

三、Interoperability Rules (互操作规则)

四、Naming Rules(命名规则)

【01】、EventsShouldNotHaveBeforeOrAfterPrefix(事件不应具有 before 或 after 前缀)

【02】、IdentifiersShouldDifferByMoreThanCase(标识符不应仅以大小写进行区分)

【03】、IdentifiersShouldHaveCorrectSuffix(标识符应具有正确的后缀)

【04】、IdentifiersShouldNotHaveIncorrectPrefix(标识符应采用正确的前缀)

【05】、IdentifiersShouldNotHaveIncorrectSuffix(标识符应采用正确的后缀)

【06】、OnlyFlagsEnumsShouldHavePluralNames(只有 FlagsAttribute 枚举应采用复数形式的名称)

【07】、Parameter names should match base declaration(参数名应与基方法中的声明保持一致)

【08】、Parameter names should not match member names(参数名不应与成员名冲突)

【09】、Type names should not match namespaces(类型名不应与命名空间冲突)

五、Performance Rules(性能规则)

【01】、AvoidExcessiveLocals(避免过多的局部变量)

【02】、Avoid uncalled private code(避免使用未调用的私有代码)

【03】、Avoid unused private fields(避免未使用的私有字段)

【04】、Do not cast unnecessarily(避免进行不必要的强制转换)

【05】、Do not initialize unnecessarily(避免进行不必要的初始化)

【06】、Remove empty finalizers(移除空的终结器)

【07】、RemoveUnusedLocals(移除未使用的局部变量)

【08】、Test for empty strings using string length(使用字符串长度测试是否有空字符串)

六、Portability Rules(可移植性规则)

七、Security Rules(安全规则)

【01】、Array fields should not be read only(数组字段不应为只读)

【02】、CatchNonClsCompliantExceptionsInGeneralHandlers(在常规处理程序中捕捉非 CLSCompliant 异常)

【03】、MethodSecurityShouldBeASupersetOfType(方法安全性应是类型安全性的超集)

【04】、ReviewDeclarativeSecurityOnValueTypes(检查有关值类型的声明性安全)

【05】、ReviewVisibleEventHandlers(检查可见的事件处理程序)

【06】、SealMethodsThatSatisfyPrivateInterfaces(密封满足私有接口的方法)

【07】、Secured types should not expose fields(受保护的类型不应公开字段)

【08】、StaticConstructorsShouldBePrivate(静态构造函数应为私有)

【09】、WrapVulnerableFinallyClausesInOuterTry(在外部 try 块中包装易受攻击的 finally 子句)

八、Usage Rules(用法规则)

【01】、AttributeStringLiteralsShouldParseCorrectly(应正确分析属性字符串文本)

【02】、Call GC.SuppressFinalize correctly(正确调用 GC.SuppressFinalize)

【03】、Collection properties should be read only(集合属性应该是只读的)

【04】、Disposable fields should be disposed(应释放可释放的字段)

【05】、DisposableTypesShouldDeclareFinalizer(可释放类型应声明终结器)

【06】、Do not call overridable methods in constructors(不要在构造函数中调用可重写的方法)

【07】、DoNotDecreaseInheritedMemberVisibility(不要降低继承成员的可见性)

【08】、Do not ignore method results(不要忽略方法结果)

【09】、Do not mark enums with FlagsAttribute(不要使用 FlagsAttribute 标记枚举)

【10】、DoNotShipUnreleasedResourceFormats(不要发行未发布的资源格式)

【11】、FinalizersShouldBeProtected(终结器应受到保护)

【12】、Finalizers should call base class finalizer(终结器应调用基类的终结器)

【13】、Initialize value type static fields inline(初始化内联值类型的静态字段)

【14】、MarkWindowsFormsEntryPointsWithStaThread(使用 STAThread 标记 Windows 窗体的入口点)

【15】、MembersShouldDifferByMoreThanReturnType(成员不应只是返回类型不同)

【16】、NonConstantFieldsShouldNotBeVisible(非常数字段不应该是可见的)

【17】、Operations should not overflow(运算不应溢出)

【18】、OperatorsShouldHaveSymmetricalOverloads(运算符应有对称重载)

【19】、PassSystemUriObjectsInsteadOfStrings(传递 System.Uri 对象而不是字符串)

【20】、TestForNaNCorrectly(正确测试 NaN)

猜你喜欢

转载自blog.csdn.net/kesshei/article/details/85599667