Remove ILLinkTrim.xml from System.Linq.Expressions (dotnet/corefx#42158)
authorStephen Toub <stoub@microsoft.com>
Mon, 28 Oct 2019 12:52:34 +0000 (08:52 -0400)
committerGitHub <noreply@github.com>
Mon, 28 Oct 2019 12:52:34 +0000 (08:52 -0400)
* Remove ILLinkTrim.xml from System.Linq.Expressions

* Address PR feedback

Commit migrated from https://github.com/dotnet/corefx/commit/80ec55f39f587fa2ebb92982c32723ba80b8e247

src/libraries/System.Linq.Expressions/src/ILLinkTrim.xml [deleted file]
src/libraries/System.Linq.Expressions/src/System.Linq.Expressions.csproj
src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/CallInstruction.Generated.cs
src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightLambda.cs
src/libraries/System.Linq.Expressions/src/System/Runtime/CompilerServices/CallSite.cs

diff --git a/src/libraries/System.Linq.Expressions/src/ILLinkTrim.xml b/src/libraries/System.Linq.Expressions/src/ILLinkTrim.xml
deleted file mode 100644 (file)
index bf4e3f9..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<linker>
-  <assembly fullname="System.Linq.Expressions">
-    <type fullname="System.Linq.Expressions.Interpreter.LightLambda">
-      <!-- required by debugger -->
-      <method name="get_DebugView" />
-    </type>
-    <!-- accessed via reflection -->
-    <type fullname="System.Dynamic.UpdateDelegates" />
-    <type fullname="System.Linq.Expressions.Interpreter.ActionCallInstruction*">
-      <!-- instantiated via reflection -->
-      <method name=".ctor" />
-    </type>
-    <type fullname="System.Linq.Expressions.Interpreter.FuncCallInstruction*">
-      <!-- instantiated via reflection -->
-      <method name=".ctor" />
-    </type>
-  </assembly>
-</linker>
\ No newline at end of file
index d0e5dd1..efc4d85 100644 (file)
@@ -16,6 +16,9 @@
     <Compile Include="$(CommonPath)\System\Collections\Generic\ArrayBuilder.cs">
       <Link>Common\System\Collections\Generic\ArrayBuilder.cs</Link>
     </Compile>
+    <Compile Include="$(CommonPath)\System\Runtime\CompilerServices\PreserveDependencyAttribute.cs">
+      <Link>Common\System\Runtime\CompilerServices\PreserveDependencyAttribute.cs</Link>
+    </Compile>
     <Compile Include="System\Dynamic\Utils\CacheDict.cs" />
     <Compile Include="System\Dynamic\Utils\ContractUtils.cs" />
     <Compile Include="System\Dynamic\Utils\ExpressionUtils.cs" />
index 3384b27..fd016ce 100644 (file)
@@ -7,6 +7,7 @@ using System.Diagnostics;
 using System.Dynamic;
 using System.Dynamic.Utils;
 using System.Reflection;
+using System.Runtime.CompilerServices;
 using System.Threading;
 
 namespace System.Linq.Expressions.Interpreter
@@ -159,6 +160,16 @@ namespace System.Linq.Expressions.Interpreter
 #endif
 
 #if FEATURE_DLG_INVOKE
+        [PreserveDependency(".ctor", "System.Linq.Expressions.Interpreter.ActionCallInstruction")]
+        [PreserveDependency(".ctor", "System.Linq.Expressions.Interpreter.ActionCallInstruction`1")]
+        [PreserveDependency(".ctor", "System.Linq.Expressions.Interpreter.ActionCallInstruction`2")]
+        [PreserveDependency(".ctor", "System.Linq.Expressions.Interpreter.ActionCallInstruction`3")]
+        [PreserveDependency(".ctor", "System.Linq.Expressions.Interpreter.ActionCallInstruction`4")]
+        [PreserveDependency(".ctor", "System.Linq.Expressions.Interpreter.FuncCallInstruction`1")]
+        [PreserveDependency(".ctor", "System.Linq.Expressions.Interpreter.FuncCallInstruction`2")]
+        [PreserveDependency(".ctor", "System.Linq.Expressions.Interpreter.FuncCallInstruction`3")]
+        [PreserveDependency(".ctor", "System.Linq.Expressions.Interpreter.FuncCallInstruction`4")]
+        [PreserveDependency(".ctor", "System.Linq.Expressions.Interpreter.FuncCallInstruction`5")]
         private static Type GetHelperType(MethodInfo info, Type[] arrTypes)
         {
             Type t;
index 025df1d..fb1679c 100644 (file)
@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information.
 
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.Dynamic.Utils;
 using System.Globalization;
 using System.Reflection;
@@ -12,6 +13,7 @@ using AstUtils = System.Linq.Expressions.Utils;
 
 namespace System.Linq.Expressions.Interpreter
 {
+    [DebuggerDisplay("{DebugView,nq}")]
     public partial class LightLambda
     {
         private readonly IStrongBox[] _closure;
@@ -30,7 +32,7 @@ namespace System.Linq.Expressions.Interpreter
             _interpreter = delegateCreator.Interpreter;
         }
 
-        internal string DebugView => new DebugViewPrinter(_interpreter).ToString();
+        private string DebugView => new DebugViewPrinter(_interpreter).ToString();
 
         private class DebugViewPrinter
         {
index da4998c..07875d2 100644 (file)
@@ -277,6 +277,49 @@ namespace System.Runtime.CompilerServices
             }
         }
 
+#if FEATURE_COMPILE
+        // TODO https://github.com/mono/linker/issues/799: Consolidate these attributes when possible.
+        [PreserveDependency("NoMatch1`2", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("NoMatch2`3", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("NoMatch3`4", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("NoMatch4`5", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("NoMatch5`6", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("NoMatch6`7", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("NoMatch7`8", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("NoMatch8`9", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("NoMatch9`10", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("NoMatch10`11", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("NoMatchVoid1`1", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("NoMatchVoid2`2", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("NoMatchVoid3`3", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("NoMatchVoid4`4", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("NoMatchVoid5`5", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("NoMatchVoid6`6", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("NoMatchVoid7`7", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("NoMatchVoid8`8", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("NoMatchVoid9`9", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("NoMatchVoid10`10", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("UpdateAndExecute1`2", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("UpdateAndExecute2`3", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("UpdateAndExecute3`4", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("UpdateAndExecute4`5", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("UpdateAndExecute5`6", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("UpdateAndExecute6`7", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("UpdateAndExecute7`8", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("UpdateAndExecute8`9", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("UpdateAndExecute9`10", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("UpdateAndExecute10`11", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("UpdateAndExecuteVoid1`1", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("UpdateAndExecuteVoid2`2", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("UpdateAndExecuteVoid3`3", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("UpdateAndExecuteVoid4`4", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("UpdateAndExecuteVoid5`5", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("UpdateAndExecuteVoid6`6", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("UpdateAndExecuteVoid7`7", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("UpdateAndExecuteVoid8`8", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("UpdateAndExecuteVoid9`9", "System.Dynamic.UpdateDelegates")]
+        [PreserveDependency("UpdateAndExecuteVoid10`10", "System.Dynamic.UpdateDelegates")]
+#endif
         internal T MakeUpdateDelegate()
         {
 #if !FEATURE_COMPILE