Seb*_*zus 8 c# resharper multithreading
我正在编写一个帮助方法来方便地设置Namea 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;
}
}
Run Code Online (Sandbox Code Playgroud)
它按预期工作.然而,ReSharper声称条件总是错误的,并且相应的代码是启发式无法访问的.那是错的.在Thread.Name分配字符串之前,A 始终为null.

那么,为什么ReSharper认为它是?有没有办法告诉ReSharper它不是(除了// ReSharper disable ...)?
我正在使用ReSharper 5.1.3.