Brian Hooper
Brian Hooper

Reputation: 22034

Visual Studio C# Code colour of this

I have been fiddling with the colours of the various C# items in my new Visual Studio 2017 (Community) using the Tools->Options->Font and Colors. Everything is fine apart from the this keyword.

Does anyone happen to know which of the Display Items one can change the colour of will affect the this keyword?

Upvotes: 5

Views: 456

Answers (3)

Cee McSharpface
Cee McSharpface

Reputation: 8726

There is analyzer rule

IDE0003 Name can be simplified

with the option "Remove 'this' qualification".

I found no way to set a different color, but the rule can be deactivated so the dimming is not applied: https://stackoverflow.com/a/32144170/1132334

This does specifically target this (or Me in VB).

Upvotes: 3

Brian Hooper
Brian Hooper

Reputation: 22034

After a bit more coding with this new toy, it seems that unnecessary this keywords are coloured differently from necessary ones. The same applies to unnecessary using statements.

As Jon Skeet says, this is a keyword and coloured as the other keywords, but it seems the unnecessary ones aren't. Since I don't like the colour this provides some incentive for getting rid of them.

Upvotes: 2

Jon Skeet
Jon Skeet

Reputation: 1499790

It's just a keyword, the same as all the others. I don't think you can tell VS to highlight it differently to other keywords.

Upvotes: 2

Related Questions