Periodically questions are posted where the OP uses a property in its getter/setter which leads to recursive calls and results in StackOverflowException
. The most recent one is here.
How should we handle such questions?
In my opinion, these are typos and have to be closed: instead of typing the backing field name, the OP has typed the property name. I guess every programmer has to face this error once. Some of them (those hopeless kind) will ask a question on Stack Overflow, and it means there will be hundreds of such questions, not linked, not shown as relevant, etc.
Closing a question as duplicate is an option too. We have a canonical duplicate for NullReferenceException), but I am unable to find one for StackOverflowException
.
Yet, every such question (at least from my experience) receives an answer, which in my opinion is wrong.
StackOverflowException
in one of its methods or what? Do you have an example?stackoverflow.com
? I mean one could answer in this sense: "While stackoverflow is here to help for any kind of programming problems, stack overflows are the consequence of unwanted direct or indirect recursion most of the time". And we'd need one good answer how to avoid unwanted recursion and how to do intended recursion right.