NDepend.API Documentation
PercentageCoverage Property (ICodeContainer)
NDepend.CodeModel Namespace > ICodeContainer Interface : PercentageCoverage Property
Gets a numeric float nullable value in the range [0f,100f] assessing the coverage percentage for this code element.
Syntax
Nullable<float> PercentageCoverage {get;}

Property Value

  • null if no code coverage data are imported through the NDepend project settings NDepend.Project.IProjectCoverage.
  • null if this code element is defined in a third-party assembly.
  • null if the PDB file of this assembly or code element parent's assembly, hasen't been found.
  • null if the code element is tagged with the attribute defined in NDepend.Project.IProjectCoverage.NDepend.Project.IProjectCoverage.UncoverableAttribute.
  • null if the code element does not contain any PDB sequence point.
  • 0 if the code element NbLinesOfCode is 0 and the code element contains at least one PDB sequence point (opening/closing braces have sequence points but don't count as lines of code).
  • Otherwise returns the code coverage by tests percentage for this code element computed as NbLinesOfCodeCovered / (NbLinesOfCodeCovered + NbLinesOfCodeNotCovered). Notice that if a code element parent (assembly/namespace/type) contains some child code elements tagged with NDepend.Project.IProjectCoverage.NDepend.Project.IProjectCoverage.UncoverableAttribute the lines of code of these child code elements are not counted neither in NbLinesOfCodeCovered nor in NbLinesOfCodeNotCovered.
    As a consequence (NbLinesOfCodeCovered + NbLinesOfCodeNotCovered) can be lower than NbLinesOfCode.
    As a consequence a code element can have 100% code coverage, even if NbLinesOfCodeCovered is lower than NbLinesOfCode, as long as NbLinesOfCodeNotCovered value is 0.
  • Remarks
    Recommendations:
    The closer to 100%, the better!
    Requirements

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

    See Also

    Reference

    ICodeContainer Interface
    ICodeContainer Members
    RelyOnCodeCoverageData Property
    NbLinesOfCodeCovered Property
    NbLinesOfCodeNotCovered Property
    CoverageDataAvailable Property
    PercentageBranchCoverage Property
    IProjectCoverage Interface