Can I “Fix” Incorrect Resharper Annotations?

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); // null

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.

+3
source share
2 answers

, . XML Resharper (C:\Program Files (x86)\JetBrains\ReSharper\v5.1\Bin\ExternalAnnotations\ ). .

Enum.GetName, - mscorlib\mscorlib.[version].Contracts.xml. :

  <member name="M:System.Enum.GetName(System.Type,System.Object)">
    <attribute ctor="M:JetBrains.Annotations.NotNullAttribute.#ctor" />
  </member>

Visual Studio, :)

+6

, , , .

Resharper 8.2.3 :

C:\Users\YOUR_USER_NAME\AppData\Local\JetBrains\ReSharper\vAny\packages\ReSharper.ExternalAnnotations.8.2.3001\ReSharper\vAny\annotations\.NETFramework\mscorlib\...

, , ( , mscorlib).

+1

All Articles