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.