Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a default IEnumerable.GetEnumerator implementation to IEnumerable<T> #102954

Closed
wants to merge 1 commit into from

Conversation

masonwheeler
Copy link
Contributor

Minor QOL improvement for .NET developers. I'm honestly surprised that this was not literally the very first thing anyone ever did with the Default Interface Implementation feature.

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jun 1, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-collections
See info in area-owners.md if you want to be subscribed.

@alexrp
Copy link
Contributor

alexrp commented Jun 1, 2024

I'm honestly surprised that this was not literally the very first thing anyone ever did with the Default Interface Implementation feature.

Maybe they considered it and opted for caution. 🤔

@huoyaoyuan
Copy link
Member

Thank you for your interest of contribution. However, this change has HUGE impact of the whole ecosystem due to being fundamental.

#31001 and #95830 are doing the similar thing for read-only collection interfaces. However, the change gets reverted since it breaks C++/CLI in some way. The exact change in this PR has been proposed for multiple times, but the team hasn't get a concrete plan for this. I believe they will get #31001 resolved first.

@teo-tsirpanis
Copy link
Contributor

This change would require opening an API proposal and having it be approved.

@jkotas
Copy link
Member

jkotas commented Jun 1, 2024

Similar idea discussed yesterday in #102795 (comment)

@hamarb123
Copy link
Contributor

Isn't it a breaking change to add a default implementation to an existing interface method? (due to diamond inheritance problem)

@huoyaoyuan
Copy link
Member

Isn't it a breaking change to add a default implementation to an existing interface method? (due to diamond inheritance problem)

If anyone inherits from non-generic IEnumerable, doesn't inherit IEnumerable<T>, and also provides DIM in the descant interface. It's also discussed at #31001

@stephentoub
Copy link
Member

Thanks. Closing per #102954 (comment).

@stephentoub stephentoub closed this Jun 2, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jul 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Collections community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants