3 ms·
Visual Studio 2017 and above actually does complain about it. It will recommend removing `this` from your code.
by jermaustin1 6y ago
Visual Studio 2017 and above actually does complain about it. It will recommend removing `this` from your code.
- crc32 6y agoI don't think this is true - sounds like resharper, an extension for Visual Studio. I don't think this is the default out of the box.
- jermaustin1 6y agoI dont use any extensions on my Visual Studio, and it complains [1] 1: https://imgur.com/a/UTGrYsq https://imgur.com/a/UTGrYsq
- jasomill 6y agoThat, or change the IDE style preference that triggers this suggestion to suit your preferred style, preferably using a mechanism like .editorconfig that embeds these preferences within the project itself. There's nothing sacred about Visual Studio defaults; give me an IDE and a language I use regularly, and there's probably at least one default style preference I disagree with (and typically more, especially for C-like languages where the currently fashionable defaults place a newline before every keyword and brace). As for this, I'd actually prefer a Python-like convention making the instance explicit in instance method parameter lists and bodies, but, given that implicit this exists in the first place, I don't really have a preference, and therefore stick with the conventional default — omit unnecessary this — unless working on an existing project whose established style includes it.
- jermaustin1 6y ago> give me an IDE and a language I use regularly, and there's probably at least one default style preference I disagree with But that is disingenuous. We aren't talking about [insert opensource language] + [insert opensource IDE], where your the IDE's inbuilt preferences match closer to the IDE developer's preference than the random language you are developin in it. This is Microsoft's Visual Studio and Microsoft's C#. Their linter is recommending the best practice conventions. You can definitely disagree with them, but I don't, that is why I wrote this piece. I don't like "this." scattered throughout the code when it isn't proper according to the language designers.