views:

21

answers:

1

Does anyone know if there is some option in VS2010 or some third party tool that I can use to detect recursive properties such as:

private string name;

public string Name
{
    get{ return this.Name; }
}

The above is obviously an error, but the compiler offers no warnings. I can appreciate that, in general, recursive methods are perfectly legal, but the above scenario does not make much sense. In fact it happens when I write the property before the backing field, even when writing this.name in lower case, because VS2010 will see that this.name does not exist and change the casing to this.Name which does exist.

The problem gets worse when binding to that property in WPF. The application crashes and takes VS2010 with it. That makes it very hard to debug, which is why I would love to have a tool of some kind that would alert me at compile time.

Hope someone can help.

/Klaus

+1  A: 

I know that ReSharper adds a column indicator next to a recursive call so that's easy to see. I don't think it has the option to find all recursive methods in your code though. ReSharper 5.0 EAP is available for VS2010.

Julien Lebosquain
I' not really a big resharper fan. It's expensive, eats away on my memory and many of its features have been added to VS2010. But maybe it's my only option. Thanks.
klausbyskov