Proposal: Allow TupleElementNames on custom types #9358
Unanswered
dotlogix
asked this question in
Language Ideas
Replies: 1 comment 1 reply
-
Is your idea that these names would pattern match with properties/fields called |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I just discovered how named value tuples actually work behind the scenes. One idea came to my mind, would it be possible to add support for
[TupleElementNames]
for custom types?For one of my projects I want to create a custom tuple like types so that I can add abstract static methods to expose additional functionality on a tuple. Unfortunately extension methods don't work for value tuples because the TRest parameter can't be type constraint to allow extension methods on this parameter itself (to allow any tuple to use the extension method).
However with static abstract interfaces this can now easily be done.
Therefore I want to create a custom struct similar to a ValueTuple with Properties Item1...Item8 + TRest but I would at least like to support to define TupleElementNames to rename them for development so that I could use a method like:
This would then allow to use
myTuple.id
andmyTuple.name
. So basically the question is if this functionality could be exposed somehow so people could create their own RefTuple or other generic base types with tuple name functionality.Beta Was this translation helpful? Give feedback.
All reactions