NDepend.API Documentation
SizeOfInst Property (IType)
NDepend.CodeModel Namespace > IType Interface : SizeOfInst Property
Gets a numeric nullable value measuring this type's instance object footprint, measured in bytes.
Syntax
Nullable<ushort> SizeOfInst {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 SizeOfInst numeric value.
Remarks
Size of Instance code metric description:
SizeOfInst for a class or a structure is defined as the sum of IField.SizeOfInst values of its fields plus the size of instances of its base class.
SizeOfInst for a generic type might be erroneous because we cannot statically know the footprint of parameter types (except when they have the class constraint).
SizeOfInst for an enumeration is equal to the size of instances of the underlying numeric primitive type. It is computed from the enumeration's value__ instance field (all enumerations have such a field when compiled in IL).
SizeOfInst for a static class or an interface is null.

Recommendations:
Types where SizeOfInst is higher than 64 might degrade performance (depending on the number of instances created at runtime) and might be hard to maintain.
However this is not a rule since sometime there are no alternatives. For example, the SizeOfInst value for the System.Net.NetworkInformation.SystemIcmpV6Statistics .NET framework class is 2064 bytes.
Non-static and non-generic types where SizeOfInst is equal to 0 indicate stateless types that might eventually be turned into static classes.

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