ReSharper 9.2 produces warning for nameof with event name

204 Views Asked by At

According to the C# specification this is valid code, and it compiles and runs.

var myObj = new MyClass();
var x = nameof(myObj.SomeEvent);
Console.Write(x); // Prints 'SomeEvent'

where SomeEvent is:

public event EventHandler SomeEvent;    

But ReSharper produces the warning:

"The event SomeEvent can only appear on the lefthand side of += or -="

I can't find a way to suppress this in Options > Inspection Severity. Is it a bug in ReSharper?

1

There are 1 best solutions below

0
On BEST ANSWER

It's a bug. It's fixed in version 10.