From add54f848e740274777bff881d90ba91c45b2e69 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Thu, 25 Feb 2021 12:52:26 +0100 Subject: [PATCH] Simplify the workaround This also gets rid of typo in previous commit, which caused problems in XF test. --- src/Microsoft.Android.Sdk.ILLink/SetupStep.cs | 31 +++++-------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/src/Microsoft.Android.Sdk.ILLink/SetupStep.cs b/src/Microsoft.Android.Sdk.ILLink/SetupStep.cs index 28930b0d915..11d2dfd5313 100644 --- a/src/Microsoft.Android.Sdk.ILLink/SetupStep.cs +++ b/src/Microsoft.Android.Sdk.ILLink/SetupStep.cs @@ -26,6 +26,8 @@ List Steps { } } + static MethodInfo getReferencedAssembliesMethod = typeof (LinkContext).GetMethod ("GetReferencedAssemblies", BindingFlags.Public | BindingFlags.Instance); + protected override void Process () { string tfmPaths; @@ -44,9 +46,12 @@ protected override void Process () subSteps2.Add (new PreserveRegistrations (cache)); subSteps2.Add (new PreserveJavaInterfaces ()); - ProcessDispatcher (subSteps1); - ProcessDispatcher (subSteps1); - ProcessStep (new FixAbstractMethodsStep (cache)); + InsertAfter (new FixAbstractMethodsStep (cache), "SetupStep"); + InsertAfter (subSteps2, "SetupStep"); + InsertAfter (subSteps1, "SetupStep"); + + // temporary workaround: this call forces illink to process all the assemblies + getReferencedAssembliesMethod.Invoke (Context, null); string proguardPath; if (Context.TryGetCustomData ("ProguardConfiguration", out proguardPath)) @@ -59,26 +64,6 @@ protected override void Process () InsertAfter (new StripEmbeddedLibraries (), "CleanStep"); } - static Type dispatcherType = typeof (SubStepsDispatcher); - static MethodInfo initMethod = dispatcherType.GetMethod ("InitializeSubSteps", BindingFlags.NonPublic | BindingFlags.Instance); - static MethodInfo browseMethod = dispatcherType.GetMethod ("BrowseAssemblies", BindingFlags.NonPublic | BindingFlags.Instance); - static MethodInfo getReferencedAssembliesMethod = typeof (LinkContext).GetMethod ("GetReferencedAssemblies", BindingFlags.Public | BindingFlags.Instance); - static MethodInfo processAssemblyMethod = typeof (BaseStep).GetMethod ("ProcessAssembly", BindingFlags.NonPublic | BindingFlags.Instance); - - void ProcessStep (BaseStep step) - { - typeof (BaseStep).GetField ("_context", BindingFlags.Instance | BindingFlags.NonPublic).SetValue (step, Context); - - foreach (var assembly in (IEnumerable) getReferencedAssembliesMethod.Invoke (Context, null)) - processAssemblyMethod.Invoke (step, new object [] { assembly }); - } - - void ProcessDispatcher (SubStepDispatcher dispatcher) - { - initMethod.Invoke (dispatcher, new object [] { Context }); - browseMethod.Invoke (dispatcher, new object [] { getReferencedAssembliesMethod.Invoke (Context, null) }); - } - void InsertAfter (IStep step, string stepName) { for (int i = 0; i < Steps.Count;) {