-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
API Proposal: File.ReadLinesAsync #2214
Comments
Is the |
I think so, yes. I'm assuming the Lines 19 to 28 in 4f9ae42
This was the only similar API I could find in code base: runtime/src/libraries/System.Threading.Channels/ref/System.Threading.Channels.netcoreapp.cs Line 16 in 4f9ae42
|
Any hint on when this will be up for review? 👼 |
We usually get to APIs in chronological order (by date opened) unless they're marked as blocking. |
namespace System.IO
{
public static partial class File
{
public static IAsyncEnumerable<string> ReadLinesAsync(string path, CancellationToken cancellationToken = default);
public static IAsyncEnumerable<string> ReadLinesAsync(string path, System.Text.Encoding encoding, CancellationToken cancellationToken = default);
}
} |
@khellang will you get a chance to work on this in the next week or two? Otherwise, I should move it to Future. |
@carlossanlop I've already done most of the work, but I won't be able to polish it up and submit a PR in the coming weeks as I'm on vacation 😢 |
No worries. Let's move it to Future then. |
Would really love to see this included in 7.0.0 |
@eiriktsarpalis There was a PR open for this that didn't get merged, I think this API is blocked on #20824 if I understood the PR's comments correctly. |
Thanks for the heads up, @huoyaoyuan! I'm pretty swamped with Other Stuff right now, so I can't commit to anything. I can try to breathe life back into #43108 when I have time, but if someone beats me to it, I won't mind 😅 |
Wouldn't it be worth making ReadAllLinesAsync then call into this new API then to optimize them a bit as well? |
Hi, I would try to learn and fix it, not sure if can assign to me, here is my draft PR which will be marked as ready, thanks. |
Hi, this PR is marked as ready for review now, thanks. |
Now that
IAsyncEnumerable<T>
has landed, I'd like to propose the following new methods to theFile
type:The methods would basically be async counterparts to
File.ReadLines
, so they would mirror whatFile.ReadAllLinesAsync
does, i.e. use an asynchronous, sequentialStreamReader
, but read line by line lazily, without allocating a list or array.These would fill the remaining gap for async reading done by the
File
type, as mentioned in https://github.com/dotnet/corefx/issues/11220.The text was updated successfully, but these errors were encountered: