Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Fix disposal of enumerators in EnumerablePartition#14979

Merged
stephentoub merged 2 commits intodotnet:masterfrom
jamesqo:fix.skip.take.dispose
Jan 12, 2017
Merged

Fix disposal of enumerators in EnumerablePartition#14979
stephentoub merged 2 commits intodotnet:masterfrom
jamesqo:fix.skip.take.dispose

Conversation

@jamesqo
Copy link
Copy Markdown
Contributor

@jamesqo jamesqo commented Jan 8, 2017

Description: I found out while adding a new API in #14186 that I had forgotten to override Dispose in EnumerablePartition, which is returned by Skip / Take. This fixes that and adds corresponding tests to make sure the source enumerator is disposed properly. I also made some of the test code I had written in an earlier PR a bit cleaner.

Related: #13628

/cc @JonHanna @stephentoub @VSadov

@jamesqo jamesqo changed the title Fix disposal of enumerators in EnumeratorPartition Fix disposal of enumerators in EnumerablePartition Jan 8, 2017
Copy link
Copy Markdown
Member

@stephentoub stephentoub Jan 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: if you were to change the implementation in the ctor to:

_getEnumerator = getEnumerator ?? () => this;

then I think you could change this to:

var source = new DelegateIterator<int>(
    moveNext: ...

etc., and not have to do this dance with defining the variable separately. You might even choose to remove ghet getEnumerator entirely and just always have it return this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@VSadov
Copy link
Copy Markdown
Member

VSadov commented Jan 9, 2017

LGTM. Thanks!

@jamesqo
Copy link
Copy Markdown
Contributor Author

jamesqo commented Jan 11, 2017

Test Innerloop OSX Debug Build and Test (build timed out)
Test Innerloop Windows_NT Debug Build and Test (reported SqlClient failures)
Test Innerloop Windows_NT Release Build and Test (reported SqlClient failures)

Copy link
Copy Markdown
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @jamesqo.

@stephentoub stephentoub merged commit 73daf67 into dotnet:master Jan 12, 2017
@jamesqo jamesqo deleted the fix.skip.take.dispose branch January 12, 2017 14:32
@karelz karelz modified the milestone: 2.0.0 Jan 21, 2017
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Fix disposal of enumerators in EnumeratorPartition

Commit migrated from dotnet/corefx@73daf67
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants