1

So my company has started using StyleCop to enforce some coding standards and consistency and I have a question about 1 of the rules:

Rule SA1101 (Prefix local calls with this) throws a warning even on return lines such as: return View("~/Views/Shared/Error.cshtml");

I am not sure what the purpose of having this.View(...) really is? Am I missing something here?

Moreover, does anyone have a custom rule I could implement that enforces the "Prefix local calls with this" logic but not in return... statements?

Thanks

blubberbo
  • 4,441
  • 4
  • 23
  • 36
  • 1
    The 'this' rule is hotly contested, as you can see in this answer: https://stackoverflow.com/questions/1562540/why-does-stylecop-recommend-prefixing-method-or-property-calls-with-this. However, it is just as applicable (or inapplicable, depending on your opinion) on a return statement as any other statement. Its intent is to clarify intent, nothing more. Personally, I just disable it altogether. – SomeGuy May 31 '18 at 16:28
  • I don't see why `return` should be special... Are they sons of the king? – xanatos May 31 '18 at 17:07

0 Answers0