C# Proposal: ability to refer to closed generic type #2857
Unanswered
molinch
asked this question in
Language Ideas
Replies: 3 comments
-
There are proposals for a |
Beta Was this translation helpful? Give feedback.
0 replies
-
Could also be a good use case for scoped aliases that can refer to the generic type arguements, e.g.: public struct Identifier<TPart1, TPart2, TPart3, TPart4, T1, T2, T3, T4>
where TPart1 : struct, IPart<T1>
where TPart2 : struct, IPart<T2>
where TPart3 : struct, IPart<T3>
where TPart4 : struct, IPart<T4>
{
using Self = Identifier<TPart1, TPart2, TPart3, TPart4, T1, T2, T3, T4>;
// ... some code here
private static readonly Func<Self, Self>[] Modifiers = GetModifiers().ToArray();
private static IEnumerable<Func<Self,Self>> GetModifiers()
{
return Modifier.GetModifiers<Self>(
// ... some code here
);
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
@HaloFour That would be even better, I really miss this ability |
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.
-
Imagine if you have the following generic struct definition:
If we could refer to the current closed type definition, code would be much more readable, for example by using Self:
If you believe it could be useful I would be happy to make a roslyn PR. I would need some guidance though.
Beta Was this translation helpful? Give feedback.
All reactions