Automatically adding the identifier 'this' when autocompleting in visual studio

I use the custom ruleset in StyleCop along with the ReSharper plugin to automatically validate my code as I type.

Rule SA1101 in StyleCop states that calls to members of the current class should begin with this.to indicate that it is actually defined in the current class.

Is there a way to configure it, so when I go to autocomplete a member of the class, it automatically adds to the prefix this., so I don’t need to remember how to enter it or add it later?

Let's use public bool Running { get; set; }as an example:

I type " Run" + Tab, and now he goes on Running, but I would like him to appear as this.Running.

This will save a lot of time and gain.

EDIT

Note that the option ReSharper => Options => Code Editing => C# => Formatting Style => Other => "Force 'this.' qualifier for instance member"(as mentioned by John) in resharper does not work properly. Not when adding ;instructions at the end (which would be acceptable), or after adding a tab this.to a class member.

+3
source share
1 answer

If you go to

ReSharper => Options => Code Editing => C# => Formatting Style => Other

there is an option "Strength". classifier, e.g. member. "

Enabling this should work as you plan.

+2
source

All Articles