From 50e6af6878fc9354d6dd141611fa47ef26803ffa Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Tue, 15 Sep 2020 18:03:27 -0600 Subject: [PATCH] Restore netcoreapp1.0 support for testhost (#2554) --- .../TestExtensionPluginInformation.cs | 2 +- .../Microsoft.TestPlatform.Common.csproj | 4 ++-- .../Resources/Resources.Designer.cs | 3 ++- .../Utilities/FakesUtilities.cs | 4 ++-- ...TestPlatform.CommunicationUtilities.csproj | 4 ++-- .../Resources/Resources.Designer.cs | 3 ++- ...icrosoft.TestPlatform.CoreUtilities.csproj | 6 +++--- .../Tracing/EqtTrace.cs | 2 +- ...rosoft.TestPlatform.CrossPlatEngine.csproj | 7 +++++-- .../Resources/Resources.Designer.cs | 3 ++- .../Microsoft.TestPlatform.ObjectModel.csproj | 21 ++++++++++++++----- .../Navigation/PortableSymbolReader.cs | 5 +++++ .../Resources/CommonResources.Designer.cs | 3 ++- ...t.TestPlatform.PlatformAbstractions.csproj | 4 ++-- .../InferRunSettingsHelper.cs | 12 ++++++++++- .../Microsoft.TestPlatform.Utilities.csproj | 4 ++-- src/testhost.x86/TestHostTraceListener.cs | 18 ++++++++++++++++ src/testhost.x86/testhost.x86.csproj | 8 +++++-- src/testhost/testhost.csproj | 10 ++++++--- 19 files changed, 91 insertions(+), 32 deletions(-) diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensionPluginInformation.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensionPluginInformation.cs index 679f2a0ff0..ac3face5da 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensionPluginInformation.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensionPluginInformation.cs @@ -81,7 +81,7 @@ private static string GetExtensionUri(Type testLoggerType) if (EqtTrace.IsErrorEnabled && string.IsNullOrEmpty(extensionUri)) { - EqtTrace.Error("The type \"{0}\" defined in \"{1}\" does not have ExtensionUri attribute.", testLoggerType.ToString(), testLoggerType.Module.Name); + EqtTrace.Error("The type \"{0}\" defined in \"{1}\" does not have ExtensionUri attribute.", testLoggerType.ToString(), testLoggerType.GetTypeInfo().Module.Name); } return extensionUri; diff --git a/src/Microsoft.TestPlatform.Common/Microsoft.TestPlatform.Common.csproj b/src/Microsoft.TestPlatform.Common/Microsoft.TestPlatform.Common.csproj index 7a7af2d6ce..3b7344455b 100644 --- a/src/Microsoft.TestPlatform.Common/Microsoft.TestPlatform.Common.csproj +++ b/src/Microsoft.TestPlatform.Common/Microsoft.TestPlatform.Common.csproj @@ -6,8 +6,8 @@ Microsoft.VisualStudio.TestPlatform.Common - netstandard2.0;net451 - netstandard2.0 + netstandard2.0;netstandard1.3;net451 + netstandard2.0;netstandard1.3 true diff --git a/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs b/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs index 4e54d9b88e..65cdef171f 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs +++ b/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs @@ -10,6 +10,7 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.Resources { using System; + using System.Reflection; /// @@ -39,7 +40,7 @@ internal class Resources { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.VisualStudio.TestPlatform.Common.Resources.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.VisualStudio.TestPlatform.Common.Resources.Resources", typeof(Resources).GetTypeInfo().Assembly); resourceMan = temp; } return resourceMan; diff --git a/src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs b/src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs index 502de37d13..adb4ce29d9 100644 --- a/src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs +++ b/src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs @@ -242,8 +242,8 @@ private static void EnsureSettingsNode(XmlDocument settings, TestRunSettings set { try { - Assembly assembly = Assembly.Load(FakesConfiguratorAssembly); - var type = assembly?.GetType(ConfiguratorAssemblyQualifiedName, false); + Assembly assembly = Assembly.Load(new AssemblyName(FakesConfiguratorAssembly)); + var type = assembly?.GetType(ConfiguratorAssemblyQualifiedName, false, false); var method = type?.GetMethod(CrossPlatformConfiguratorMethodName, new Type[] { typeof(IDictionary) }); if (method != null) { diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Microsoft.TestPlatform.CommunicationUtilities.csproj b/src/Microsoft.TestPlatform.CommunicationUtilities/Microsoft.TestPlatform.CommunicationUtilities.csproj index 1f9daa06dc..8419b36504 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Microsoft.TestPlatform.CommunicationUtilities.csproj +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Microsoft.TestPlatform.CommunicationUtilities.csproj @@ -5,8 +5,8 @@ Microsoft.TestPlatform.CommunicationUtilities - netstandard2.0;net451 - netstandard2.0 + netstandard2.0;netstandard1.3;net451 + netstandard2.0;netstandard1.3 true true diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Resources/Resources.Designer.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Resources/Resources.Designer.cs index 9ccddada2f..0a50b20672 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Resources/Resources.Designer.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Resources/Resources.Designer.cs @@ -10,6 +10,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources { using System; + using System.Reflection; /// @@ -39,7 +40,7 @@ public class Resources { public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources.Resources", typeof(Resources).GetTypeInfo().Assembly); resourceMan = temp; } return resourceMan; diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Microsoft.TestPlatform.CoreUtilities.csproj b/src/Microsoft.TestPlatform.CoreUtilities/Microsoft.TestPlatform.CoreUtilities.csproj index 91e61760a9..5c17e606b2 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Microsoft.TestPlatform.CoreUtilities.csproj +++ b/src/Microsoft.TestPlatform.CoreUtilities/Microsoft.TestPlatform.CoreUtilities.csproj @@ -6,8 +6,8 @@ Microsoft.TestPlatform.CoreUtilities - netstandard2.0;net451 - netstandard2.0 + netstandard2.0;netstandard1.3;net451 + netstandard2.0;netstandard1.3 @@ -20,7 +20,7 @@ - + 4.0.0 diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Tracing/EqtTrace.cs b/src/Microsoft.TestPlatform.CoreUtilities/Tracing/EqtTrace.cs index 6a798a33bc..7b13d802d3 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Tracing/EqtTrace.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Tracing/EqtTrace.cs @@ -50,7 +50,7 @@ public static TraceLevel TraceLevel #endif -#if NETSTANDARD2_0 +#if NETSTANDARD public static PlatformTraceLevel TraceLevel { get diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Microsoft.TestPlatform.CrossPlatEngine.csproj b/src/Microsoft.TestPlatform.CrossPlatEngine/Microsoft.TestPlatform.CrossPlatEngine.csproj index 2b4085b7e8..f350f7fd32 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Microsoft.TestPlatform.CrossPlatEngine.csproj +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Microsoft.TestPlatform.CrossPlatEngine.csproj @@ -6,8 +6,8 @@ Microsoft.TestPlatform.CrossPlatEngine - netstandard2.0;net451 - netstandard2.0 + netstandard2.0;netstandard1.3;net451 + netstandard2.0;netstandard1.3 true @@ -26,6 +26,9 @@ true + + + diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs index 24d87bbeb9..683eb49355 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs @@ -10,6 +10,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources { using System; + using System.Reflection; /// @@ -39,7 +40,7 @@ internal class Resources { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources.Resources", typeof(Resources).GetTypeInfo().Assembly); resourceMan = temp; } return resourceMan; diff --git a/src/Microsoft.TestPlatform.ObjectModel/Microsoft.TestPlatform.ObjectModel.csproj b/src/Microsoft.TestPlatform.ObjectModel/Microsoft.TestPlatform.ObjectModel.csproj index cd06e0ee08..20478c9b00 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Microsoft.TestPlatform.ObjectModel.csproj +++ b/src/Microsoft.TestPlatform.ObjectModel/Microsoft.TestPlatform.ObjectModel.csproj @@ -6,8 +6,8 @@ Microsoft.VisualStudio.TestPlatform.ObjectModel - net451;netstandard2.0 - netstandard2.0 + net451;netstandard2.0;netstandard1.3 + netstandard2.0;netstandard1.3 Microsoft.TestPlatform.ObjectModel @@ -31,10 +31,21 @@ + + + + + + + + + + + + + + - - 1.6.0 - diff --git a/src/Microsoft.TestPlatform.ObjectModel/Navigation/PortableSymbolReader.cs b/src/Microsoft.TestPlatform.ObjectModel/Navigation/PortableSymbolReader.cs index 9a28728b3a..206f047f80 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Navigation/PortableSymbolReader.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Navigation/PortableSymbolReader.cs @@ -101,8 +101,13 @@ private void PopulateCacheForTypeAndMethodSymbols(string binaryPath) } catch (FileNotFoundException) { +#if !NETSTANDARD1_3 // fallback when the assembly is not loaded asm = Assembly.LoadFile(binaryPath); +#else + // fallback is not supported + throw; +#endif } foreach (var type in asm.GetTypes()) diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/CommonResources.Designer.cs b/src/Microsoft.TestPlatform.ObjectModel/Resources/CommonResources.Designer.cs index 6e8ee0bbb1..3a37b375e5 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/CommonResources.Designer.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/CommonResources.Designer.cs @@ -10,6 +10,7 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources { using System; + using System.Reflection; /// @@ -39,7 +40,7 @@ public class CommonResources { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources.CommonResources", typeof(CommonResources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources.CommonResources", typeof(CommonResources).GetTypeInfo().Assembly); resourceMan = temp; } return resourceMan; diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/Microsoft.TestPlatform.PlatformAbstractions.csproj b/src/Microsoft.TestPlatform.PlatformAbstractions/Microsoft.TestPlatform.PlatformAbstractions.csproj index 329c10aa1d..d7e5483840 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/Microsoft.TestPlatform.PlatformAbstractions.csproj +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/Microsoft.TestPlatform.PlatformAbstractions.csproj @@ -6,8 +6,8 @@ Microsoft.TestPlatform.PlatformAbstractions - netcoreapp2.1;net451;uap10.0;netstandard2.0 - netstandard2.0;netcoreapp2.1 + netcoreapp2.1;net451;uap10.0;netstandard2.0;netstandard1.0 + netstandard2.0;netstandard1.0;netcoreapp2.1 true NU1605 diff --git a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs index fc069da27e..c0edcb8f3f 100644 --- a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs +++ b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs @@ -715,11 +715,21 @@ private static bool IsPlatformIncompatible(Architecture sourcePlatform, Architec { return false; } - if (targetPlatform == Architecture.X64 && !Environment.Is64BitOperatingSystem) + if (targetPlatform == Architecture.X64 && !Is64BitOperatingSystem()) { return true; } return sourcePlatform != targetPlatform; + + bool Is64BitOperatingSystem() + { +#if !NETSTANDARD1_3 + return Environment.Is64BitOperatingSystem; +#else + // In the absence of APIs to check, assume the majority case + return true; +#endif + } } /// diff --git a/src/Microsoft.TestPlatform.Utilities/Microsoft.TestPlatform.Utilities.csproj b/src/Microsoft.TestPlatform.Utilities/Microsoft.TestPlatform.Utilities.csproj index 81f341c320..0323baf7e8 100644 --- a/src/Microsoft.TestPlatform.Utilities/Microsoft.TestPlatform.Utilities.csproj +++ b/src/Microsoft.TestPlatform.Utilities/Microsoft.TestPlatform.Utilities.csproj @@ -6,8 +6,8 @@ Microsoft.TestPlatform.Utilities - netstandard2.0;net451 - netstandard2.0 + netstandard2.0;netstandard1.3;net451 + netstandard2.0;netstandard1.3 diff --git a/src/testhost.x86/TestHostTraceListener.cs b/src/testhost.x86/TestHostTraceListener.cs index dda5876dd9..214b9db411 100644 --- a/src/testhost.x86/TestHostTraceListener.cs +++ b/src/testhost.x86/TestHostTraceListener.cs @@ -76,7 +76,21 @@ public static void ShowDialog(string stackTrace, string message, string detailMe private static DebugAssertException GetException(string message) { var debugTypes = new Type[] { typeof(Debug), typeof(Trace) }; +#if NETCOREAPP1_0 + Exception exceptionForStack; + try + { + throw new Exception(); + } + catch (Exception e) + { + exceptionForStack = e; + } + + var stack = new StackTrace(exceptionForStack, true); +#else var stack = new StackTrace(true); +#endif var debugMethodFound = false; var frameCount = 0; @@ -97,7 +111,11 @@ private static DebugAssertException GetException(string message) } } +#if NETCOREAPP1_0 + var stackTrace = string.Join(Environment.NewLine, stack.ToString().Replace(Environment.NewLine, "\n").Split('\n').Reverse().Take(frameCount).Reverse()); +#else var stackTrace = string.Join(Environment.NewLine, stack.ToString().Split(Environment.NewLine).TakeLast(frameCount)); +#endif var methodName = method != null ? $"{method.DeclaringType.Name}.{method.Name}" : ""; var wholeMessage = $"Method {methodName} failed with '{message}', and was translated to { typeof(DebugAssertException).FullName } to avoid terminating the process hosting the test."; diff --git a/src/testhost.x86/testhost.x86.csproj b/src/testhost.x86/testhost.x86.csproj index 535a6e6afb..34a04f8092 100644 --- a/src/testhost.x86/testhost.x86.csproj +++ b/src/testhost.x86/testhost.x86.csproj @@ -6,8 +6,8 @@ testhost.x86 - netcoreapp2.1;net451;net452;net46;net461;net462;net47;net471;net472;net48 - netcoreapp2.1 + netcoreapp2.1;netcoreapp1.0;net451;net452;net46;net461;net462;net47;net471;net472;net48 + netcoreapp2.1;netcoreapp1.0 true AnyCPU true @@ -19,6 +19,10 @@ + + + + diff --git a/src/testhost/testhost.csproj b/src/testhost/testhost.csproj index c239485d24..25efc8ec61 100644 --- a/src/testhost/testhost.csproj +++ b/src/testhost/testhost.csproj @@ -6,12 +6,12 @@ testhost - netcoreapp2.1;net451;net452;net46;net461;net462;net47;net471;net472;net48 - netcoreapp2.1 + netcoreapp2.1;netcoreapp1.0;net451;net452;net46;net461;net462;net47;net471;net472;net48 + netcoreapp2.1;netcoreapp1.0 Exe app.manifest - + win7-x64 false @@ -21,6 +21,10 @@ + + + +