Skip to content

Commit

Permalink
Update IoHelpers.cs (#1129)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Jan 10, 2024
1 parent deb691a commit 421f936
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/Verify/IoHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,10 @@ public static async Task<StringBuilder> ReadStringBuilderWithFixedLines(this Str
{
stream.MoveToStart();
using var reader = new StreamReader(stream);
StringBuilder builder = new(GetLength(stream));

while (await reader.ReadLineAsync(Cancel.None) is { } line)
{
builder.AppendLineN(line);
}
var builder = new StringBuilder(await reader.ReadToEndAsync());
builder.FixNewlines();

return builder;

static int GetLength(Stream stream) =>
stream switch
{
FileStream fileStream => (int) fileStream.Length,
MemoryStream memoryStream => (int) memoryStream.Length,
_ => 16
};
}

#if NET472 || NET48
Expand Down

0 comments on commit 421f936

Please sign in to comment.