I have been trying to follow StyleCop's guidelines on a project, to see if the resulting code was better in the end. Most rules are reasonable or a matter of opinion on coding standard, but there is one rule which puzzles me, because I haven't seen anyone else recommend it, and because I don't see a clear benefit to it:
SA1101: The call to {method or property name} must begin with the 'this.' prefix to indicate that the item is a member of the class.
On the downside, the code is clearly more verbose that way, so what are the benefits of following that rule? Does anyone here follow that rule?
StyleCop analyzes C# source code to enforce a set of style and consistency rules. Use it as a NuGet package which is the best way to work in a team.
I don't really follow this guidance unless I'm in the scenarios you need it:
this.name = name;
) or things like Equals
(return this.id == other.id;
)Other than that I consider this clutter. So I turn the rule off.
It can make code clearer at a glance. When you use this
, it's easier to:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With