开发者

Code is heuristically unreachable

What does this mean in contrast to "unreachable 开发者_JS百科code detected"?


Heuristically unreachable means possibly unreachable code. Unreachable code is certainly unreachable.


Here's an example of ReSharper giving the cryptic "Heuristically unreachable code" warning:

Code is heuristically unreachable

It's an example of:

  • ReSharper being way too smart for itself, because if you remove it the compiler will complain about a lack of a return statement
  • Use of a word that is not common lexicon


Say you're deleting 2 different kinds of objects in a unit test and you want to use a try/catch for both types.

If you delete one, and then check to see if it was successful without properly casting using:

Assert.IsNull(obj1);

The "IsNull" may always be null because you casted obj1 incorrectly, or did something above the greyed out code incorrectly with obj1, the next try/catch will be greyed out.

Try fixing the thing you're trying to Assert.IsNull and once it's not always null or undefined, the greyed out code will be reachable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜