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;
}
}
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.
So, why does ReSharper think it is? And is there some way to tell ReSharper it isn't (other than // ReSharper disable ...
)?
I'm using ReSharper 5.1.3.
This was fixed in 6+ of RS I think. See here.
It appears to be a bug in R#, fixed in v6.
see: http://devnet.jetbrains.net/message/5366898
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With