The usual behaviour of VS is to display in yellow the faulting line :
int i = 1;
switch (i)
{
default:
throw new NotImplementedException(); //this will be yellow
}
However, quite frequently, I've witnessed that the wrong line is coloured, like in this example :
int i = 1;
switch (i)
{
default:
if (i==1)
throw new NotImplementedException();
break; i = 1; //this line is displayed in yellow, which makes no sense
}
While I understand some of the differences between those two snippets (in the first situation, the "throw..." line is the last executable line of the method, so no IL is generated for the code coming after this, thus it's the last possible line to "display" the exception on), I'm wondering while VS fails to display the exception on the correct line in the second snippet.
Has someone any hints on the reason of this strange behaviour ? Despite knowing about this caveat, once in a while I end up spending a few minutes debugging the wrong line.