From f5491ceb6b4d62969684022a3c31af4540dff563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lozier?= Date: Tue, 12 May 2026 21:00:55 -0400 Subject: [PATCH] Polyfill Encoding.GetString --- src/core/IronPython.Modules/IronPython.Modules.csproj | 1 + src/core/IronPython/IronPython.csproj | 1 + src/core/IronPython/Runtime/PythonEncoding.cs | 9 --------- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/core/IronPython.Modules/IronPython.Modules.csproj b/src/core/IronPython.Modules/IronPython.Modules.csproj index 86e575a48..f6185c153 100644 --- a/src/core/IronPython.Modules/IronPython.Modules.csproj +++ b/src/core/IronPython.Modules/IronPython.Modules.csproj @@ -15,6 +15,7 @@ T:System.Runtime.Versioning.SupportedOSPlatformAttribute; M:System.String.Contains(System.Char); M:System.String.EndsWith(System.Char); + M:System.Text.Encoding.GetString(System.ReadOnlySpan{System.Byte}); diff --git a/src/core/IronPython/IronPython.csproj b/src/core/IronPython/IronPython.csproj index 9360331b0..902f0c66d 100644 --- a/src/core/IronPython/IronPython.csproj +++ b/src/core/IronPython/IronPython.csproj @@ -19,6 +19,7 @@ M:System.String.Contains(System.Char); M:System.String.EndsWith(System.Char); M:System.String.StartsWith(System.Char); + M:System.Text.Encoding.GetString(System.ReadOnlySpan{System.Byte}); diff --git a/src/core/IronPython/Runtime/PythonEncoding.cs b/src/core/IronPython/Runtime/PythonEncoding.cs index da40a4bb9..042349f3b 100644 --- a/src/core/IronPython/Runtime/PythonEncoding.cs +++ b/src/core/IronPython/Runtime/PythonEncoding.cs @@ -1532,15 +1532,6 @@ public override unsafe int GetChars(byte* bytes, int byteCount, char* chars, int #if !NETCOREAPP // TODO: Move to IronPython.Runtime.Text - internal static class EncodingExtensions { - public static unsafe string GetString(this Encoding encoding, ReadOnlySpan bytes) { - fixed (byte* bytesPtr = &MemoryMarshal.GetReference(bytes)) { - return encoding.GetString(bytesPtr, bytes.Length); - } - - } - } - internal static class EncoderExtensions { public static unsafe int GetByteCount(this Encoder encoder, ReadOnlySpan chars, bool flush) { fixed (char* pChars = &MemoryMarshal.GetReference(chars)) {