From fbd105f312b785f21b2c41319617ca8fb9fd794d Mon Sep 17 00:00:00 2001 From: Ed Ball Date: Tue, 12 Mar 2024 14:54:53 -0700 Subject: [PATCH] Fix exception thrown under .NET Framework. --- src/Segmenter/Common/Extensions.cs | 4 ++-- test/Segmenter.Tests/Segmenter.Tests.csproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Segmenter/Common/Extensions.cs b/src/Segmenter/Common/Extensions.cs index a207074..4efb773 100644 --- a/src/Segmenter/Common/Extensions.cs +++ b/src/Segmenter/Common/Extensions.cs @@ -124,13 +124,13 @@ public static IEnumerable SubGroupValues(this GroupCollection groups) public static string ReadAllText(this Stream stream) { - using var sr = new StreamReader(stream, encoding: Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: -1, leaveOpen: true); + using var sr = new StreamReader(stream, encoding: Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: 4096, leaveOpen: true); return sr.ReadToEnd(); } public static string[] ReadAllLines(this Stream stream) { - using var sr = new StreamReader(stream, encoding: Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: -1, leaveOpen: true); + using var sr = new StreamReader(stream, encoding: Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: 4096, leaveOpen: true); var lines = new List(); while (true) diff --git a/test/Segmenter.Tests/Segmenter.Tests.csproj b/test/Segmenter.Tests/Segmenter.Tests.csproj index 66b7a6e..ca0ff43 100644 --- a/test/Segmenter.Tests/Segmenter.Tests.csproj +++ b/test/Segmenter.Tests/Segmenter.Tests.csproj @@ -1,7 +1,7 @@  - net7.0 + net7.0;net472 JiebaNet.Segmenter.Tests JiebaNet.Segmenter.Tests JiebaNet.Segmenter.Tests