Fix DecoderNLS.Convert to out the correct value for 'completed' (dotnet/coreclr#27210)
authorLevi Broderick <GrabYourPitchforks@users.noreply.github.com>
Wed, 16 Oct 2019 03:02:27 +0000 (20:02 -0700)
committerGitHub <noreply@github.com>
Wed, 16 Oct 2019 03:02:27 +0000 (20:02 -0700)
This is a complementary fix to https://github.com/dotnet/coreclr/issues/23020

Commit migrated from https://github.com/dotnet/coreclr/commit/c07ec4cd2f88c23edc87500893576d83c20f2e6d

src/coreclr/tests/CoreFX/CoreFX.issues.rsp
src/libraries/System.Private.CoreLib/src/System/Text/DecoderNLS.cs
src/libraries/System.Private.CoreLib/src/System/Text/EncoderNLS.cs

index 52f5850..5bd0c62 100644 (file)
 # 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
index 00b72c4..49aa166 100644 (file)
@@ -207,11 +207,13 @@ namespace System.Text
             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;
index ff664f2..5c813dc 100644 (file)
@@ -201,8 +201,6 @@ namespace System.Text
             completed = (charsUsed == charCount)
                 && !this.HasState
                 && (_fallbackBuffer is null || _fallbackBuffer.Remaining == 0);
-
-            // Our data thingys are now full, we can return
         }
 
         public Encoding Encoding