Is this an analyzer bug?

Answered

Rider keeps telling me that Null refs are possible but I don't see how.

class Class1
{
internal enum Enum1
{
Case0,
Case1,
Case2,
}

internal Enum1 EnumField { get; set; }

[CanBeNull]
internal Class1 ClassField { get; set; }

public void Test()
{
if (EnumField != Enum1.Case0)
{
if (ClassField == null) throw new Exception();
}

switch (EnumField)
{
case Enum1.Case0:
break;
case Enum1.Case1:
ClassField.Test(); // Possible null ref?
break;
case Enum1.Case2:
ClassField.Test(); // Possible null ref?
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
1 comment
Comment actions Permalink

Hi,

ReSharper does not support value analysis on enum's values. Please, feel free to vote for the issue: https://youtrack.jetbrains.com/issue/RSRP-45506.

 

Kind regards,

Sofia.

1

Please sign in to leave a comment.