Skip to content

Conversation

@vchirikov
Copy link
Contributor

@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
Contributor

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
Contributor 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.

@JoshClose JoshClose merged commit 2a7076c into JoshClose:master Jun 1, 2025
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

4 participants