@Ccursed commented on Sat Jun 30 2018
I propose to highlight the usage of underscore ( _ ), when used as discard character, to be treated like a keyword (this / default / await / etc.) by the syntax highlighting in Visual Studio.
Example:
SomeObject.SomeEvent += (value1, _) => { //Do Something with only value1 };
Where the underscore would be marked in blue (Dark Visual Studio Theme, colors accordingly for theme).
I think it would improve code readability and would make it more clear that the specified parameter is not neccesary for the required operation.
Edit: My example is bad.
Hopefully better:
var (value1, _, _) = CreateTupleWith3Values();
Where currently the discard underscores are not syntax hightlighted.
@jnm2 commented on Sat Jun 30 2018
Is this covered by https://github.com/dotnet/csharplang/issues/111?
@Ccursed commented on Sat Jun 30 2018
@jnm2 As far as I can tell, no.
It is not about existing or new ways of usage, but simply about syntax highlighting.
My current Visual Studio 17 (latest Updates) and running latest minor C# version does not highlight underscores used as discards.
@yaakov-h commented on Sat Jun 30 2018
That example doesn't use a discard, IIRC...
@Ccursed commented on Sat Jun 30 2018
@yaakov-h True. Updated first post.
@HaloFour commented on Sat Jun 30 2018
This request belongs on the Roslyn repo as it doesn't change the semantics of the C# language, only the tooling. I want to say that I've seen an issue there for this but I couldn't find it with a quick search.
@jnm2 commented on Sat Jun 30 2018
Scratch that, I could have sworn discards were highlighted as keywords, but apparently they aren't. Was there a change?
@jnm2 commented on Sat Jun 30 2018
@Ccursed See https://github.com/dotnet/roslyn/issues/16667 and https://github.com/dotnet/roslyn/pull/20561. This looks intentional.
@Ccursed commented on Sat Jun 30 2018
@jnm2 Yes I see. Thanks.
@Joe4evr commented on Wed Jul 04 2018
It's a shame, though. I loved seeing that discard highlighted differently.
@jnm2 commented on Wed Jul 04 2018
Me too! I thought it was cool. @jcouv, what are the possibilities if we were to move this issue to dotnet/roslyn?
Moved the issue from csharplang.
Design Meeting Notes:
We do think this should be classified as a keyword.
Referencing the CreateTupleWith3Values sample from above, does the classification do anything to improve the tool tip experience?
Currently, nothing happens when I move the mouse over the discard and I regularly think that I didn't hover right. Usually, there is some information about the variable like (local variable) int value1, so I'd like to propose something along the lines of (discard) int nameOfItem2.
@Tragetaschen QuickInfo does pop-up for discards. It shows the type and an underscore as show in screencap:

The classification fix was merged, so I'll go ahead and close this issue.
Please file a separate issue about QuickInfo if you'd like further refinement. Thanks
Most helpful comment
Design Meeting Notes:
We do think this should be classified as a keyword.