-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Hello Roslyn friends, I was asked to write an issue here since it was identified as something best addressed through Roslyn. However I originally phrased it as a VS issue, so my language reflects that somewhat, since I am not entirely certain how Roslyn is involved. So, please bear with me. 😄
Visual Studio intellisense, hoverovers, and such things like this currently do not handle value-tuples in what I would consider a good way. However, other vaguely similar situations on more established idioms already have good practice, just maybe the UI hasn't quite caught up to value-tuples yet since they are so new.
The problem becomes obvious in cases where there is a library with generic type parameters, and value-tuples are ever used in those generic type parameters. LINQ would be the most obvious example, but I'll use immutable collections here. (No particular reason, I just happened to be playing with them in a scratch project, so that's what I wound up using here.)
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
var foo = ImmutableArray.Create(1, 2, 3, 4);
var a = new { well = 5, gee = 3, that = 5, sounds = 2, terrific = 0 };
var bar = ImmutableArray.Create(a, a, a, a);
var t = (well: 5, gee: 3, that: 5, sounds: 2, terrific: 0);
var biz = ImmutableArray.Create(t, t, t, t);
}
}
}I'll give a series of examples, marked with ✔️ and ❌ examples to show what I feel are good and bad. I also list the good examples since I feel like they inform some ways in which we could address the bad examples.
-
✔️ Cursor over the first lines
Create: -
✔️ Cursor over third line's
var. This one is slightly odd, but at least it is comprehensible by a human. -
✔️ Cursor over third line's
Create: -
✔️ Cursor over fifth line's
var: -
❌ Cursor over fifth line's
Create:This sort of seems like a missed opportunity. I would argue this is not easily comprehensible by a human, but it is easy to see how we might make it so. From example 3, I know these method can have sort of auxiliary explanatory information on the types of methods, and from example 4 I know that at least the type description is capable of calling them out.
Hypothetically, in this case (generic parameter that is a value-tuple) maybe something that looks more like the following, in the case where the generic type parameter relevant to a method is a value-tuple, it could look like this. Please forgive my limited formatting skills:
-
✔️ Speaking not just of hover-overs but Intellisense, I think it's more or less the same but just to emphasize, if I cursor over the third line just prior to the
;, then type., we get this methodAddas the first one. This looks pretty good. -
❌ If I do the same on the fifth line, this is what
Add's intellisense display looks like:

Similarly to point 5, I feel like the enumeration of the type every single time it appears decreases the helpfulness of the display. We could imagine solving it in a similar fashion.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status







