Resharper quick-fix puts this qualifier in front of properties and not just private fields

297 views Asked by At

I am using VS 2012 and Resharper 7. In my project the convention to access private fields is always with "this" qualifier, just to make it clear it's private (e.g. this.myPrivateField). Properties should not be accessed with the this qualifier. We configured resharper and that's working fine. But if I use a quick-fix option, it always puts the this qualifier in front of the used property (e.g. this.MyPublicProperty). Is there any way/setting to turn of that behaviour?

1

There are 1 answers

0
J. Steen On

You can set the feature to work "For fields in this class", or "For fields", if you're sure to also follow the very standard convention of making all fields private.

Turning on "For fields in this class" allows me to have this code after an automatic cleanup:

public class MyClass
{
    private string myPrivateField;

    public string MyPublicProperty { get; set; }

    public void MyMethod()
    {
        this.myPrivateField = "Cucumber";
        MyPublicProperty = "Cucumber as well";
    }
}