Allow using alias directives to reference other using aliases #2896
Unanswered
TheUnlocked
asked this question in
Language Ideas
Replies: 2 comments
-
This can helps to simplify using alias of long generics. using SomeClass = Some.VeryLong.Namespace.GenericType
<Some.VeryLong.Namesmace.SomeVeryLongClass,
Some.VeryLong.Namesmace.SomeVeryLongInterface> |
Beta Was this translation helpful? Give feedback.
0 replies
-
You can reference other aliases, if you declare the second inside a namespace: using Chunk = Chunk<bool, byte>;
namespace MyNamespace
{
using ChunkMap = Dictionary<Point, Chunk>; |
Beta Was this translation helpful? Give feedback.
0 replies
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Aliases should be able to reference other aliases. For example, this is not legal:
But this is:
Ideally if you want to change something about the definition of
Chunk
(e.g. changingbyte
toshort
), you should be able to do it in one place rather than needing to do it for all of the aliases which use the same definition.To show that this isn't some weird thing with generics and using the same name as the generic type, this also doesn't work:
Changing
using B = F.Bar;
tousing B = Foo.Bar;
compiles fine.Edit:
This could be a breaking change in some cases, but I still think this has benefits which should be considered, even if not exactly using the proposed syntax. Or perhaps types/namespaces with the same name as an alias should just get precedence over the alias to avoid any breaking changes. There are multiple ways to get around this issue.
Beta Was this translation helpful? Give feedback.
All reactions