From d6f254994afcda10845dcd63a8004c47d026adf7 Mon Sep 17 00:00:00 2001 From: Levi Broderick Date: Tue, 15 Oct 2019 13:13:45 -0700 Subject: [PATCH 1/2] Fix DecoderNLS.Convert to out the correct value for 'completed' This is a complementary fix to https://github.com/dotnet/coreclr/issues/23020 --- .../shared/System/Text/DecoderNLS.cs | 10 ++++++---- .../shared/System/Text/EncoderNLS.cs | 2 -- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/System.Private.CoreLib/shared/System/Text/DecoderNLS.cs b/src/System.Private.CoreLib/shared/System/Text/DecoderNLS.cs index 00b72c47e916..49aa166b76e4 100644 --- a/src/System.Private.CoreLib/shared/System/Text/DecoderNLS.cs +++ b/src/System.Private.CoreLib/shared/System/Text/DecoderNLS.cs @@ -207,11 +207,13 @@ public override unsafe void Convert(byte* bytes, int byteCount, charsUsed = _encoding.GetChars(bytes, byteCount, chars, charCount, this); bytesUsed = _bytesUsed; - // Its completed if they've used what they wanted AND if they didn't want flush or if we are flushed - completed = (bytesUsed == byteCount) && (!flush || !this.HasState) && - (_fallbackBuffer == null || _fallbackBuffer.Remaining == 0); + // Per MSDN, "The completed output parameter indicates whether all the data in the input + // buffer was converted and stored in the output buffer." That means we've successfully + // consumed all the input _and_ there's no pending state or fallback data remaining to be output. - // Our data thingy are now full, we can return + completed = (bytesUsed == byteCount) + && !this.HasState + && (_fallbackBuffer is null || _fallbackBuffer.Remaining == 0); } public bool MustFlush => _mustFlush; diff --git a/src/System.Private.CoreLib/shared/System/Text/EncoderNLS.cs b/src/System.Private.CoreLib/shared/System/Text/EncoderNLS.cs index ff664f2209d5..5c813dc213c0 100644 --- a/src/System.Private.CoreLib/shared/System/Text/EncoderNLS.cs +++ b/src/System.Private.CoreLib/shared/System/Text/EncoderNLS.cs @@ -201,8 +201,6 @@ public override unsafe void Convert(char* chars, int charCount, completed = (charsUsed == charCount) && !this.HasState && (_fallbackBuffer is null || _fallbackBuffer.Remaining == 0); - - // Our data thingys are now full, we can return } public Encoding Encoding From 773cb1c569db2b4c7b076ba29c728179bb0ef779 Mon Sep 17 00:00:00 2001 From: Levi Broderick Date: Tue, 15 Oct 2019 14:31:40 -0700 Subject: [PATCH 2/2] Suppress failing tests --- tests/CoreFX/CoreFX.issues.rsp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/CoreFX/CoreFX.issues.rsp b/tests/CoreFX/CoreFX.issues.rsp index 52f585005b32..5bd0c62836e1 100644 --- a/tests/CoreFX/CoreFX.issues.rsp +++ b/tests/CoreFX/CoreFX.issues.rsp @@ -71,6 +71,10 @@ # https://github.com/dotnet/coreclr/issues/22414 -nomethod System.Numerics.Tests.ToStringTest.RunRegionSpecificStandardFormatToStringTests +# Failure in System.Text.Encoding.Tests due to bug fix in DecoderNLS.Convert +# https://github.com/dotnet/coreclr/issues/27191 +-nomethod System.Text.Tests.DecoderConvert2.PosTest6 + # Timeout in System.Text.RegularExpressions.Tests.RegexMatchTests.Match_ExcessPrefix # https://github.com/dotnet/coreclr/issues/18912 -nomethod System.Text.RegularExpressions.Tests.RegexMatchTests.Match_ExcessPrefix