StyleCop has a rule about using "this." prefix to calling class members (SA1101).
Is this rule holds true about a member (for example a method) of a class which is inherited from its base class.
Example:
class BaseClass
{
protected void F1()
{
...
}
}
class ChildClass : BaseClass
{
protected void F2()
{
...
}
protected void F3()
{
this.F2(); // This is correct acording to SA1101
// F1 is a member of base class and if I dont put this prefix, stylecop will not show any message.
this.F1(); // Is this correct?
F1(); // Or this?
}
}
I know this is just for better readability.
The documentation for StyleCop Rule SA1101 actually mentions this:
A violation of this rule occurs whenever the code contains a call to an instance member of the local class or a base class which is not prefixed with ‘this.’.
(emphasis added by myself). So yes, the rule requires this.
on every access to an instance member, irrespective of whether that member is in the local class or inherited from a base class.