Why does StyleCop recommend prefixing method or property calls with “this”?

I don’t really follow this guidance unless I’m in the scenarios you need it:

  • there is an actual ambiguity – mainly this impacts either constructors (this.name = name;) or things like Equals (return this.id == other.id;)
  • you want to pass a reference to the current instance
  • you want to call an extension method on the current instance

Other than that I consider this clutter. So I turn the rule off.

Leave a Comment