Home

ValueTuple name display?

edited August 2017
Hey Joe,
At the risk of making your head too big. Linqpad is awesome, and I have been a big fan for years.

With that out of the way, I am wondering if you see a way to implement dumping of the user-assigned ValueTuple names when assigned? And if you think you might add support?

I have only looked into this for five minutes, but it looks like some compilers emit attributes that would allow you to enhance .Dump() to display this information. Of course, I am not certain and don't know the difficulty to do so.


Well, I would be interested to know if you think it is possible and you are considering using the user-assigned names as some point?


http://mustoverride.com/tuples_names/ [ search for TupleElementNames in page ]
https://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.tupleelementnamesattribute(v=vs.110).aspx


Regards,
Cameron





Comments

  • edited August 2017
    The TupleElementNames attribute isn't helpful because it's not attached to variables (only method/property signatures).

    Unfortunately, there's no other way to do this, other than perhaps doing some analysis on the source code - and even this would only work in simple cases.
  • How does the Visual Studio debugger do it? As Linqpad uses Roslyn just like VS does, doesn't Roslyn expose that information?

  • @DaiPlusPlus said:
    How does the Visual Studio debugger do it? As Linqpad uses Roslyn just like VS does, doesn't Roslyn expose that information?

    My guess is that you're referring to a local variable, visible in 'Locals'. A local variable can [easily] be traced back to its declaration and any naming decorations.
    That's very different to a parameter value that's come in from another function [where the naming decoration is not in the local function space]. In this case, there's no [obvious] pathway, other than reflection, to learn about the incoming item, declared as object...

  • @YedidyaH It wouldn't be typed as Object, it would be typed as ValueTuple<...> with appropriate type-parameter arguments. The names of the members would be in a [TupleElementNames(...)] attribute on the method.

    As for local valuetuples, I suppose you're right about VS needing to get that information from the lexical source-code analysis which they get from Roslyn - which may explain why it took until now for ValueTuples to be part of C#.

Sign In or Register to comment.