2

I'm refining the built in dead code query in NDEpend and I'm finding a lot of false positives from standalone programs (i.e. w/ Main() entrypoints).

I noticed that the built in unused types query has this clause:

 !NameIs "Program" AND // Generally, types named Program 
                       // contain a Main() entry-point 
                       // method and this condition avoid 
                       // to consider such type as 
                       // unused code.

Is it impossible to write something like

HasMethodNamed "Main"

instead? That's what I'd really like to select for.

Patrick from NDepend team
  • 13,237
  • 6
  • 61
  • 92
Yostage
  • 292
  • 2
  • 4
  • 12

1 Answers1

1

Yes, you can complete your CQL rule with a HasMethodNamed "Main".

For that:

  1. Convert your CQL rule to a CQLinq rule
  2. add the CQLinq where clause && t.Methods.Where(m => m.SimpleName == "Main").Any()
Patrick from NDepend team
  • 13,237
  • 6
  • 61
  • 92