ndepend

Count the number of indirectly used assemblies in NDepend


I'm trying to count the indirect assembly references. The following does not work because IsIndirectlyUsing wants a constant string: "Only constant literal string are accepted as input for IsIndirectlyUsing(string)"

Is there a method to get the indirect assemblies used?

from a in Assemblies 

let indirectlyUsed = 
  from dep in Assemblies
  let depName = a.FullName
  where a.IsIndirectlyUsing(depName)
  select dep

where a.PDBFound orderby a.AssembliesUsed.Count() descending
select new { a, a.AssembliesUsed, indirectlyUsed, a.NbLinesOfCode, a.NbILInstructions }```

Solution

  • The NDepend.API method FillIterative() is here to help:

    from a in Assemblies 
    
    let indirectlyUsed = a.AssembliesUsed.FillIterative(
        asms => asms.SelectMany(a1 => a1.AssembliesUsed)).DefinitionDomain
    
    where a.PDBFound orderby indirectlyUsed .Count() descending
    select new { a, a.AssembliesUsed, indirectlyUsed, a.NbLinesOfCode, a.NbILInstructions }
    

    List assemblies used directly and indirectly