Hi,
I need to write a rule for checking the number of levels of nesting in a method. It should count the maximum depth of if, for and while branches in the bodies of methods like For loop containing if and more For loop inside that and say one more if or while with in that and so on. Will some body help me out on this
Thanks and Regards
Prash

Checking for maximum number of levels
everguess
This is a fairly complicated analysis. FxCop renders a method body as an AST (raised from IL) in the Method.Body member. We also publish the IL instruction stream via Method.Instructions. We do not create and expose a control flow graph, however, you'd need to create this construct yourself. We're looking at providing an SDK for method control flow graphs in a future tool update.
Note that any analysis you do here in FxCop will be against the IL that the compiler has emitted and will not necessarily map directly to the higher-level source language the code was written in.