I like Resharper, but sometimes it gives the wrong warnings, perhaps because the inline annotations for BCL types are wrong. For example, in this code:
private static string GetDescription(T value)
{
Type type = typeof(T);
string name = Enum.GetName(type, value);
if (name != null)
{
...
This gives me a warning in the instruction if: "The expression is always true." But Enum.GetNamecan return null:
string name = Enum.GetName(typeof(DayOfWeek), (DayOfWeek)42);
I guess this is because Enum.GetNamethere is an annotation for [NotNull]. Is there any way to fix this, so I am not getting a warning?
Note. I am using Resharper 5.1; this problem may be fixed in version 6, but I do not want to update right now.
source
share