From 6da5aa778e537f8ca43f4a9ac07f1274c43b22e5 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 2 Mar 2018 11:31:45 +0100 Subject: [PATCH] [mtouch] Move native code sharing check for the remove-dynamic-registrar optimization until after checking the linker settings. Fixes this test failure: 1) Failed : Xamarin.MTouch.MT0113_linker The error 'MT0113: Native code sharing has been disabled for the extension 'testServiceExtension' because the managed linker settings are different between the container app (None) and the extension (All).' was not found in the output: Message #1 did not match: actual: 'Native code sharing has been disabled for the extension 'testServiceExtension' because the remove-dynamic-registrar optimization differ between the container app (default) and the extension (false).' expected: 'Native code sharing has been disabled for the extension 'testServiceExtension' because the managed linker settings are different between the container app (None) and the extension (All).' which happens because: * Removing the dynamic registrar requires the linker, so removal of the dynamic registrar is disabled if the linker is not disabled * This results in the app and appex having different values for the remove-dynamic-registrar option * Thus the error message. Technically either error is correct, but I prefer the previous one (about the linker), because it directly assigns blame (the linker setting). Figuring out what has to change (the linker setting) when the error message complains about an optimization is not so straight forward for users. --- tools/mtouch/Application.cs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tools/mtouch/Application.cs b/tools/mtouch/Application.cs index 02172133dba7..dc1df7f391f9 100644 --- a/tools/mtouch/Application.cs +++ b/tools/mtouch/Application.cs @@ -957,16 +957,6 @@ void DetectCodeSharing () continue; } - if (Optimizations.RemoveDynamicRegistrar != appex.Optimizations.RemoveDynamicRegistrar) { - Func bool_tostr = (v) => { - if (!v.HasValue) - return "default"; - return v.Value ? "true" : "false"; - }; - ErrorHelper.Warning (113, "Native code sharing has been disabled for the extension '{0}' because {1}", appex.Name, $"the remove-dynamic-registrar optimization differ between the container app ({bool_tostr (appex.Optimizations.RemoveDynamicRegistrar)}) and the extension ({bool_tostr (Optimizations.RemoveDynamicRegistrar)})."); - continue; - } - bool applicable = true; // The --assembly-build-target arguments must be identical. // We can probably lift this requirement (at least partially) at some point, @@ -1056,6 +1046,17 @@ void DetectCodeSharing () } } + // Check that the remove-dynamic-registrar optimizations are identical + if (Optimizations.RemoveDynamicRegistrar != appex.Optimizations.RemoveDynamicRegistrar) { + Func bool_tostr = (v) => { + if (!v.HasValue) + return "default"; + return v.Value ? "true" : "false"; + }; + ErrorHelper.Warning (113, "Native code sharing has been disabled for the extension '{0}' because {1}", appex.Name, $"the remove-dynamic-registrar optimization differ between the container app ({bool_tostr (appex.Optimizations.RemoveDynamicRegistrar)}) and the extension ({bool_tostr (Optimizations.RemoveDynamicRegistrar)})."); + continue; + } + // Check if there aren't referenced assemblies from different sources foreach (var target in Targets) { var appexTarget = appex.Targets.SingleOrDefault ((v) => v.Is32Build == target.Is32Build);