ndepend

NDepend: how to limit JustMyCode to the methods used by x?


The official documentation explains how to limit JustMyCode by exclusion using notmycode

notmycode from m in Methods where
  m.SourceFileDeclAvailable && 
  m.SourceDecls.First().SourceFile.FileName.ToLower().EndsWith(".designer.cs")
select m

I'd like to limit JustMyCode to only the methods returned by this query

from m in Methods 
let depth0 = m.DepthOfIsUsedBy("InsertMuk(Int32,Int32,BetCoupon,Boolean,Boolean,Boolean,DateTime&,Boolean)")
where depth0  >= 0 orderby depth0
select new { m, depth0 }

Will it redefine the codebase for all the other queries?


Solution

  • This query should work, assuming you disable all other notmycode queries and also that you provide Namespace.ClassName in the string:

    notmycode
    let methodsUsed =  Methods.Where(m1 => m1.DepthOfIsUsedBy("Namespace.ClassName.InsertMuk(Int32,Int32,BetCoupon,Boolean,Boolean,Boolean,DateTime&,Boolean)") >= 0)
    from m in Methods.Except(methodsUsed )
    select m