Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off "Qualifier 'this.' is redundant" warnings in Resharper?

Tags:

c#

resharper

In my code I have a lot of this. qualifiers (a habit from writing Python code), so I have a lot little orange warning markers in the right hand gutter saying "Qualifier 'this.' is redundant". I don't want to remove the this. qualifiers. How can I turn off the orange warning markers?

like image 237
dan-gph Avatar asked Aug 13 '14 01:08

dan-gph


4 Answers

For Resharper 9 it's been moved. Actually I never noticed in Resharper 8, because I use "this" for clarity. My problem is that now it's all over the place and it drives me insane. I hope this helps someone, because it took me some time to find this.

Resharper 9 location

like image 70
pqsk Avatar answered Oct 21 '22 08:10

pqsk


Change your settings in the Inspection Severity section. In the C# tab, there is a section called Redundancies in Code. In there is a Redundant this.' qualifier setting. I put mine on "Do not show" (gray-colored).

enter image description here

enter image description here

like image 24
LVBen Avatar answered Oct 21 '22 07:10

LVBen


The following is taken from the comment by @user2864740, which the OP found to solve the problem:

It should be possible to open up the ReSharper context menu - click on the pencil thing to the left when the warning is "in focus", or perhaps hit Alt+Enter (?) - and select "Change Inspection Severity..". It should provide several options from Ignore to Error. I believe there is also an inspection option to Require the this. explicitly, but I've never felt inclined to look for or enable it. (Such an option would likely be within the main Code Inspection R# options.)

like image 25
DeanOC Avatar answered Oct 21 '22 06:10

DeanOC


If you don't have the ($$$) Resharper, you don't need it to remove the orange warning markers or the lightbulb suggestions. You can do this within VS 2015: Follow exactly this set of instructions in the green-checked answer, but tick the "Qualify member access with 'this' " instead. Click OK, and you'll never see another this lightbulb again.

I don't know if this particular configuration is available in other VS versions, but at least you can check your version.

OR, apply the change globally (project-wide or solution-wide) with one click as demonstrated here:

Project-wide removal of <code>this</code> qualifier

And you'll never see it again in your project.

like image 1
Michael D. O'Connor Avatar answered Oct 21 '22 08:10

Michael D. O'Connor