"Delegate invocation can be simplified"

Answered

I just updated from Resharper 10.1 to Resharper 10.2, and now I am always seeing the "Delegate invocation can be simplified" tip on delgate invocations, which is to change "if (OnWhatever != null) OnWhatever()" into "OnWhatever?.Invoke()". The problem is I'm using C# 4 and that should only be showing up for C# 6. Resharper 10.1 correctly didn't show the tip when I had "C# 4" selected as my C# level in a project, but Resharper 10.2 does. Also, if I click the light bulb to try to make the change it will often throw a Resharper error and ask if I want to disable that tip but disabling it doesn't stop it either. I also can't find a setting anywhere in Code Inspection to turn it off. Any ideas?

4 comments
Comment actions Permalink
Official comment

Please try disabling ReSharper (Tools | Options | ReSharper Ultimate | Suspend Now) - such suggestion will stay in Text Editor since it comes from Roslyn, not from ReSharper.  

Comment actions Permalink

Hello Tom,

What Visual Studio version do you use? 

By the way, seems like you are talking about R# 10.0.1 and R# 10.0.2 since there has not been R# 10.1/10.2 yet. 

Thanks! 

 

0
Comment actions Permalink

Visual Studio 2015 Update 2. And yes, sorry, I meant 10.0.1 and 10.0.2.

0
Comment actions Permalink

My apologies; you are correct. The issue is from Update 2 for Visual Studio 2015, which I installed at the same time as the Resharper update. I assumed it was Resharper but it's not. They mention it on this page: https://www.visualstudio.com/en-us/news/vs2015-update2-vs.aspx#CsharpAndVB

Thanks for your help!

0

Please sign in to leave a comment.