IEnumerable.GetEnumerator with default implementation #7569
Replies: 2 comments 18 replies
-
See: dotnet/runtime#29513 |
Beta Was this translation helpful? Give feedback.
-
Yeah, I know, I've been using C# for almost that long.
I think it needs some support from the language, even if in the form of analyzers, but sure, the runtime needs to be worked on, not sure I have a concrete model for the more general idea of removing obsoleted parts of the BCL from "fresh" codebases. Let me think and write about it and I will link it up here.
Most people would agree that the non-generic collections are legacy cruft, and for those that depend on it still, they are surely not targeting .net 8. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The generic IEnumerable interface inherits from the (legacy) non-generic IEnumerable. They both have GetEnumerator methods which differ on the return type by the generic vs non generic versions of IEnumerator. Anytime someone needs to implement IEnumerable (and I imagine essentially no-one works with the non-generic collections at this time) it is also necessary to implement the non-generic version for backwards compatibility polluting the code with outdated concepts.
The question here is: couldn't the BCL be updated so that the non-generic version has a default implementation which just calls the generic version?
Beta Was this translation helpful? Give feedback.
All reactions