Extended Design Guidelines Rules rule set for managed code
The Microsoft Extended Design Guideline Rules rule set expands on the basic design guideline rules to maximize the usability and maintainability issues that are reported. Extra emphasis is placed on naming guidelines. You should consider including this rule set if your project includes library code or if you want to enforce the highest standards for writing code that is easy to maintain.
The Extended Design Guideline Rules include all of the Microsoft Basic Design Guideline Rules. The Basic Design Guideline Rules include all of the Microsoft Minimum Recommended Rules. For more information, see Basic Design Guideline Rules rule set for managed code and Managed Recommended Rules rule set for managed code
The following table describes all the rules in the Microsoft Extended Design Guideline Rules rule set.
Rule |
Description |
---|---|
Types that own disposable fields should be disposable |
|
Declare event handlers correctly |
|
Mark assemblies with AssemblyVersionAttribute |
|
Interface methods should be callable by child types |
|
Types that own native resources should be disposable |
|
Move P/Invokes to NativeMethods class |
|
Do not hide base class methods |
|
Implement IDisposable correctly |
|
Do not raise exceptions in unexpected locations |
|
Avoid duplicate accelerators |
|
P/Invoke entry points should exist |
|
P/Invokes should not be visible |
|
Auto layout types should not be COM visible |
|
Call GetLastError immediately after P/Invoke |
|
COM visible type base types should be COM visible |
|
COM registration methods should be matched |
|
Declare P/Invokes correctly |
|
Remove empty finalizers |
|
Value type fields should be portable |
|
P/Invoke declarations should be portable |
|
Do not lock on objects with weak identity |
|
Review SQL queries for security vulnerabilities |
|
Specify marshaling for P/Invoke string arguments |
|
Review declarative security on value types |
|
Pointers should not be visible |
|
Secured types should not expose fields |
|
Method security should be a superset of type |
|
APTCA methods should only call APTCA methods |
|
APTCA types should only extend APTCA base types |
|
Do not indirectly expose methods with link demands |
|
Override link demands should be identical to base |
|
Wrap vulnerable finally clauses in outer try |
|
Type link demands require inheritance demands |
|
Security critical types may not participate in type equivalence |
|
Default constructors must be at least as critical as base type default constructors |
|
Delegates must bind to methods with consistent transparency |
|
Methods must keep consistent transparency when overriding base methods |
|
Transparent methods must contain only verifiable IL |
|
Transparent methods must not call methods with the SuppressUnmanagedCodeSecurity attribute |
|
Transparent code must not reference security critical items |
|
Transparent methods must not satisfy LinkDemands |
|
Types must be at least as critical as their base types and interfaces |
|
Transparent methods may not use security asserts |
|
Transparent methods must not call into native code |
|
Rethrow to preserve stack details |
|
Do not dispose objects multiple times |
|
Initialize value type static fields inline |
|
Do not mark serviced components with WebMethod |
|
Disposable fields should be disposed |
|
Do not call overridable methods in constructors |
|
Disposable types should declare finalizer |
|
Finalizers should call base class finalizer |
|
Implement serialization constructors |
|
Overload operator equals on overriding ValueType.Equals |
|
Mark Windows Forms entry points with STAThread |
|
Mark all non-serializable fields |
|
Call base class methods on ISerializable types |
|
Mark ISerializable types with SerializableAttribute |
|
Implement serialization methods correctly |
|
Implement ISerializable correctly |
|
Provide correct arguments to formatting methods |
|
Test for NaN correctly |
|
Do not declare static members on generic types |
|
Do not expose generic lists |
|
Use generic event handler instances |
|
Generic methods should provide type parameter |
|
Avoid excessive parameters on generic types |
|
Do not nest generic types in member signatures |
|
Use generics where appropriate |
|
Enums should have zero value |
|
Collections should implement generic interface |
|
Consider passing base types as parameters |
|
Abstract types should not have constructors |
|
Overload operator equals on overloading add and subtract |
|
Mark assemblies with CLSCompliantAttribute |
|
Mark assemblies with ComVisibleAttribute |
|
Mark attributes with AttributeUsageAttribute |
|
Define accessors for attribute arguments |
|
Indexers should not be multidimensional |
|
Use properties where appropriate |
|
Replace repetitive arguments with params array |
|
Default parameters should not be used |
|
Mark enums with FlagsAttribute |
|
Enum storage should be Int32 |
|
Use events where appropriate |
|
Do not catch general exception types |
|
Implement standard exception constructors |
|
Nested types should not be visible |
|
ICollection implementations have strongly typed members |
|
Override methods on comparable types |
|
Enumerators should be strongly typed |
|
Lists are strongly typed |
|
Provide ObsoleteAttribute message |
|
Use integral or string argument for indexers |
|
Properties should not be write only |
|
Do not overload operator equals on reference types |
|
Do not declare protected members in sealed types |
|
Do not declare virtual members in sealed types |
|
Declare types in namespaces |
|
Do not declare visible instance fields |
|
Static holder types should be sealed |
|
Static holder types should not have constructors |
|
URI parameters should not be strings |
|
URI return values should not be strings |
|
URI properties should not be strings |
|
String URI overloads call System.Uri overloads |
|
Types should not extend certain base types |
|
Members should not expose certain concrete types |
|
Exceptions should be public |
|
Variable names should not match field names |
|
Avoid excessive complexity |
|
Identifiers should differ by more than case |
|
Identifiers should not match keywords |
|
Review unused parameters |
|
Remove unused locals |
|
Avoid excessive locals |
|
Initialize reference type static fields inline |
|
Avoid uncalled private code |
|
Avoid uninstantiated internal classes |
|
Avoid unsealed attributes |
|
Prefer jagged arrays over multidimensional |
|
Override equals and operator equals on value types |
|
Properties should not return arrays |
|
Test for empty strings using string length |
|
Mark members as static |
|
Avoid unused private fields |
|
Do not raise reserved exception types |
|
Use managed equivalents of Win32 API |
|
Instantiate argument exceptions correctly |
|
Non-constant fields should not be visible |
|
Do not mark enums with FlagsAttribute |
|
Do not raise exceptions in exception clauses |
|
Finalizers should be protected |
|
Do not decrease inherited member visibility |
|
Members should differ by more than return type |
|
Override equals on overloading operator equals |
|
Operator overloads have named alternates |
|
Operators should have symmetrical overloads |
|
Collection properties should be read only |
|
Use params for variable arguments |
|
Pass System.Uri objects instead of strings |
|
Provide deserialization methods for optional fields |
|
Avoid namespaces with few types |
|
Avoid out parameters |
|
Avoid empty interfaces |
|
Do not pass types by reference |
|
Validate arguments of public methods |
|
Avoid excessive inheritance |
|
Review misleading field names |
|
Avoid unmaintainable code |
|
Avoid excessive class coupling |
|
Do not name enum values 'Reserved' |
|
Resource string compound words should be cased correctly |
|
Compound words should be cased correctly |
|
Resource strings should be spelled correctly |
|
Identifiers should be spelled correctly |
|
Identifiers should not contain underscores |
|
Identifiers should be cased correctly |
|
Identifiers should have correct suffix |
|
Identifiers should not have incorrect suffix |
|
Do not prefix enum values with type name |
|
Events should not have before or after prefix |
|
Flags enums should have plural names |
|
Identifiers should have correct prefix |
|
Only FlagsAttribute enums should have plural names |
|
Parameter names should not match member names |
|
Identifiers should not contain type names |
|
Property names should not match get methods |
|
Identifiers should not have incorrect prefix |
|
Type Names Should Not Match Namespaces |
|
Parameter names should match base declaration |
|
Use preferred terms |
|
Literals should be spelled correctly |