NDepend.API Documentation
GetNbLinesOfCode_GuaranteedIfPDBFound Method
NDepend.CodeModel Namespace > ExtensionMethodsHelpers Class : GetNbLinesOfCode_GuaranteedIfPDBFound Method
The code element for which we want to obtain the number of line of code
Try gets a number of lines of code for an application codeElement. This value is guaranteed not being zero if the code element is in an assembly for which PDB file has been found and parsed.
Syntax
[Extension()]
public static Nullable<uint> GetNbLinesOfCode_GuaranteedIfPDBFound( 
   ICodeElement codeElement
)

Parameters

codeElement
The code element for which we want to obtain the number of line of code
Remarks
The metric ICodeContainer.NbLinesOfCode is computed from number of sequence points obtained at analysis time when parsing a PDB file.
As a consequence, if a PDB file is not found, all associated ICodeElement objects have a null NbLinesOfCode.

s However there are several cases where this metric is not defined for a code elements declared in an assembly with PDB file found:
- Abstract method
- Implicit constructor
- Field
- Interface
- Enumeration
- Namespace, assembly or code base that contains only interfaces and enumerations

This method is returning a non-null, non-zero value if codeElement satisfies the PDB found condition.
- This value is 1 for any abstract method, implicit constructor or field.
- In all other cases, codeElement is a ICodeElementParent object, and this methods returns NbLinesOfCode + ICodeElementParent.MeAndRecursiveChildren.Count.
Notice that in the peculiar case where codeElementis a ICodeBase, the PDB found condition means that a PDB file must have been resolved for all application assemblies at analysis time.
Notice that this method returns null for any third-party code element.
Requirements

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

See Also

Reference

ExtensionMethodsHelpers Class
ExtensionMethodsHelpers Members
PDBFound Property
NbLinesOfCode Property