Search code examples
visual-studiometricsndependcoupling

Ndepend Class Coupling Value exclude all classes not in my project


I tried to calculate the class coupling with ndepend. But as far as I can see, all dependencies on other classes are added (see image, so the ones from my Project: MultiCar, from mscorlib and System). I would like to only consider the types from my project and not the rest. Of course the value is given here, but I would like it to be directly calculated. Is there any why? I already tried to change the query shown at the top of the picture, but I am not familiar with it and did not find a good explanation on how to change it the way I want it to be. I really hope someone can help me.

The query is depicted in this figure.


Solution

  • To do so you need to edit the code query generated by the Search type by class coupling panel. Edit Query of NDepend Search type by class coupling panel

    The query generated to edit manually is:

    from t in Application.Types 
    where t.NbTypesUsed >= 0 
    orderby t.NbTypesUsed descending 
    select new { 
       t,
       t.TypesUsed,
       t.TypesUsingMe
    }
    

    You just need to edit the TypesUsed line:

    from t in Application.Types 
    where t.NbTypesUsed >= 0 
    orderby t.NbTypesUsed descending 
    select new { 
       t,
       TypesUsed = t.TypesUsed.Where(tu => !tu.IsThirdParty),
       t.TypesUsingMe
    }
    

    Et voilà :)

    NDepend Search type by class coupling discard third-party types