Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 525f521

Browse files
Fix DecoderNLS.Convert to out the correct value for 'completed' (#27229)
Port #27210 to release/3.1
1 parent b9c7399 commit 525f521

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/System.Private.CoreLib/shared/System/Text/DecoderNLS.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,13 @@ public unsafe override void Convert(byte* bytes, int byteCount,
207207
charsUsed = _encoding.GetChars(bytes, byteCount, chars, charCount, this);
208208
bytesUsed = _bytesUsed;
209209

210-
// Its completed if they've used what they wanted AND if they didn't want flush or if we are flushed
211-
completed = (bytesUsed == byteCount) && (!flush || !this.HasState) &&
212-
(_fallbackBuffer == null || _fallbackBuffer.Remaining == 0);
210+
// Per MSDN, "The completed output parameter indicates whether all the data in the input
211+
// buffer was converted and stored in the output buffer." That means we've successfully
212+
// consumed all the input _and_ there's no pending state or fallback data remaining to be output.
213+
214+
completed = (bytesUsed == byteCount)
215+
&& !this.HasState
216+
&& (_fallbackBuffer is null || _fallbackBuffer.Remaining == 0);
213217

214218
// Our data thingy are now full, we can return
215219
}

tests/CoreFX/CoreFX.issues.rsp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@
7070
# https://github.com/dotnet/coreclr/issues/22414
7171
-nomethod System.Numerics.Tests.ToStringTest.RunRegionSpecificStandardFormatToStringTests
7272

73+
# Failure in System.Text.Encoding.Tests due to bug fix in DecoderNLS.Convert
74+
# https://github.com/dotnet/coreclr/issues/27191
75+
-nomethod System.Text.Tests.DecoderConvert2.PosTest6
76+
7377
# Timeout in System.Text.RegularExpressions.Tests.RegexMatchTests.Match_ExcessPrefix
7478
# https://github.com/dotnet/coreclr/issues/18912
7579
-nomethod System.Text.RegularExpressions.Tests.RegexMatchTests.Match_ExcessPrefix

0 commit comments

Comments
 (0)