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 }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.