I am trying to write my own rule for analyzing FxCop code that will warn developers about methods that contain too deep nested blocks of code and will encourage them to redistribute the mess.
ex. I am trying to avoid the following situation:
if(condition)
{
foreach(var item in items)
{
if(anotherCondition)
{
for(var product in item.Products)
{
}
}
}
}
I get stackoverflow when I redefine a method VisitBlock(Block block)
that counts the depth of a block, because there seems to be a circular reference from one of the properties of the block to the block itself. that is, the following for some i: block.Statements [i] == block
Why is there such a circular reference? How to avoid this? Thank!
source
share