1

I use NDepend to analyze static code dependencies. However, it does not recognize dependencies introduced by constants, because constants are inlined by the compiled and so the dependency is not visible to reflection used by NDepend.

I am at a loss here. I cannot replace constants with Enums - too much code, too many non integer constants (like strings).

Theoretically using Roslyn API should help here, but I do not understand what am I to do exactly. Given a source code file, do I need to build the syntax tree of the file and scan every node looking for a constant? I have not seen any nodes dedicated to constants, so it must be more complicated than just filtering the root.DescendantNodes().

Maybe there is an undocumented compiler option that helps somehow here. I could not find anything.

The context of this request is refactoring a big monolithic application and part of this work is identifying compile time dependencies.

halfer
  • 19,824
  • 17
  • 99
  • 186
mark
  • 59,016
  • 79
  • 296
  • 580

0 Answers0