I have installed NDepend (14-day trial version) as a Visual Studio 2015 Extension, and it works now.
I would like to get some metrics of some classes in my solution:
I did not find any useful instruction from its official site, does anyone know?
Thanks.
You can write C# LINQ code queries to obtain pretty much any code metric you need.
length of identifiers
from t in Application.Types
select new { t, t.SimpleName.Length }
fan in / fan out
from t in Application.Types
select new { t, t.TypesUsed, t.TypesUsingMe }
weighted method of class
from t in Application.Types
select new { t, t.CyclomaticComplexity }
coupling of class objects (according to this definition)
from n in Application.Namespaces
let NumberOfClasses = n.ChildTypes.Count()
let NumberOfLinks = n.ChildTypes.SelectMany(t => t.TypesUsed).Distinct().Count()
select new { n, CBO = NumberOfLinks / (float)NumberOfClasses }
You can then transform a code query into a code rule with the prefix warnif count > 0 and save the rule to get it executed in Visual Studio and/or in your BuildProcess.
// <Name>Type name shouldn't exceed 25 char</Name>
warnif count > 0
from t in Application.Types
where t.SimpleName.Length > 25
orderby t.SimpleName.Length descending
select new { t, t.SimpleName.Length }

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With