I've always been explicit with my code when using instance members, prefixing them with this.
and with static members, prefixing them with the type name.
Roslyn seems not to like this, and politely suggests that you can omit this.
and Type.
from your code where appropriate...
...so where I would do this... (no pun intended)
public void DoSomethingCool()
{
this.CallAwesomeMethod();
CoolCucumber.DoSomethingLessAewsome();
}
...roslyn suggests I do this...
public void DoSomethingCool()
{
CallAwesomeMethod();
DoSomethingLessAwesome();
}
...however when it comes to using extension methods, it appears that I cannot omit the use of this.
for example...
public int GetTotal()
{
// This doesn't work
return Sum(o => o.Value);
// This does
return this.Sum(o => o.Value);
}
Questions:
- Why does Roslyn not seem to like explicit use of
this.
andType.
? - Why do I need to explicitly use
this.
for extension methods? - Whilst not strictly part of this question, how do I resolve the discrepancy between Roslyn NOT wanting me to use
this.
andType.
and StyleCop's analyzers insisting that I use them?