From 29e3a55f851bb1b193386192fd9b42428c0dd365 Mon Sep 17 00:00:00 2001 From: Laurent Ellerbach Date: Fri, 23 Oct 2026 10:56:37 +0200 Subject: [PATCH 1/3] Adding test to cover new UTF8 helper changes in native. --- Tests/NFUnitTestEncoding/EncodingTests.cs | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Tests/NFUnitTestEncoding/EncodingTests.cs b/Tests/NFUnitTestEncoding/EncodingTests.cs index 8e4d531..9034f3b 100644 --- a/Tests/NFUnitTestEncoding/EncodingTests.cs +++ b/Tests/NFUnitTestEncoding/EncodingTests.cs @@ -456,6 +456,40 @@ public void Utf8EncodingTests_TestIncrementalDecodingMultiByte() Assert.AreEqual('€', output[0]); } + [TestMethod] + public void Utf8Decoder_IncompleteSequence() + { + Decoder decoder = Encoding.UTF8.GetDecoder(); + byte[] bytes = { 0xE2, 0x82, 0xAC }; // U+20AC + char[] chars = new char[4]; + + // Only the first two bytes are available; preserve the incomplete prefix. + decoder.Convert(bytes, 0, 2, chars, 0, chars.Length, false, + out int bytesUsed, out int charsUsed, out bool completed); + + Assert.AreEqual(0, bytesUsed); + Assert.AreEqual(0, charsUsed); + Assert.IsFalse(completed); + + // Retry the unconsumed prefix with the complete character. + decoder.Convert(bytes, 0, 3, chars, 0, chars.Length, false, + out bytesUsed, out charsUsed, out completed); + + Assert.AreEqual(3, bytesUsed); + Assert.AreEqual(1, charsUsed); + Assert.AreEqual('\u20AC', chars[0]); + Assert.IsTrue(completed); + + // At EOF, consume a truncated sequence once and emit one replacement. + decoder.Convert(bytes, 0, 2, chars, 0, chars.Length, true, + out bytesUsed, out charsUsed, out completed); + + Assert.AreEqual(2, bytesUsed); + Assert.AreEqual(1, charsUsed); + Assert.AreEqual('\uFFFD', chars[0]); + Assert.IsTrue(completed); + } + [TestMethod] public void Utf8EncodingTests_TestOverlongEncodingRejection() { From 20867c414db78140d57e954f8e019d2701db8213 Mon Sep 17 00:00:00 2001 From: Laurent Ellerbach Date: Fri, 23 Oct 2026 11:05:20 +0200 Subject: [PATCH 2/3] updating deps --- .../nanoFramework.System.Text.Benchmark.nfproj | 2 +- nanoFramework.System.Text.Benchmark/packages.config | 2 +- nanoFramework.System.Text.Benchmark/packages.lock.json | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/nanoFramework.System.Text.Benchmark/nanoFramework.System.Text.Benchmark.nfproj b/nanoFramework.System.Text.Benchmark/nanoFramework.System.Text.Benchmark.nfproj index 9202961..2487395 100644 --- a/nanoFramework.System.Text.Benchmark/nanoFramework.System.Text.Benchmark.nfproj +++ b/nanoFramework.System.Text.Benchmark/nanoFramework.System.Text.Benchmark.nfproj @@ -30,7 +30,7 @@ ..\packages\nanoFramework.CoreLibrary.2.0.0-preview.63\lib\netnano1.0\mscorlib.dll - ..\packages\nanoFramework.Benchmark.2.0.0-preview.13\lib\netnano1.0\nanoFramework.Benchmark.dll + ..\packages\nanoFramework.Benchmark.2.0.0-preview.14\lib\netnano1.0\nanoFramework.Benchmark.dll ..\packages\nanoFramework.Logging.2.0.0-preview.43\lib\netnano1.0\nanoFramework.Logging.dll diff --git a/nanoFramework.System.Text.Benchmark/packages.config b/nanoFramework.System.Text.Benchmark/packages.config index d0929bd..b612c60 100644 --- a/nanoFramework.System.Text.Benchmark/packages.config +++ b/nanoFramework.System.Text.Benchmark/packages.config @@ -1,6 +1,6 @@  - + diff --git a/nanoFramework.System.Text.Benchmark/packages.lock.json b/nanoFramework.System.Text.Benchmark/packages.lock.json index 428df2f..7f5a62f 100644 --- a/nanoFramework.System.Text.Benchmark/packages.lock.json +++ b/nanoFramework.System.Text.Benchmark/packages.lock.json @@ -4,9 +4,9 @@ ".NETnanoFramework,Version=v1.0": { "nanoFramework.Benchmark": { "type": "Direct", - "requested": "[2.0.0-preview.13, 2.0.0-preview.13]", - "resolved": "2.0.0-preview.13", - "contentHash": "214iBqa2d9VXwnmAjN3JOfJcV+ZhEfLgx6K5zhjeDJ8J1E1fyGGzFrGM7qtTuAyFPVbqRMcgoQhDQ8YPzxjFBA==" + "requested": "[2.0.0-preview.14, 2.0.0-preview.14]", + "resolved": "2.0.0-preview.14", + "contentHash": "ZqRpbC0WrkpZ2m3NgWvEalH8lOfv3szqCDsgOsrZt3VR2RFnXMJ4BUb89dJX8JbxYo0qtKUXLLa9SVK1qwVVPA==" }, "nanoFramework.CoreLibrary": { "type": "Direct", From 7b16ff1c86b850fa920168044873a2526f05c647 Mon Sep 17 00:00:00 2001 From: Laurent Ellerbach Date: Fri, 23 Oct 2026 11:15:24 +0200 Subject: [PATCH 3/3] fixing packagelock --- nanoFramework.System.Text.Benchmark/packages.lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanoFramework.System.Text.Benchmark/packages.lock.json b/nanoFramework.System.Text.Benchmark/packages.lock.json index 7f5a62f..3ca2087 100644 --- a/nanoFramework.System.Text.Benchmark/packages.lock.json +++ b/nanoFramework.System.Text.Benchmark/packages.lock.json @@ -6,7 +6,7 @@ "type": "Direct", "requested": "[2.0.0-preview.14, 2.0.0-preview.14]", "resolved": "2.0.0-preview.14", - "contentHash": "ZqRpbC0WrkpZ2m3NgWvEalH8lOfv3szqCDsgOsrZt3VR2RFnXMJ4BUb89dJX8JbxYo0qtKUXLLa9SVK1qwVVPA==" + "contentHash": "OomiBoedkZYSB1DkDH6NSl52hM5db1cqTk9SIby1ocmCQQf/NsjNFD/P/wxnOQ5Uq3uWYysnU85ufr7U/zEFbQ==" }, "nanoFramework.CoreLibrary": { "type": "Direct",