4

Closed

Remove 'this' qualification in Visual Studio 2015 Preview

description

The new function in Visual Studio 2015 Preview "Light Bulb", shows "Remove 'this' qualification" message, suggests all the local call with "this." to be removed. This conflicts to SA1101 PrefixLocalCallsWithThis.
Will StyleCop change/delete this rule to fit VS2015? I don't know whether there are any other light bulb message that's conflict to StyleCop rules...
Closed Dec 1, 2016 at 5:24 AM by csdahlberg
Closing this work item due to its age and because development is moving to GitHub. Please open a new issue at https://github.com/StyleCop/StyleCop if this still needs to be addressed.

comments

rjrelander wrote Jan 31, 2015 at 5:36 PM

Found a setting for this in Visual Studio CTP 5. Might have been there before and I just didn't notice. Go to "Tools - Options - Text Editor - C# - Code Style" and check the "Qualify member access with 'this'" box. That turns off the light bulb message when you use "this" qualification but (oddly enough) with the box checked, it doesn't give you a light bulb if you forget to use "this" qualification.

It used to bother me when default StyleCop enforced "this" qualification but it's grown on me and now it really bothers me when I see code without it. I'm not a huge fan of "using" statements either. It has helped me to fully qualify everything to remember where they originate. Your mileage may vary ... :-)

subt13 wrote Feb 5, 2015 at 5:55 PM

How did you get StyleCop to work with Visual Studio 2015 ?

ChrisTorng wrote Feb 6, 2015 at 7:07 AM

I didn't install StyleCop addin to work with VS 2005. I use NuGet Package http://www.nuget.org/packages/StyleCop.MSBuild to let it run with every build.

ChrisTorng wrote Feb 6, 2015 at 7:22 AM

Instead, I am huge fan of "using" statements. Because I like to see "all external references" from the top of every code files. Then I can have a glance that this code file is related to which external resource. And hope StyleCop to have a rule that will warn at every namespace usage in code, to use "using" instead.