Relax "member names cannot be the same as their enclosing type" for nested generic classes #3108
Replies: 7 comments
-
I'm not entirely sure why this is an issue to begin with - isn't the "name" of Is there any reason not to allow that? If you are allowed to have |
Beta Was this translation helpful? Give feedback.
-
No, that's an internal implementation detail of the runtime. There is nothing aobut C# that considers it that. |
Beta Was this translation helpful? Give feedback.
-
I mean, kind of but not really. I consider an internal implementation detail something that doesn't leak out but |
Beta Was this translation helpful? Give feedback.
-
That is part of the CLR, it's not part of C#.
No, the C# language specification determines name collisions for C# :)
That's true today. But may not be in the future. We've def considered at time the idea of type-arg inference for types (just like it exists for methods). So it's not an open and shut case of this being trivial :) |
Beta Was this translation helpful? Give feedback.
-
*and that internal implementation detail is what determines name collisions at the CLR level so C# should be able to support that without a problem. I can maybe kinda see your point about possible type-arg inference for types but I feel like it was more or less realized that it isn't going to happen, so I'm talking about this from today's perspective. I also don't think that this would impede that at all - like I kind of alluded to, if you can have |
Beta Was this translation helpful? Give feedback.
-
When did that happen? |
Beta Was this translation helpful? Give feedback.
-
It didn't explicitly happen. Just the particular nature of the proposal and the lack of it going anywhere for years felt that way, but my feelings are ultimately irrelevant here given the position that I don't think this would affect that in any way since you're already going to have to deal with varying generic parameter count types in the same namespace if it ever comes to fruition and I believe the same logic can be applied to nested types that are in scope. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I tend to run into this type of pattern quite often:
Obviously I can find a different name for the inner class but sometimes that's annoying in terms of code readability and in the case of nested generic types there is only an ambiguity if the number of generic parameters is the same, so it would be nice to lift the matching name restriction for that particular case.
Beta Was this translation helpful? Give feedback.
All reactions