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

fix: dispose enumerator in CsvWriter.WriteRecordsAsync #2297

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vchirikov
Copy link

@vchirikov vchirikov commented Nov 2, 2024

We should check enumerator with IAsyncDisposable too.

p.s. A bit better version of #2265

Closes: #2264

@CaringDev
Copy link

Why do you think this is better than #2265 ? IMO:

  1. if we get a synchronous enumerator, we should Dispose synchronously. Or do you know of any counterexample?
  2. if we get an asynchronous enumerator, no check is needed, just use DisposeAsync

@vchirikov
Copy link
Author

@CaringDev at least because:

		// These methods should all be the same;
		// - WriteRecordsAsync(IEnumerable records)
		// - WriteRecordsAsync<T>(IEnumerable<T> records)
		// - WriteRecordsAsync<T>(IAsyncEnumerable<T> records)

but #2265 changes only one overload. And also you don't know about implementation of enumerator, so it might implement IAsyncDisposable or IDisposable. Library code should support both, imho.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CsvWriter.WriteRecordsAsync does not dispose e.g. EF Core AsyncEnumerators
3 participants