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

StackOverflow https://stackoverflow.com/questions/11306521

  •  18-06-2021
  •  | 
  •  

Domanda

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.

È stato utile?

Soluzione

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:

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top