Delete ILLinkTrim.xml (and associated dead code) from System.Text.Encodings.Web ...
authorStephen Toub <stoub@microsoft.com>
Mon, 28 Oct 2019 03:47:48 +0000 (23:47 -0400)
committerJan Kotas <jkotas@microsoft.com>
Mon, 28 Oct 2019 03:47:48 +0000 (20:47 -0700)
This is all stale/dead code from before the relevant functionality was made public.

Commit migrated from https://github.com/dotnet/corefx/commit/17c14aa2b50cfb5920d03ea8835c9a4932b5359c

src/libraries/System.Text.Encodings.Web/src/Common/TextEncoderExtensions.cs [deleted file]
src/libraries/System.Text.Encodings.Web/src/ILLinkTrim.xml [deleted file]
src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/TextEncoder.cs
src/libraries/System.Text.Encodings.Web/tests/System.Text.Encodings.Web.Tests.csproj

diff --git a/src/libraries/System.Text.Encodings.Web/src/Common/TextEncoderExtensions.cs b/src/libraries/System.Text.Encodings.Web/src/Common/TextEncoderExtensions.cs
deleted file mode 100644 (file)
index 6f7f7fe..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Buffers;
-using System.Diagnostics;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-
-namespace System.Text.Encodings.Web
-{
-    /// <summary>
-    /// Provides access to <see cref="TextEncoder"/> APIs that aren't part of the ref asms.
-    /// </summary>
-    internal static class TextEncoderExtensions
-    {
-        private delegate OperationStatus EncodeUtf8Del(TextEncoder encoder, ReadOnlySpan<byte> utf8Source, Span<byte> utf8Destination, out int bytesConsumed, out int bytesWritten, bool isFinalBlock);
-        private delegate int FindFirstCharacterToEncodeUtf8Del(TextEncoder encoder, ReadOnlySpan<byte> utf8Text);
-
-        private static readonly EncodeUtf8Del s_encodeUtf8Fn = CreateEncodeUtf8Fn();
-        private static readonly FindFirstCharacterToEncodeUtf8Del s_findFirstCharToEncodeUtf8Fn = CreateFindFirstCharToEncodeUtf8Fn();
-
-        private static EncodeUtf8Del CreateEncodeUtf8Fn()
-        {
-            // Locate the shim method, which is able to perform fast virtual dispatch,
-            // then create a delegate to it.
-
-            MethodInfo methodInfo = typeof(TextEncoder).GetMethod("EncodeUtf8Shim", BindingFlags.NonPublic | BindingFlags.Static);
-            Debug.Assert(methodInfo != null);
-            EncodeUtf8Del del = (EncodeUtf8Del)methodInfo.CreateDelegate(typeof(EncodeUtf8Del));
-
-            // Now invoke the delegate once. The reason for this is that the delegate probably
-            // points to the pre-jit stub rather than the final codegen for the method, which
-            // means that invocations of this delegate will incur an unnecessary call back into
-            // the VM. Invoking the delegate forces JIT to take place now, so a future delegate
-            // will point directly to the codegen rather than the pre-jit stub.
-
-            del(HtmlEncoder.Default, ReadOnlySpan<byte>.Empty, Span<byte>.Empty, out _, out _, false);
-
-            // Now create the delegate again and return it to the caller.
-            // The delegate should now be pointing directly to the static method's codegen.
-
-            return (EncodeUtf8Del)methodInfo.CreateDelegate(typeof(EncodeUtf8Del));
-        }
-
-        private static FindFirstCharacterToEncodeUtf8Del CreateFindFirstCharToEncodeUtf8Fn()
-        {
-            // See the comments in CreateEncodeUtf8Fn for an overview of how this logic works.
-
-            MethodInfo methodInfo = typeof(TextEncoder).GetMethod("FindFirstCharacterToEncodeUtf8Shim", BindingFlags.NonPublic | BindingFlags.Static);
-            Debug.Assert(methodInfo != null);
-
-            FindFirstCharacterToEncodeUtf8Del del = (FindFirstCharacterToEncodeUtf8Del)methodInfo.CreateDelegate(typeof(FindFirstCharacterToEncodeUtf8Del));
-            del(HtmlEncoder.Default, ReadOnlySpan<byte>.Empty);
-
-            return (FindFirstCharacterToEncodeUtf8Del)methodInfo.CreateDelegate(typeof(FindFirstCharacterToEncodeUtf8Del));
-        }
-
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        internal static OperationStatus EncodeUtf8(this TextEncoder encoder, ReadOnlySpan<byte> utf8Source, Span<byte> utf8Destination, out int bytesConsumed, out int bytesWritten, bool isFinalBlock = true)
-        {
-            return s_encodeUtf8Fn(encoder, utf8Source, utf8Destination, out bytesConsumed, out bytesWritten, isFinalBlock);
-        }
-
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        internal static int FindFirstCharacterToEncodeUtf8(this TextEncoder encoder, ReadOnlySpan<byte> utf8Text)
-        {
-            return s_findFirstCharToEncodeUtf8Fn(encoder, utf8Text);
-        }
-    }
-}
diff --git a/src/libraries/System.Text.Encodings.Web/src/ILLinkTrim.xml b/src/libraries/System.Text.Encodings.Web/src/ILLinkTrim.xml
deleted file mode 100644 (file)
index 5afdc6d..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<linker>
-  <assembly fullname="System.Text.Encodings.Web">
-    <type fullname="System.Text.Encodings.Web.TextEncoder">
-      <!-- Not exposed via ref asm, but needed by JSON project and tests -->
-      <method name="EncodeUtf8Shim" />
-      <method name="FindFirstCharacterToEncodeUtf8Shim" />
-    </type>
-  </assembly>
-</linker>
index 4debeee..b1350c1 100644 (file)
@@ -561,14 +561,6 @@ namespace System.Text.Encodings.Web
         }
 
         /// <summary>
-        /// Shim function which can call virtual method <see cref="EncodeUtf8"/> using fast dispatch.
-        /// </summary>
-        internal static OperationStatus EncodeUtf8Shim(TextEncoder encoder, ReadOnlySpan<byte> utf8Source, Span<byte> utf8Destination, out int bytesConsumed, out int bytesWritten, bool isFinalBlock)
-        {
-            return encoder.EncodeUtf8(utf8Source, utf8Destination, out bytesConsumed, out bytesWritten, isFinalBlock);
-        }
-
-        /// <summary>
         /// Encodes the supplied characters.
         /// </summary>
         /// <param name="source">A source buffer containing the characters to encode.</param>
@@ -828,14 +820,6 @@ namespace System.Text.Encodings.Web
             }
         }
 
-        /// <summary>
-        /// Shim function which can call virtual method <see cref="FindFirstCharacterToEncodeUtf8"/> using fast dispatch.
-        /// </summary>
-        internal static int FindFirstCharacterToEncodeUtf8Shim(TextEncoder encoder, ReadOnlySpan<byte> utf8Text)
-        {
-            return encoder.FindFirstCharacterToEncodeUtf8(utf8Text);
-        }
-
         internal static unsafe bool TryCopyCharacters(char[] source, char* destination, int destinationLength, out int numberOfCharactersWritten)
         {
             Debug.Assert(source != null && destination != null && destinationLength >= 0);
index f580805..4c29d06 100644 (file)
@@ -13,7 +13,6 @@
     </CodeAnalysisDependentAssemblyPaths>
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="..\src\Common\TextEncoderExtensions.cs" />
     <Compile Include="..\src\System\Text\Encodings\Web\HexUtil.cs" />
     <Compile Include="..\src\System\Text\Internal\AllowedCharactersBitmap.cs" />
     <Compile Include="..\src\System\Text\Unicode\UnicodeHelpers.cs" />