ndependcqlinq

NDepend - how to run a report on number of methods having and not having an attribute


I would like to run a report on how many methods in a particular assembly and its sub-assemblies have and do not have certain attribute. Can you write to me a sample code for this? What are the reporting options? I need to run this report every night.


Solution

  • You could write something like:

    (from m in Application.Assemblies.WithNameLike("^MyAssembly").ChildMethods()
     where m.HasAttribute("NamespaceA.AttributeA") &&
           m.HasAttribute("NamespaceB.AttributeB") &&
          !m.HasAttribute("NamespaceC.AttributeC")
     select m).Count()
    

    Note that the aggregate call to Count(), that can be removed if you wish to list methods instead of counting them.

    I need to run this report every night.

    Here is the relevant documentation: