Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReSharper 9.2 produces warning for nameof with event name

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?

like image 502
Rob Kent Avatar asked Jan 04 '16 14:01

Rob Kent


1 Answers

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

like image 85
Patrick Quirk Avatar answered Oct 24 '22 19:10

Patrick Quirk