NDepend.API Documentation
DepthOfInheritance Property
NDepend.CodeModel Namespace > IType Interface : DepthOfInheritance Property
Gets a numeric nullable value measuring this type's depth of inheritance.
Syntax
Nullable<ushort> DepthOfInheritance {get;}

Property Value

null if this type is declared in a third-party assembly.
null if this type is static or is an interface.
Otherwise returns this type DepthOfInheritance numeric value.
Remarks
The depth of inheritance for a class directly deriving from System.Object class is equal to 1.
The depth of inheritance for a structure is equal to 2 since it derives from System.ValueType that derives from System.Object.
The depth of inheritance for an enumeration is equal to 3 since it derives from System.Enum that derives from System.ValueType that derives from System.Object.

Recommendations:
Types where DepthOfInheritance is higher or equal than 6 might be hard to maintain. However this is not a rule since sometime your classes might inherit from third-party classes that have a high depth of inheritance.
For example, the average depth of inheritance for .NET Framework classes that derive from System.Windows.Forms.Control is 5.3.
Requirements

Target Platforms: Windows 11, 10, 8, 7 and Linux, MacOS with net8.0, net7.0 or net6.0 installed

See Also

Reference

IType Interface
IType Members