Code is heuristically unreachable

不想你离开。 提交于 2019-12-22 01:47:15

问题


What does this mean in contrast to "unreachable code detected"?


回答1:


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




回答2:


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

It's an example of:

  • Resharper being way to 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



回答3:


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.



来源:https://stackoverflow.com/questions/5532509/code-is-heuristically-unreachable

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!