[Discussion] allow cascading type alias #3873
Replies: 6 comments 11 replies
-
I recall this being mentioned during triage for 1239. |
Beta Was this translation helpful? Give feedback.
-
A bit tangential, but combining this with the ability to alias named tuples would be extremely useful. My preference would be an outcome like this: using CustomerId = System.Int32;
using CustomerRegistry = (CustomerId Id, string Name); |
Beta Was this translation helpful? Give feedback.
-
Would some type of first class type sub-types be a better solution? Once this was in, people would alias all their types, then they'd put an AddressId into a function call requesting a CustomerId and ask 'why did that work without a warning'. |
Beta Was this translation helpful? Give feedback.
-
@marksmeltzer yep, as a contrived example. |
Beta Was this translation helpful? Give feedback.
-
ITNOA @leandromoh I think the answer of this discussion in #4284 , when I can using aliases for anything, so I can using aliases for another using aliases. |
Beta Was this translation helpful? Give feedback.
-
Even after the feature Champion: using aliases for any types be implemented. using System;
using CustomerId = System.Int32;
using CustomerRegistry = (CustomerId, string);
Console.WriteLine("Hello World"); |
Beta Was this translation helpful? Give feedback.
-
Currently, we can not use an alias inside another.
This does not compiles:
This should be very usefull because allow more concrete and composable reuse of alias.
For now, we must define as follow (knowing implicitly that int referes to
CustomerId
)but if
CustomerId
type changes (let say fromint
toGuid
, for example), we should update manually each alias that makes implicit reference to it. This also may be confusing if a third alias is also an int.This would be also very usefull with #3428
Perhaps we could implement it at same time as #1239
Beta Was this translation helpful? Give feedback.
All reactions