Sponsored By Aspose - File Format APIs for .NET

Aspose are the market leader of .NET APIs for file business formats – natively work with DOCX, XLSX, PPT, PDF, MSG, MPP, images formats and many more!

NDepend Analysis Inputs

 

I would like here to
clarify from where NDepend analysis
takes its inputs. Indeed, it might sounds mysterious how NDepend can infer
comment metrics from assemblies for example. The trick is that the analysis
is fetching data from 4 different places: .NET assemblies, .NET PDB files, C#
source files and coverage files.

 

 

 

Here are some remarks:

 

  • The 2 orange rows on the
    left reflect the fact that PDB files location are inferred from assemblies
    files location, and source files are referenced from PDB files. Coverage files
    location cannot be inferred and must be specified.
  • A PDB file does not need
    to reside in the same folder as its corresponding assembly. NDepend will try first
    to find the PDB in the same folder and if not found, it will try to find it in
    any of the folders specified.
  • Not all C# source files needed
    to build a .NET assembly are referenced from the PDB file. Only those
    containing some non-abstract methods are referenced. However NDepend uses a
    heuristic to find the corresponding Visual Studio project file from the
    referenced PDB files. If the VS project file is found, NDepend can then know
    about all source files referenced by the project.
  • In case the server used
    to build the assemblies is not the same as the server that performs the NDepend
    analysis, there is the possibility to rebase the location of source files as
    explained here.
  • The bulk of data used by
    NDepend comes from assemblies themselves. Only the number of lines of code
    is computed from PDB files. The lines of code computation is explained here.
  • Source files are parsed
    to obtain metrics relative to comments: PercentageComment,
    and NbLinesOfComment
    .
  • NDepend computes the Cyclomatic
    Complexity from the IL code
    . If source files are available it computes also the Cyclomatic Complexity from
    the source code
    .
    Experience shows that IL CC is a bit larger than the Source code CC. Indeed, a
    C# ‘if’ expression yields one IL jump. A C# ‘for’ loop yields two different
    offsets targeted by a branch IL instruction while a ‘foreach’ C# loop yields
    three.
  • So far only C# source
    files can be parsed by NDepend and in the future we plan to parse also VB.NET
    source files. Notice that because the number of lines of code is computed from
    PDB files, this metric is available for all .NET languages.
  • If some PDB files and/or
    some source files are missing, NDepend will warn about it but won’t stop the
    analysis. As the bulk of data is inferred from assemblies themselves it is still
    useful to analyze assemblies only, especially tier assemblies not released with
    source code.
  • You can read the Coverage
    FAQ
    to know more about NCover
    and VSTS
    coverage XML files. Coverage metrics values are inferred from these files,
    including: PercentageCoverage,
    NbLinesOfCodeCovered and,
    NbLinesOfCodeNotCovered. As PDB and source files, coverage files are optional.
  • Finally, NDepend will
    detect and warn about any synchronization issue between assemblies, and PDB
    files, sources files and coverage files.
This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.