为什么ReSharper的认为" thread.Name == NULL"永远是假的? [英] Why does ReSharper think that "thread.Name == null" is always false?
问题描述
我写一个辅助方法,用于方便地设置名称
A 发
的:
I am writing a helper method for conveniently setting the Name
of a Thread
:
public static bool TrySetName(this Thread thread, string name)
{
try
{
if (thread.Name == null)
{
thread.Name = name;
return true;
}
return false;
}
catch (InvalidOperationException)
{
return false;
}
}
它的工作按预期。 ReSharper的,但是,声称条件始终是假的,相应的代码是试探性可达。那不对。 A Thread.Name
,直到一个字符串分配总是空
It's working as intended. ReSharper, however, claims that the condition is always false and the corresponding code is heuristically unreachable. That's wrong. A Thread.Name
is always null until a string is assigned.
那么,为什么ReSharper的认为它是什么?并且有一些方法来告诉ReSharper的是不?
So, why does ReSharper think it is? And is there some way to tell ReSharper it isn't (other than // ReSharper disable ...
)?
我使用ReSharper的5.1.3。
I'm using ReSharper 5.1.3.
推荐答案
这是固定的RS我觉得6+。请参见 href=\"http://devnet.jetbrains.net/message/5273899\">。
This was fixed in 6+ of RS I think. See here.
这篇关于为什么ReSharper的认为" thread.Name == NULL"永远是假的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!