From 4fbb74fc9fdb39d278ee0886f5310dbdc1efd88c Mon Sep 17 00:00:00 2001 From: Medeni Baykal <433724+Haplois@users.noreply.github.com> Date: Mon, 27 Jun 2022 16:07:35 +0200 Subject: [PATCH 1/7] Updated version tag to release. --- eng/Versions.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Versions.props b/eng/Versions.props index e791c5e24b..aec6aa1cc7 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -3,7 +3,7 @@ 17.3.0 - preview + release false true From c7ba2ca721808f830482ace6be06ae93077e0e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Fri, 8 Jul 2022 10:56:08 +0200 Subject: [PATCH 2/7] Reverts change that breaks DOTNET_ROOT (#3844) --- .../Hosting/DotnetTestHostManager.cs | 69 +++------ .../Hosting/DotnetTestHostManagerTests.cs | 137 ------------------ .../IntegrationTestBase.cs | 10 +- .../ProjectLaunch32BitsProcess.csproj | 22 --- .../ProjectLaunch32BitsProcess/Test32Bit.cs | 68 --------- test/TestAssets/TestAssets.sln | 32 ---- test/TestAssets/TestProcess32/Program.cs | 32 ---- .../TestProcess32/TestProcess32.csproj | 10 -- 8 files changed, 23 insertions(+), 357 deletions(-) delete mode 100644 test/TestAssets/ProjectLaunch32BitsProcess/ProjectLaunch32BitsProcess.csproj delete mode 100644 test/TestAssets/ProjectLaunch32BitsProcess/Test32Bit.cs delete mode 100644 test/TestAssets/TestProcess32/Program.cs delete mode 100644 test/TestAssets/TestProcess32/TestProcess32.csproj diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs index f9c53dd18f..2e8ceb1b88 100644 --- a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs +++ b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs @@ -53,8 +53,6 @@ public class DotnetTestHostManager : ITestRuntimeProvider2 private const string TestAdapterRegexPattern = @"TestAdapter.dll"; private const string PROCESSOR_ARCHITECTURE = nameof(PROCESSOR_ARCHITECTURE); - private static readonly Version Version6_0 = new(6, 0); - private readonly IDotnetHostHelper _dotnetHostHelper; private readonly IEnvironment _platformEnvironment; private readonly IProcessHelper _processHelper; @@ -471,7 +469,24 @@ public virtual TestProcessStartInfo GetTestHostProcessStartInfo( // i.e. I've got only private install and no global installation, in this case apphost needs to use env var to locate runtime. if (testHostExeFound) { - ForwardDotnetRootEnvironmentVariable(startInfo); + string prefix = "VSTEST_WINAPPHOST_"; + string dotnetRootEnvName = $"{prefix}DOTNET_ROOT(x86)"; + var dotnetRoot = _environmentVariableHelper.GetEnvironmentVariable(dotnetRootEnvName); + if (dotnetRoot is null) + { + dotnetRootEnvName = $"{prefix}DOTNET_ROOT"; + dotnetRoot = _environmentVariableHelper.GetEnvironmentVariable(dotnetRootEnvName); + } + + if (dotnetRoot != null) + { + EqtTrace.Verbose($"DotnetTestHostmanager.LaunchTestHostAsync: Found '{dotnetRootEnvName}' in env variables, value '{dotnetRoot}', forwarding to '{dotnetRootEnvName.Replace(prefix, string.Empty)}'"); + startInfo.EnvironmentVariables.Add(dotnetRootEnvName.Replace(prefix, string.Empty), dotnetRoot); + } + else + { + EqtTrace.Verbose($"DotnetTestHostmanager.LaunchTestHostAsync: Prefix '{prefix}*' not found in env variables"); + } } startInfo.WorkingDirectory = sourceDirectory; @@ -568,54 +583,6 @@ bool IsNativeModule(string modulePath) } } - internal /* for testing purposes */ void ForwardDotnetRootEnvironmentVariable(TestProcessStartInfo startInfo) - { - TPDebug.Assert(_targetFramework is not null, "Initialize must have been called before this method."); - const string prefix = "VSTEST_WINAPPHOST_"; - const string dotnetRoot = "DOTNET_ROOT"; - string vstestDotnetRootEnvName = $"{prefix}{dotnetRoot}(x86)"; - - // Check if VSTEST_WINAPPHOST_DOTNET_ROOT(x86) is set, if not then looks for VSTEST_WINAPPHOST_DOTNET_ROOT. - // If none of these variables is set we exit as we have nothing to forward. - var vstestDotnetRootEnvValue = _environmentVariableHelper.GetEnvironmentVariable(vstestDotnetRootEnvName); - if (vstestDotnetRootEnvValue is null) - { - vstestDotnetRootEnvName = $"{prefix}{dotnetRoot}"; - vstestDotnetRootEnvValue = _environmentVariableHelper.GetEnvironmentVariable(vstestDotnetRootEnvName); - - // None of the forwarding environment variables are set so exit. - if (vstestDotnetRootEnvValue is null) - { - EqtTrace.Verbose($"DotnetTestHostmanager.LaunchTestHostAsync: Prefix '{prefix}*' not found in env variables"); - return; - } - } - - // For .NET 6.0 onward, the DOTNET_ROOT* environment variable to set was changed. - // This implementation is based on the logic defined in SDK: - // https://github.com/dotnet/sdk/blob/c3f8d746f4d5cd87f462d711a3caa7a4f6621826/src/Cli/dotnet/commands/dotnet-run/RunCommand.cs#L264-L279 - string dotnetRootEnvName; - if (Version.Parse(_targetFramework.Version) >= Version6_0) - { - dotnetRootEnvName = $"{dotnetRoot}_{_processHelper.GetCurrentProcessArchitecture().ToString().ToUpperInvariant()}"; - - // SDK side of TP is not checking for the .NET6.0+ environment variables so we want to make sure we - // are not overriding user definition. - if (_environmentVariableHelper.GetEnvironmentVariable(dotnetRootEnvName) is string dotnetRootEnvValue) - { - EqtTrace.Verbose($"DotnetTestHostmanager.LaunchTestHostAsync: Found '{vstestDotnetRootEnvName}' in env variables but also found '{dotnetRootEnvName}' with value '{dotnetRootEnvValue}'. Skipping forwarding."); - return; - } - } - else - { - dotnetRootEnvName = vstestDotnetRootEnvName.Replace(prefix, string.Empty); - } - - EqtTrace.Verbose($"DotnetTestHostmanager.LaunchTestHostAsync: Found '{vstestDotnetRootEnvName}' in env variables, value '{vstestDotnetRootEnvValue}', forwarding to '{dotnetRootEnvName}' (target framework is {_targetFramework.Name}, Version={_targetFramework.Version})."); - startInfo.EnvironmentVariables!.Add(dotnetRootEnvName, vstestDotnetRootEnvValue); - } - /// public IEnumerable GetTestPlatformExtensions(IEnumerable sources, IEnumerable extensions) { diff --git a/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerTests.cs b/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerTests.cs index 8aee09f72e..4b97c13465 100644 --- a/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerTests.cs +++ b/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerTests.cs @@ -1025,143 +1025,6 @@ public async Task CleanTestHostAsyncShouldNotThrowIfTestHostIsNotStarted() Assert.IsTrue(isVerified); } - [TestMethod] - [DataRow("VSTEST_WINAPPHOST_DOTNET_ROOT(x86)", "DOTNET_ROOT(x86)")] - [DataRow("VSTEST_WINAPPHOST_DOTNET_ROOT", "DOTNET_ROOT")] - public void ForwardDotnetRootEnvironmentVariableWhenTargetFrameworkIsLessThanNet6SetsCorrectEnvVariable(string envVarName, string expectedForwaredName) - { - // Arrange - const string envVarValue = "c:\\SomePath"; - _mockEnvironmentVariable.Reset(); - _mockEnvironmentVariable.Setup(x => x.GetEnvironmentVariable(envVarName)).Returns(envVarValue); - string runSettingsXml = """ - - - net5.0 - - - """; - _dotnetHostManager.Initialize(_mockMessageLogger.Object, runSettingsXml); - - var startInfo = new TestProcessStartInfo { EnvironmentVariables = new Dictionary() }; - // Sanity check - Assert.AreEqual(0, startInfo.EnvironmentVariables.Count); - - // Act - _dotnetHostManager.ForwardDotnetRootEnvironmentVariable(startInfo); - - // Assert - Assert.AreEqual(1, startInfo.EnvironmentVariables.Count); - Assert.IsTrue(startInfo.EnvironmentVariables.TryGetValue(expectedForwaredName, out var actualEnvVarValue)); - Assert.AreEqual(envVarValue, actualEnvVarValue); - } - - [TestMethod] - [DataRow("DOTNET_ROOT(x86)", "net5.0")] - [DataRow("DOTNET_ROOT(x86)", "net6.0")] - [DataRow("DOTNET_ROOT", "net5.0")] - [DataRow("DOTNET_ROOT", "net6.0")] - [DataRow("DOTNET_ROOT_X86", "net5.0")] - [DataRow("DOTNET_ROOT_X86", "net6.0")] - [DataRow("DOTNET_ROOT_X64", "net5.0")] - [DataRow("DOTNET_ROOT_X64", "net6.0")] - [DataRow("DOTNET_ROOT_ARM64", "net5.0")] - [DataRow("DOTNET_ROOT_ARM64", "net6.0")] - public void ForwardDotnetRootEnvironmentVariableWhenIncorrectEnvVarDoesNothing(string envVarName, string framework) - { - // Arrange - const string envVarValue = "c:\\SomePath"; - _mockEnvironmentVariable.Reset(); - _mockEnvironmentVariable.Setup(x => x.GetEnvironmentVariable(envVarName)).Returns(envVarValue); - string runSettingsXml = $""" - - - {framework} - - - """; - _dotnetHostManager.Initialize(_mockMessageLogger.Object, runSettingsXml); - - var startInfo = new TestProcessStartInfo { EnvironmentVariables = new Dictionary() }; - - // Act - _dotnetHostManager.ForwardDotnetRootEnvironmentVariable(startInfo); - - // Assert - Assert.AreEqual(0, startInfo.EnvironmentVariables.Count); - } - - [TestMethod] - [DataRow("VSTEST_WINAPPHOST_DOTNET_ROOT(x86)", PlatformArchitecture.X86)] - [DataRow("VSTEST_WINAPPHOST_DOTNET_ROOT(x86)", PlatformArchitecture.X64)] - [DataRow("VSTEST_WINAPPHOST_DOTNET_ROOT", PlatformArchitecture.X86)] - [DataRow("VSTEST_WINAPPHOST_DOTNET_ROOT", PlatformArchitecture.X64)] - public void ForwardDotnetRootEnvironmentVariableWhenTargetFrameworkIsGreaterOrEqualsToNet6SetsCorrectEnvVariable(string envVarName, PlatformArchitecture platformArchitecture) - { - // Arrange - const string envVarValue = "c:\\SomePath"; - _mockEnvironmentVariable.Reset(); - _mockEnvironmentVariable.Setup(x => x.GetEnvironmentVariable(envVarName)).Returns(envVarValue); - _mockProcessHelper.Setup(x => x.GetCurrentProcessArchitecture()).Returns(platformArchitecture); - string runSettingsXml = """ - - - net6.0 - - - """; - _dotnetHostManager.Initialize(_mockMessageLogger.Object, runSettingsXml); - - var startInfo = new TestProcessStartInfo { EnvironmentVariables = new Dictionary() }; - // Sanity check - Assert.AreEqual(0, startInfo.EnvironmentVariables.Count); - - // Act - _dotnetHostManager.ForwardDotnetRootEnvironmentVariable(startInfo); - - // Assert - Assert.AreEqual(1, startInfo.EnvironmentVariables.Count); - Assert.IsTrue(startInfo.EnvironmentVariables.TryGetValue($"DOTNET_ROOT_{platformArchitecture.ToString().ToUpperInvariant()}", out var actualEnvVarValue)); - Assert.AreEqual(envVarValue, actualEnvVarValue); - } - - [TestMethod] - [DataRow("VSTEST_WINAPPHOST_DOTNET_ROOT(x86)", PlatformArchitecture.X86)] - [DataRow("VSTEST_WINAPPHOST_DOTNET_ROOT(x86)", PlatformArchitecture.X64)] - [DataRow("VSTEST_WINAPPHOST_DOTNET_ROOT(x86)", PlatformArchitecture.ARM64)] - [DataRow("VSTEST_WINAPPHOST_DOTNET_ROOT", PlatformArchitecture.X86)] - [DataRow("VSTEST_WINAPPHOST_DOTNET_ROOT", PlatformArchitecture.X64)] - [DataRow("VSTEST_WINAPPHOST_DOTNET_ROOT", PlatformArchitecture.ARM64)] - public void ForwardDotnetRootEnvironmentVariableWhenTargetFrameworkIsGreaterOrEqualsToNet6DoesNotOverrideEnvVar(string envVarName, PlatformArchitecture platformArchitecture) - { - // Arrange - const string expectedEnvVarValue = "c:\\SomePath"; - const string nonForwardedEnvVarValue = "C:\\SomeOtherPath"; - var expectedForwardedEnvVarName = $"DOTNET_ROOT_{platformArchitecture.ToString().ToUpperInvariant()}"; - _mockEnvironmentVariable.Reset(); - _mockEnvironmentVariable.Setup(x => x.GetEnvironmentVariable(envVarName)).Returns(expectedEnvVarValue); - _mockEnvironmentVariable.Setup(x => x.GetEnvironmentVariable(expectedForwardedEnvVarName)).Returns(nonForwardedEnvVarValue); - _mockProcessHelper.Setup(x => x.GetCurrentProcessArchitecture()).Returns(platformArchitecture); - string runSettingsXml = """ - - - net6.0 - - - """; - _dotnetHostManager.Initialize(_mockMessageLogger.Object, runSettingsXml); - - var startInfo = new TestProcessStartInfo { EnvironmentVariables = new Dictionary() }; - // Sanity check - Assert.AreEqual(0, startInfo.EnvironmentVariables.Count); - - // Act - _dotnetHostManager.ForwardDotnetRootEnvironmentVariable(startInfo); - - // Assert - Assert.AreEqual(0, startInfo.EnvironmentVariables.Count); - } - private void DotnetHostManagerExitCodeTesterHostExited(object? sender, HostProviderEventArgs e) { _errorMessage = e.Data.TrimEnd(Environment.NewLine.ToCharArray()); diff --git a/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs b/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs index d3d5d5d0c1..1ad5cc2aee 100644 --- a/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs +++ b/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs @@ -193,7 +193,7 @@ public void InvokeVsTest(string? arguments, Dictionary? environ /// Invokes our local copy of dotnet that is patched with artifacts from the build with specified arguments. /// /// Arguments provided to vstest.console.exe - public void InvokeDotnetTest(string arguments, Dictionary? environmentVariables = null, bool useDotnetFromTools = false, string? workingDirectory = null) + public void InvokeDotnetTest(string arguments, Dictionary? environmentVariables = null) { var debugEnvironmentVariables = AddDebugEnvironmentVariables(environmentVariables); @@ -208,7 +208,7 @@ public void InvokeDotnetTest(string arguments, Dictionary? envi // https://github.com/dotnet/sdk/blob/main/src/Cli/dotnet/commands/dotnet-test/VSTestForwardingApp.cs#L30-L39 debugEnvironmentVariables["VSTEST_CONSOLE_PATH"] = vstestConsolePath; - ExecutePatchedDotnet("test", arguments, out _standardTestOutput, out _standardTestError, out _runnerExitCode, debugEnvironmentVariables, useDotnetFromTools, workingDirectory); + ExecutePatchedDotnet("test", arguments, out _standardTestOutput, out _standardTestError, out _runnerExitCode, debugEnvironmentVariables); FormatStandardOutCome(); } @@ -762,7 +762,7 @@ protected void ExecuteVsTestConsole(string? args, out string stdOut, out string /// /// private void ExecutePatchedDotnet(string command, string args, out string stdOut, out string stdError, out int exitCode, - Dictionary? environmentVariables = null, bool useDotnetFromTools = false, string? workingDirectory = null) + Dictionary? environmentVariables = null) { if (environmentVariables is null) { @@ -772,8 +772,8 @@ private void ExecutePatchedDotnet(string command, string args, out string stdOut environmentVariables["DOTNET_MULTILEVEL_LOOKUP"] = "0"; var executablePath = IsWindows ? @"dotnet\dotnet.exe" : @"dotnet-linux/dotnet"; - var patchedDotnetPath = Path.Combine(useDotnetFromTools ? _testEnvironment.ToolsDirectory : _testEnvironment.TestArtifactsDirectory, executablePath); - ExecuteApplication(patchedDotnetPath, string.Join(" ", command, args), out stdOut, out stdError, out exitCode, environmentVariables, workingDirectory); + var patchedDotnetPath = Path.Combine(_testEnvironment.TestArtifactsDirectory, executablePath); + ExecuteApplication(patchedDotnetPath, string.Join(" ", command, args), out stdOut, out stdError, out exitCode, environmentVariables); } protected static void ExecuteApplication(string path, string? args, out string stdOut, out string stdError, out int exitCode, diff --git a/test/TestAssets/ProjectLaunch32BitsProcess/ProjectLaunch32BitsProcess.csproj b/test/TestAssets/ProjectLaunch32BitsProcess/ProjectLaunch32BitsProcess.csproj deleted file mode 100644 index 0e3ae170ab..0000000000 --- a/test/TestAssets/ProjectLaunch32BitsProcess/ProjectLaunch32BitsProcess.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - net5.0;net6.0 - enable - Preview - - - - - - - - - - - - - diff --git a/test/TestAssets/ProjectLaunch32BitsProcess/Test32Bit.cs b/test/TestAssets/ProjectLaunch32BitsProcess/Test32Bit.cs deleted file mode 100644 index e6bcc1bffe..0000000000 --- a/test/TestAssets/ProjectLaunch32BitsProcess/Test32Bit.cs +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Diagnostics; - -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace UnitTest; - -[TestClass] -public class Test32Bit -{ - [TestMethod] - public void TheTest() - { - // Test is based on reproducer from following SDK issue: https://github.com/dotnet/sdk/issues/22647 - // We cannot run the test in an automatic/coded way because we need to have .NET 5 and 6 SDKs installed - // which leads to full disk capacity on CI. - // As this change of behavior is quite important we want to make sure we can rerun such manual test - // later on so we are keeping it here. - // Repro steps: - // 1. Build project - // 2. Set $env:DOTNET_ROOT_ENV_VAR_NAME = "DOTNET_ROOT(x86)" - // 3. Set $env:DOTNET_ROOT_ENV_VAR_VALUE to a 32bits dotnet installation directory for the matching TFM - // (e.g. C:\src\vstest\tools\dotnet_x86) - // 4. Add a global.json pinning the .NET version to 5 or 6 - // 5. Run 'dotnet test ./bin///ProjectLaunch32BitsProcess.dll' - // 6. Test should be succesful - // 7. Repeat steps 2 to 5 with $env:DOTNET_ROOT_ENV_VAR_NAME = "DOTNET_ROOT". Although we are running a - // 32 bits process, the dotnet detection logic is set to fallback to this variable. - // 8. Repeat steps 2 to 5 with $env:DOTNET_ROOT_ENV_VAR_NAME = "DOTNET_ROOT_X86". - // This should work for .NET 6 but fail for .NET 5 (if you don't have a global .NET 5 SDK installed), - // as this new variable is not understood by the .NET 5 detection algorithm. - // Debugging tips: - // Use the following environment variables to understand how is .NET being resolved. - // COREHOST_TRACE = 1 - // COREHOST_TRACEFILE = "C:\fxr.tx" - var process = new Process(); - process.StartInfo = new ProcessStartInfo - { - FileName = "TestProcess32.exe", - RedirectStandardError = true, - RedirectStandardOutput = true, - }; - - var envVarName = Environment.GetEnvironmentVariable("DOTNET_ROOT_ENV_VAR_NAME"); - Assert.IsNotNull(envVarName, "Calling process didn't set DOTNET_ROOT_ENV_VAR_NAME."); - var envVarValue = Environment.GetEnvironmentVariable("DOTNET_ROOT_ENV_VAR_VALUE"); - Assert.IsNotNull(envVarValue, "Calling process didn't set DOTNET_ROOT_ENV_VAR_VALUE."); - // Set the DOTNET_ROOT* env variable so that the 32bits process can locate dotnet - // even if there is no global installation. - process.StartInfo.EnvironmentVariables[envVarName] = envVarValue; - process.StartInfo.EnvironmentVariables["DOTNET_ROOT_ENV_VAR_NAME"] = envVarName; - // Ensure multi-level lookup is disabled so that we don't fallback to machine-wide installation - process.StartInfo.EnvironmentVariables["DOTNET_MULTILEVEL_LOOKUP"] = "0"; - - process.Start(); - var stderr = process.StandardError.ReadToEnd(); - var stdout = process.StandardOutput.ReadToEnd(); - - Console.WriteLine($"32bit stdout: {stdout}"); - Console.WriteLine($"32bit err: {stderr}"); - - Assert.IsTrue(string.IsNullOrEmpty(stderr), - $"There was some error in process run: {stderr}"); - } -} diff --git a/test/TestAssets/TestAssets.sln b/test/TestAssets/TestAssets.sln index 32b4fcd42a..8fae3a203e 100644 --- a/test/TestAssets/TestAssets.sln +++ b/test/TestAssets/TestAssets.sln @@ -124,12 +124,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tools", "Tools\Tools.csproj EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Perfy.TestAdapter", "performance\Perfy.TestAdapter\Perfy.TestAdapter.csproj", "{71BF7EC9-7BEE-4038-8F4E-87032FA4E995}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DOTNET_ROOT", "DOTNET_ROOT", "{C06EFF20-F1EA-42B7-B404-D8AB98AA78C0}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestProcess32", "TestProcess32\TestProcess32.csproj", "{4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectLaunch32BitsProcess", "ProjectLaunch32BitsProcess\ProjectLaunch32BitsProcess.csproj", "{A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -812,30 +806,6 @@ Global {71BF7EC9-7BEE-4038-8F4E-87032FA4E995}.Release|x64.Build.0 = Release|Any CPU {71BF7EC9-7BEE-4038-8F4E-87032FA4E995}.Release|x86.ActiveCfg = Release|Any CPU {71BF7EC9-7BEE-4038-8F4E-87032FA4E995}.Release|x86.Build.0 = Release|Any CPU - {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Debug|x64.ActiveCfg = Debug|Any CPU - {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Debug|x64.Build.0 = Debug|Any CPU - {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Debug|x86.ActiveCfg = Debug|Any CPU - {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Debug|x86.Build.0 = Debug|Any CPU - {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Release|Any CPU.Build.0 = Release|Any CPU - {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Release|x64.ActiveCfg = Release|Any CPU - {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Release|x64.Build.0 = Release|Any CPU - {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Release|x86.ActiveCfg = Release|Any CPU - {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Release|x86.Build.0 = Release|Any CPU - {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Debug|x64.ActiveCfg = Debug|Any CPU - {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Debug|x64.Build.0 = Debug|Any CPU - {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Debug|x86.ActiveCfg = Debug|Any CPU - {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Debug|x86.Build.0 = Debug|Any CPU - {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Release|Any CPU.Build.0 = Release|Any CPU - {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Release|x64.ActiveCfg = Release|Any CPU - {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Release|x64.Build.0 = Release|Any CPU - {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Release|x86.ActiveCfg = Release|Any CPU - {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -856,8 +826,6 @@ Global {10AA955C-B412-41A8-899F-8609AAE19F61} = {2633D125-64A7-456C-AD37-F8A6B56C2403} {E166D337-4033-4209-863F-8F77675EAEE8} = {2633D125-64A7-456C-AD37-F8A6B56C2403} {71BF7EC9-7BEE-4038-8F4E-87032FA4E995} = {0C9CA869-32FD-4A9E-8885-E2E19786C746} - {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506} = {C06EFF20-F1EA-42B7-B404-D8AB98AA78C0} - {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA} = {C06EFF20-F1EA-42B7-B404-D8AB98AA78C0} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D2334DAA-F7B2-450E-ABA4-FBC185152500} diff --git a/test/TestAssets/TestProcess32/Program.cs b/test/TestAssets/TestProcess32/Program.cs deleted file mode 100644 index 107b3f8908..0000000000 --- a/test/TestAssets/TestProcess32/Program.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; - -if (Environment.Is64BitProcess) -{ - throw new InvalidOperationException("Process is supposed to be 32bits."); -} - -var envVarName = Environment.GetEnvironmentVariable("DOTNET_ROOT_ENV_VAR_NAME"); -if (string.IsNullOrEmpty(envVarName)) -{ - throw new InvalidOperationException("Could not find 'DOTNET_ROOT_ENV_VAR_NAME' which is supposed to tell us which DOTNET_ROOTXXX to look up."); -} - -var dotnetRootPath = Environment.GetEnvironmentVariable(envVarName); -if (string.IsNullOrEmpty(dotnetRootPath)) -{ - throw new InvalidOperationException($"{dotnetRootPath} was not set."); -} - -Console.WriteLine("DOTNET_ROOT(x86)={0}", Environment.GetEnvironmentVariable("DOTNET_ROOT(x86)")); -Console.WriteLine("DOTNET_ROOT={0}", Environment.GetEnvironmentVariable("DOTNET_ROOT")); -Console.WriteLine("DOTNET_ROOT_X86={0}", Environment.GetEnvironmentVariable("DOTNET_ROOT_X86")); -Console.WriteLine("DOTNET_ROOT_X64={0}", Environment.GetEnvironmentVariable("DOTNET_ROOT_X64")); - -if (!typeof(object).Assembly.Location.StartsWith(dotnetRootPath, StringComparison.OrdinalIgnoreCase)) -{ - throw new InvalidOperationException($"{typeof(object).Assembly.Location} was not found in {dotnetRootPath}. .NET was not resolved from the correct path."); -} - -Console.WriteLine("Process and DOTNET_ROOT* were correctly set."); diff --git a/test/TestAssets/TestProcess32/TestProcess32.csproj b/test/TestAssets/TestProcess32/TestProcess32.csproj deleted file mode 100644 index 0a5f4d7e1a..0000000000 --- a/test/TestAssets/TestProcess32/TestProcess32.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - x86 - Exe - net5.0;net6.0 - enable - - - From a3d836984c5012d84d85a42d0bfbc67a65bf6562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Fri, 19 Aug 2022 11:06:27 +0200 Subject: [PATCH 3/7] Do not match netstandard for .NET testhost --- playground/TestPlatform.Playground/Program.cs | 5 +++-- .../Client/ProxyOperationManager.cs | 12 ++++++------ .../Resources/Resources.Designer.cs | 4 ++-- .../Resources/Resources.resx | 3 ++- .../Hosting/DotnetTestHostManager.cs | 4 +--- .../Client/ProxyExecutionManagerTests.cs | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/playground/TestPlatform.Playground/Program.cs b/playground/TestPlatform.Playground/Program.cs index 9c17968abd..0732a347c8 100644 --- a/playground/TestPlatform.Playground/Program.cs +++ b/playground/TestPlatform.Playground/Program.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.IO; using System.Linq; using System.Reflection; @@ -169,7 +170,7 @@ public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryComplete public void HandleLogMessage(TestMessageLevel level, string? message) { - Console.WriteLine($"[DISCOVERY.{level.ToString().ToUpper()}] {message}"); + Console.WriteLine($"[DISCOVERY.{level.ToString().ToUpper(CultureInfo.InvariantCulture)}] {message}"); } public void HandleRawMessage(string rawMessage) @@ -197,7 +198,7 @@ public TestRunHandler() public void HandleLogMessage(TestMessageLevel level, string? message) { - Console.WriteLine($"[{level.ToString().ToUpper()}]: {message}"); + Console.WriteLine($"[{level.ToString().ToUpper(CultureInfo.InvariantCulture)}]: {message}"); } public void HandleRawMessage(string rawMessage) diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs index 97e9820f6c..04877f51a7 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs @@ -272,11 +272,11 @@ public virtual bool SetupChannel(IEnumerable sources, string? runSetting // Throw a test platform exception along with the error messages from the test if the test host exited unexpectedly // before communication was established. - ThrowOnTestHostExited(_testHostExited.IsSet); + ThrowOnTestHostExited(sources, _testHostExited.IsSet); // Throw a test platform exception stating the connection to test could not be established even after waiting // for the configure timeout period. - ThrowExceptionOnConnectionFailure(connTimeout); + ThrowExceptionOnConnectionFailure(sources, connTimeout); } // Handling special case for dotnet core projects with older test hosts. @@ -459,17 +459,17 @@ private void TestHostManagerHostExited(object? sender, HostProviderEventArgs? e) RequestSender.OnClientProcessExit(_testHostProcessStdError); } - private void ThrowOnTestHostExited(bool testHostExited) + private void ThrowOnTestHostExited(IEnumerable sources, bool testHostExited) { if (testHostExited) { // We might consider passing standard output here in case standard error is not // available because some errors don't end up in the standard error output. - throw new TestPlatformException(string.Format(CrossPlatEngineResources.TestHostExitedWithError, _testHostProcessStdError)); + throw new TestPlatformException(string.Format(CrossPlatEngineResources.TestHostExitedWithError, string.Join(", ", sources), _testHostProcessStdError)); } } - private void ThrowExceptionOnConnectionFailure(int connTimeout) + private void ThrowExceptionOnConnectionFailure(IEnumerable sources, int connTimeout) { // Failed to launch testhost process. var errorMsg = CrossPlatEngineResources.InitializationFailed; @@ -489,7 +489,7 @@ private void ThrowExceptionOnConnectionFailure(int connTimeout) if (!StringUtils.IsNullOrWhiteSpace(_testHostProcessStdError)) { // Testhost failed with error. - errorMsg = string.Format(CrossPlatEngineResources.TestHostExitedWithError, _testHostProcessStdError); + errorMsg = string.Format(CrossPlatEngineResources.TestHostExitedWithError, string.Join(", ", sources), _testHostProcessStdError); } throw new TestPlatformException(string.Format(CultureInfo.CurrentUICulture, errorMsg)); diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs index 847038f2b9..52968b2632 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs @@ -11,7 +11,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources { using System; using System.Reflection; - + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -367,7 +367,7 @@ internal static string TesthostDiagLogOutputFile { } /// - /// Looks up a localized string similar to Testhost process exited with error: {0}. Please check the diagnostic logs for more information.. + /// Looks up a localized string similar to Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information.. /// internal static string TestHostExitedWithError { get { diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.resx b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.resx index ebbda678c9..a7028987fe 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.resx +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.resx @@ -169,7 +169,8 @@ Logging TestHost Diagnostics in file: {0} - Testhost process exited with error: {0}. Please check the diagnostic logs for more information. + Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + {0} a source, or very rarely list of sources, {1} the output error. No test is available in {0}. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again. diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs index 2e8ceb1b88..155db28c54 100644 --- a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs +++ b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs @@ -610,9 +610,7 @@ public bool CanExecuteCurrentRunConfiguration(string? runsettingsXml) var config = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettingsXml); var framework = config.TargetFramework; - // This is expected to be called once every run so returning a new instance every time. - return framework!.Name.IndexOf("netstandard", StringComparison.OrdinalIgnoreCase) >= 0 - || framework.Name.IndexOf("netcoreapp", StringComparison.OrdinalIgnoreCase) >= 0 + return framework!.Name.IndexOf("netcoreapp", StringComparison.OrdinalIgnoreCase) >= 0 || framework.Name.IndexOf("net5", StringComparison.OrdinalIgnoreCase) >= 0; } diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs index 27f56d9d5f..ef3f45280d 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs @@ -308,7 +308,7 @@ public void SetupChannelShouldThrowExceptionIfTestHostExitedBeforeConnectionIsEs _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(true)).Callback(() => _mockTestHostManager.Raise(t => t.HostExited += null, new HostProviderEventArgs("I crashed!"))); - Assert.AreEqual(string.Format(CrossPlatEngineResources.Resources.TestHostExitedWithError, "I crashed!"), Assert.ThrowsException(() => _testExecutionManager.SetupChannel(new List { "source.dll" }, runsettings)).Message); + Assert.AreEqual(string.Format(CrossPlatEngineResources.Resources.TestHostExitedWithError, "source.dll", "I crashed!"), Assert.ThrowsException(() => _testExecutionManager.SetupChannel(new List { "source.dll" }, runsettings)).Message); } [TestMethod] From 325dcb12de13619b65c4b42644cf7b6d7de0159d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Fri, 19 Aug 2022 11:51:11 +0200 Subject: [PATCH 4/7] Fix --- .../AdapterUtilitiesPlayground.csproj | 32 +++++ .../FindMethodExtensions.cs | 101 +++++++++++++++ .../AdapterUtilitiesPlayground/Program.cs | 55 ++++++++ .../AdapterUtilitiesPlayground/TestClasses.cs | 117 ++++++++++++++++++ playground/TestPlatform.Playground/Program.cs | 2 +- .../TestPlatform.Playground.csproj | 2 +- .../Resources/xlf/Resources.cs.xlf | 6 +- .../Resources/xlf/Resources.de.xlf | 6 +- .../Resources/xlf/Resources.es.xlf | 6 +- .../Resources/xlf/Resources.fr.xlf | 6 +- .../Resources/xlf/Resources.it.xlf | 6 +- .../Resources/xlf/Resources.ja.xlf | 6 +- .../Resources/xlf/Resources.ko.xlf | 6 +- .../Resources/xlf/Resources.pl.xlf | 6 +- .../Resources/xlf/Resources.pt-BR.xlf | 6 +- .../Resources/xlf/Resources.ru.xlf | 6 +- .../Resources/xlf/Resources.tr.xlf | 6 +- .../Resources/xlf/Resources.xlf | 4 +- .../Resources/xlf/Resources.zh-Hans.xlf | 6 +- .../Resources/xlf/Resources.zh-Hant.xlf | 6 +- 20 files changed, 348 insertions(+), 43 deletions(-) create mode 100644 playground/AdapterUtilitiesPlayground/AdapterUtilitiesPlayground.csproj create mode 100644 playground/AdapterUtilitiesPlayground/FindMethodExtensions.cs create mode 100644 playground/AdapterUtilitiesPlayground/Program.cs create mode 100644 playground/AdapterUtilitiesPlayground/TestClasses.cs diff --git a/playground/AdapterUtilitiesPlayground/AdapterUtilitiesPlayground.csproj b/playground/AdapterUtilitiesPlayground/AdapterUtilitiesPlayground.csproj new file mode 100644 index 0000000000..83a8efa2f2 --- /dev/null +++ b/playground/AdapterUtilitiesPlayground/AdapterUtilitiesPlayground.csproj @@ -0,0 +1,32 @@ + + + ..\..\ + + + + + Exe + net6.0 + enable + enable + true + + + + + + + + + + + + + + + PreserveNewest + + + + + diff --git a/playground/AdapterUtilitiesPlayground/FindMethodExtensions.cs b/playground/AdapterUtilitiesPlayground/FindMethodExtensions.cs new file mode 100644 index 0000000000..ca61906545 --- /dev/null +++ b/playground/AdapterUtilitiesPlayground/FindMethodExtensions.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection; + +using Microsoft.CodeAnalysis; + +namespace Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities.UnitTests; + +[DebuggerStepThrough] +internal static class FindMethodExtensions +{ + private const BindingFlags PrivateBindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; + + internal static MethodInfo? FindMethod(this Type type, string signature) + => type.FindMembers(MemberTypes.Method, PrivateBindingFlags, + (mbr, sig) => mbr.ToString() == (string?)sig, signature).FirstOrDefault() as MethodInfo; + + internal static IMethodSymbol FindMethod( + this INamedTypeSymbol type, + string methodName, + int methodGenericArity = -1, + params ITypeSymbol[] methodParameterTypes) + { + var candidates = GetCandidateMethods(type, methodName); + if (candidates.Any() && !candidates.Skip(1).Any()) + { + return candidates.Single(); + } + + if (methodGenericArity != -1) + { + candidates = candidates.Where(m => m.Arity == methodGenericArity); + if (candidates.Any() && !candidates.Skip(1).Any()) + { + return candidates.Single(); + } + } + + if (methodParameterTypes != null && methodParameterTypes.Length >= 0) + { + candidates = candidates.Where(m => m.Parameters.Length == methodParameterTypes.Length); + if (candidates.Any() && !candidates.Skip(1).Any()) + { + return candidates.Single(); + } + + candidates = candidates.Where(m => m.Parameters.Select(p => p.Type).SequenceEqual(methodParameterTypes)); + } + + Debug.Assert(candidates.Any() && !candidates.Skip(1).Any()); + return candidates.Single(); + } + + internal static IMethodSymbol FindMethod( + this INamedTypeSymbol type, + string methodName, + int methodGenericArity, + int methodParameterCount, + Func selector) + { + var candidates = GetCandidateMethods(type, methodName); + if (candidates.Any() && !candidates.Skip(1).Any()) + { + return candidates.Single(); + } + + candidates = candidates.Where(m => m.Arity == methodGenericArity); + if (candidates.Any() && !candidates.Skip(1).Any()) + { + return candidates.Single(); + } + + candidates = candidates.Where(m => m.Parameters.Length == methodParameterCount); + if (candidates.Any() && !candidates.Skip(1).Any()) + { + return candidates.Single(); + } + + candidates = candidates.Where(selector); + + Debug.Assert(candidates.Any() && !candidates.Skip(1).Any()); + return candidates.Single(); + } + + private static IEnumerable GetCandidateMethods(INamedTypeSymbol type, string methodName) + { + var candidates = type.GetMembers(methodName).OfType(); + + if (type.BaseType != null && type.BaseType.SpecialType != SpecialType.System_Object) + { + candidates = candidates.Union(GetCandidateMethods(type.BaseType, methodName)); + } + + return candidates; + } +} diff --git a/playground/AdapterUtilitiesPlayground/Program.cs b/playground/AdapterUtilitiesPlayground/Program.cs new file mode 100644 index 0000000000..325e62a4d0 --- /dev/null +++ b/playground/AdapterUtilitiesPlayground/Program.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Reflection; + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities; +using Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities.UnitTests; + +namespace AdapterUtilitiesPlayground; + +internal class Program +{ + private const BindingFlags PrivateBindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; + private static readonly Compilation _compilation = CSharpCompilation.Create( + "Test.dll", + new[] { CSharpSyntaxTree.ParseText(File.ReadAllText("TestClasses.cs")) }, + new[] { MetadataReference.CreateFromFile(typeof(object).Assembly.Location) }); + + static void Main(string[] args) + { + var derivedClass = typeof(TestClasses.DerivedClass); + var baseClass = typeof(TestClasses.BaseClass); + + var derivedMethods = derivedClass.GetMethods(PrivateBindingFlags).ToArray(); + var baseMethods = baseClass.GetMethods(PrivateBindingFlags).ToArray(); + var derivedMethod0 = derivedMethods.Single(i => i.Name == "Method0" && i.DeclaringType == derivedClass); + var derivedbaseMethod0 = derivedMethods.Single(i => i.Name == "Method0" && i.DeclaringType == baseClass); + var baseMethod0 = baseMethods.Single(i => i.Name == "Method0" && i.DeclaringType == baseClass); + + // { + // ManagedNameHelper.GetManagedName(derivedMethod0, out var managedType, out var managedMethod, out var hierarchies); + // var methodBase = ManagedNameHelper.GetMethod(derivedClass.Assembly, managedType, managedMethod); + // } + // + // { + // ManagedNameHelper.GetManagedName(derivedbaseMethod0, out var managedType, out var managedMethod, out var hierarchies); + // var methodBase = ManagedNameHelper.GetMethod(derivedClass.Assembly, managedType, managedMethod); + // } + + //{ + // ManagedNameHelper.GetManagedName(baseMethod0, out var managedType, out var managedMethod, out var hierarchies); + // var methodBase = ManagedNameHelper.GetMethod(derivedClass.Assembly, managedType, managedMethod); + //} + + { + var method = typeof(TestClasses.IImplementation).GetMethods(PrivateBindingFlags).SingleOrDefault(i => i.Name == "ImplMethod2")!; + method = method.MakeGenericMethod(typeof(int)); + + ManagedNameHelper.GetManagedName(method, out var managedType, out var managedMethod, out var hierarchies); + var methodBase = ManagedNameHelper.GetMethod(derivedClass.Assembly, managedType, managedMethod); + } + } +} diff --git a/playground/AdapterUtilitiesPlayground/TestClasses.cs b/playground/AdapterUtilitiesPlayground/TestClasses.cs new file mode 100644 index 0000000000..0e320efe49 --- /dev/null +++ b/playground/AdapterUtilitiesPlayground/TestClasses.cs @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; + +namespace TestClasses; + +#pragma warning disable IDE0060 // Remove unused parameter +#pragma warning disable CA1822 // Mark members as static + +internal class DerivedClass : BaseClass +{ + public new void Method0(int i) { } +} + +internal class BaseClass +{ + public void Method0(int i) { } + public void Method1(int i) { } +} + +internal class Outer +{ + public void Method0() { } + public void Method1(int i) { } + public void Method2(List ls) { } + public void Method3(string p, int l) { } + internal class Inner + { + public void Method0() { } + public void Method1(int i) { } + public void Method2(int i) { } + public void Method3(int i) { } + } +} + +internal class OuterPrime : Outer { } + +internal class Outer +{ + public void Method0() { } + public void Method1(T t) { } + public void Method2(U[] u) { } + public void Method3(T t, U u) { } + + internal class Inner + { + public void Method0() { } + public void Method1(T t) { } + public void Method2(V v) { } + public void Method3(T t, U u, V v) { } + public void Method4(X x, U u) { } + public void Method5(List x, U u) { } + + internal class MoreInner + { + public void Method0(T t, V v, I i, U u) { } + } + } +} + +internal class OuterPrime : Outer { } + +internal class OuterPrime : Outer { } + +internal class OuterString : Outer { } + +internal interface IImplementation +{ + void ImplMethod0(); + void ImplMethod1(int i); +} + +internal class Impl : IImplementation +{ + void IImplementation.ImplMethod0() { } + void IImplementation.ImplMethod1(int i) { } +} + +internal interface IImplementation +{ + void ImplMethod0(); + void ImplMethod1(T t); + void ImplMethod2(T t, U u, string s); +} + +internal class Impl : IImplementation +{ + void IImplementation.ImplMethod0() { } + void IImplementation.ImplMethod1(T t) { } + void IImplementation.ImplMethod2(T t, U u, string s) { } +} + +internal class Overloads +{ + public void Overload0() { } + public void Overload0(int i) { } + public void Overload0(int i, Overloads c) { } + public unsafe void Overload0(int* p) { } + public void Overload0(dynamic d) { } + public void Overload0(U u) { } + public void Overload0() { } + public void Overload0() { } + public void Overload0(U[] u) { } + public void Overload0(U[][] u) { } + public void Overload0(U[,] u) { } + public void Overload0(U[,,] u) { } + public void Overload0(List l) { } + public void Overload0(List l) { } + public void Overload0(Tuple t0, Tuple t1) { } + public void Overload0(Tuple> t0) { } + public void Overload0(Tuple, Tuple> t) { } + public void Overload0(Tuple.Inner>> t) { } +} +#pragma warning restore IDE0060 // Remove unused parameter +#pragma warning restore CA1822 // Mark members as static diff --git a/playground/TestPlatform.Playground/Program.cs b/playground/TestPlatform.Playground/Program.cs index 0732a347c8..4026e65d0e 100644 --- a/playground/TestPlatform.Playground/Program.cs +++ b/playground/TestPlatform.Playground/Program.cs @@ -20,7 +20,7 @@ namespace TestPlatform.Playground; internal class Program { - static void Main(string[] args) + static void Main() { // This project references TranslationLayer, vstest.console, TestHostProvider, testhost and MSTest1 projects, to make sure // we build all the dependencies of that are used to run tests via VSTestConsoleWrapper. It then copies the components from diff --git a/playground/TestPlatform.Playground/TestPlatform.Playground.csproj b/playground/TestPlatform.Playground/TestPlatform.Playground.csproj index 2814dca8ca..ea5ece9750 100644 --- a/playground/TestPlatform.Playground/TestPlatform.Playground.csproj +++ b/playground/TestPlatform.Playground/TestPlatform.Playground.csproj @@ -36,7 +36,7 @@ - + diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf index ef003db9e6..782039a686 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf @@ -78,9 +78,9 @@ - Testhost process exited with error: {0}. Please check the diagnostic logs for more information. - Proces testhost se ukončil s chybou: {0}. Další informace najdete v diagnostických protokolech. - + Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Proces testhost se ukončil s chybou: {0}. Další informace najdete v diagnostických protokolech. + {0} a source, or very rarely list of sources, {1} the output error. DataCollector debugging is enabled. Please attach debugger to datacollector process to continue. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf index 1de50e46ec..ef6e202ac5 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf @@ -78,9 +78,9 @@ - Testhost process exited with error: {0}. Please check the diagnostic logs for more information. - Der TestHost-Prozess wurde mit folgendem Fehler beendet: {0}. Weitere Informationen finden Sie in den Diagnoseprotokollen. - + Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Der TestHost-Prozess wurde mit folgendem Fehler beendet: {0}. Weitere Informationen finden Sie in den Diagnoseprotokollen. + {0} a source, or very rarely list of sources, {1} the output error. DataCollector debugging is enabled. Please attach debugger to datacollector process to continue. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.es.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.es.xlf index 3294360d20..27d18927d1 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.es.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.es.xlf @@ -78,9 +78,9 @@ - Testhost process exited with error: {0}. Please check the diagnostic logs for more information. - El proceso del host de prueba finalizó con el siguiente error: {0}. Consulte los registros de diagnóstico para obtener más información. - + Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + El proceso del host de prueba finalizó con el siguiente error: {0}. Consulte los registros de diagnóstico para obtener más información. + {0} a source, or very rarely list of sources, {1} the output error. DataCollector debugging is enabled. Please attach debugger to datacollector process to continue. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.fr.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.fr.xlf index bddc3970be..6665c5f321 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.fr.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.fr.xlf @@ -78,9 +78,9 @@ - Testhost process exited with error: {0}. Please check the diagnostic logs for more information. - Le processus Testhost s'est arrêté. Erreur : {0}. Pour plus d'informations, consultez les journaux de diagnostic. - + Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Le processus Testhost s'est arrêté. Erreur : {0}. Pour plus d'informations, consultez les journaux de diagnostic. + {0} a source, or very rarely list of sources, {1} the output error. DataCollector debugging is enabled. Please attach debugger to datacollector process to continue. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.it.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.it.xlf index 31444efa09..511d57813b 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.it.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.it.xlf @@ -78,9 +78,9 @@ - Testhost process exited with error: {0}. Please check the diagnostic logs for more information. - Il processo testhost è terminato con l'errore {0}. Per altre informazioni, vedere i log di diagnostica. - + Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Il processo testhost è terminato con l'errore {0}. Per altre informazioni, vedere i log di diagnostica. + {0} a source, or very rarely list of sources, {1} the output error. DataCollector debugging is enabled. Please attach debugger to datacollector process to continue. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ja.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ja.xlf index 62677da394..0c19dc36b7 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ja.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ja.xlf @@ -78,9 +78,9 @@ - Testhost process exited with error: {0}. Please check the diagnostic logs for more information. - Testhost プロセスがエラーで終了しました: {0}。詳細については、診断ログを確認してください。 - + Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Testhost プロセスがエラーで終了しました: {0}。詳細については、診断ログを確認してください。 + {0} a source, or very rarely list of sources, {1} the output error. DataCollector debugging is enabled. Please attach debugger to datacollector process to continue. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ko.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ko.xlf index 20da27db90..8dfce2a8d2 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ko.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ko.xlf @@ -78,9 +78,9 @@ - Testhost process exited with error: {0}. Please check the diagnostic logs for more information. - Testhost 프로세스가 종료되었습니다(오류: {0}). 자세한 내용은 진단 로그를 확인하세요. - + Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Testhost 프로세스가 종료되었습니다(오류: {0}). 자세한 내용은 진단 로그를 확인하세요. + {0} a source, or very rarely list of sources, {1} the output error. DataCollector debugging is enabled. Please attach debugger to datacollector process to continue. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pl.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pl.xlf index e10930a19e..ddb60f40ee 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pl.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pl.xlf @@ -78,9 +78,9 @@ - Testhost process exited with error: {0}. Please check the diagnostic logs for more information. - Zakończono proces testhost z powodu błędu: {0}. Sprawdź dzienniki diagnostyczne, aby uzyskać więcej informacji. - + Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Zakończono proces testhost z powodu błędu: {0}. Sprawdź dzienniki diagnostyczne, aby uzyskać więcej informacji. + {0} a source, or very rarely list of sources, {1} the output error. DataCollector debugging is enabled. Please attach debugger to datacollector process to continue. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pt-BR.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pt-BR.xlf index fdd1b9eb20..66c803c7fa 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pt-BR.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pt-BR.xlf @@ -78,9 +78,9 @@ - Testhost process exited with error: {0}. Please check the diagnostic logs for more information. - O processo do testhost foi encerrado com o erro: {0}. Verifique os logs de diagnóstico para obter mais informações. - + Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + O processo do testhost foi encerrado com o erro: {0}. Verifique os logs de diagnóstico para obter mais informações. + {0} a source, or very rarely list of sources, {1} the output error. DataCollector debugging is enabled. Please attach debugger to datacollector process to continue. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ru.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ru.xlf index 3aa17963b3..67bb2c7bc8 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ru.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ru.xlf @@ -78,9 +78,9 @@ - Testhost process exited with error: {0}. Please check the diagnostic logs for more information. - Процесс testhost завершился с ошибкой: {0}. Дополнительные сведения см. в журналах диагностики. - + Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Процесс testhost завершился с ошибкой: {0}. Дополнительные сведения см. в журналах диагностики. + {0} a source, or very rarely list of sources, {1} the output error. DataCollector debugging is enabled. Please attach debugger to datacollector process to continue. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.tr.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.tr.xlf index 1262914f1a..d8587e10e2 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.tr.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.tr.xlf @@ -78,9 +78,9 @@ - Testhost process exited with error: {0}. Please check the diagnostic logs for more information. - Testhost işleminden şu hatayla çıkıldı: {0}. Daha fazla bilgi için lütfen tanılama günlüklerine bakın. - + Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Testhost işleminden şu hatayla çıkıldı: {0}. Daha fazla bilgi için lütfen tanılama günlüklerine bakın. + {0} a source, or very rarely list of sources, {1} the output error. DataCollector debugging is enabled. Please attach debugger to datacollector process to continue. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.xlf index 2cd35c2e0b..e7a01a628f 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.xlf @@ -64,9 +64,9 @@ - Testhost process exited with error: {0}. Please check the diagnostic logs for more information. + Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. Testhost process exited with error: {0} - + {0} a source, or very rarely list of sources, {1} the output error. DataCollector debugging is enabled. Please attach debugger to datacollector process to continue. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hans.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hans.xlf index b212fe2408..0ae9356824 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hans.xlf @@ -78,9 +78,9 @@ - Testhost process exited with error: {0}. Please check the diagnostic logs for more information. - Testhost 进程已退出,但出现错误: {0}。请查看诊断日志了解详细信息。 - + Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Testhost 进程已退出,但出现错误: {0}。请查看诊断日志了解详细信息。 + {0} a source, or very rarely list of sources, {1} the output error. DataCollector debugging is enabled. Please attach debugger to datacollector process to continue. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hant.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hant.xlf index af27933cae..63553ec03a 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hant.xlf @@ -78,9 +78,9 @@ - Testhost process exited with error: {0}. Please check the diagnostic logs for more information. - Testhost 處理序已結束。錯誤: {0}。如需詳細資訊,請查看診斷記錄。 - + Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Testhost 處理序已結束。錯誤: {0}。如需詳細資訊,請查看診斷記錄。 + {0} a source, or very rarely list of sources, {1} the output error. DataCollector debugging is enabled. Please attach debugger to datacollector process to continue. From 101c2608428e5ca5d965ff3bce23deab2a6c5b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Fri, 19 Aug 2022 11:52:02 +0200 Subject: [PATCH 5/7] mm --- eng/Versions.props | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index aec6aa1cc7..781dd07fc3 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -2,8 +2,8 @@ - 17.3.0 - release + 17.4.0 + preview false true @@ -38,7 +38,7 @@ 4.16.1 5.3.0.1 2.3.0 - 9.0.1 + 13.0.1 4.6.0-preview4.19202.2 4.4.0 5.3.0 @@ -54,7 +54,7 @@ 4.5.1 4.4.0 1.4.2 - 4.5.0 + 5.0.0 4.5.1 4.5.1 4.4.0 @@ -62,8 +62,8 @@ 2.4.1 2.0.3 2.4.1 - 7.0.0-beta.22316.2 - 7.0.0-beta.22316.2 + 7.0.0-beta.22379.10 + 7.0.0-beta.22379.10 1.22.0 1.1.2 2.0.0 @@ -75,15 +75,18 @@ 1.7.0 1.1.0-beta.20074.1 1.0.0-beta2-19554-01 - 7.0.0-beta.22316.2 + 7.0.0-beta.22379.10 1.0.0-beta.21272.1 3.8.0-3.20427.2 - 17.3.6 + 17.4.4-beta.22415.9 0.2.0-preview.21508.1 5.0.0-preview.21508.1 + 16.4.78 + 16.3.44 + 16.3.36 From 2d3193b6ff7dbce21057ecce61bd383a2837ccb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Fri, 19 Aug 2022 14:06:57 +0200 Subject: [PATCH 6/7] Fix build break --- .../Client/ProxyExecutionManagerTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs index 0683bb5d72..38508248d3 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs @@ -309,7 +309,7 @@ public void SetupChannelShouldThrowExceptionIfTestHostExitedBeforeConnectionIsEs _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(true)).Callback(() => _mockTestHostManager.Raise(t => t.HostExited += null, new HostProviderEventArgs("I crashed!"))); - Assert.AreEqual(string.Format(CrossPlatEngineResources.Resources.TestHostExitedWithError, "source.dll", "I crashed!"), Assert.ThrowsException(() => _testExecutionManager.SetupChannel(new List { "source.dll" }, runsettings)).Message); + Assert.AreEqual(string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.Resources.TestHostExitedWithError, "source.dll", "I crashed!"), Assert.ThrowsException(() => _testExecutionManager.SetupChannel(new List { "source.dll" }, runsettings)).Message); } [TestMethod] From 412743ed3b6801ee3d1f867304daf63a010dc58e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Mon, 22 Aug 2022 11:09:13 +0200 Subject: [PATCH 7/7] Update error formatting and add test --- .../Client/ProxyOperationManager.cs | 4 ++-- .../Resources/Resources.Designer.cs | 3 ++- .../Resources/Resources.resx | 2 +- .../Resources/xlf/Resources.cs.xlf | 2 +- .../Resources/xlf/Resources.de.xlf | 2 +- .../Resources/xlf/Resources.es.xlf | 2 +- .../Resources/xlf/Resources.fr.xlf | 2 +- .../Resources/xlf/Resources.it.xlf | 2 +- .../Resources/xlf/Resources.ja.xlf | 2 +- .../Resources/xlf/Resources.ko.xlf | 2 +- .../Resources/xlf/Resources.pl.xlf | 2 +- .../Resources/xlf/Resources.pt-BR.xlf | 2 +- .../Resources/xlf/Resources.ru.xlf | 2 +- .../Resources/xlf/Resources.tr.xlf | 2 +- .../Resources/xlf/Resources.xlf | 2 +- .../Resources/xlf/Resources.zh-Hans.xlf | 2 +- .../Resources/xlf/Resources.zh-Hant.xlf | 2 +- .../Client/ProxyExecutionManagerTests.cs | 13 ++++++++++++- 18 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs index 77adb4122e..55d11267fe 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs @@ -465,7 +465,7 @@ private void ThrowOnTestHostExited(IEnumerable sources, bool testHostExi { // We might consider passing standard output here in case standard error is not // available because some errors don't end up in the standard error output. - throw new TestPlatformException(string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.TestHostExitedWithError, string.Join(", ", sources), _testHostProcessStdError)); + throw new TestPlatformException(string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.TestHostExitedWithError, string.Join("', '", sources), _testHostProcessStdError)); } } @@ -490,7 +490,7 @@ private void ThrowExceptionOnConnectionFailure(IEnumerable sources, int if (!StringUtils.IsNullOrWhiteSpace(_testHostProcessStdError)) { // Testhost failed with error. - errorMsg = string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.TestHostExitedWithError, string.Join(", ", sources), _testHostProcessStdError); + errorMsg = string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.TestHostExitedWithError, string.Join("', '", sources), _testHostProcessStdError); } throw new TestPlatformException(errorMsg); diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs index 52968b2632..2502dbc08d 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs @@ -12,6 +12,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources { using System; using System.Reflection; + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -367,7 +368,7 @@ internal static string TesthostDiagLogOutputFile { } /// - /// Looks up a localized string similar to Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information.. + /// Looks up a localized string similar to Testhost process for source(s) '{0}' exited with error: {1}. Please check the diagnostic logs for more information.. /// internal static string TestHostExitedWithError { get { diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.resx b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.resx index a7028987fe..4c4eaa72d5 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.resx +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.resx @@ -169,7 +169,7 @@ Logging TestHost Diagnostics in file: {0} - Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Testhost process for source(s) '{0}' exited with error: {1}. Please check the diagnostic logs for more information. {0} a source, or very rarely list of sources, {1} the output error. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf index 782039a686..7d8278769c 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf @@ -78,7 +78,7 @@ - Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Testhost process for source(s) '{0}' exited with error: {1}. Please check the diagnostic logs for more information. Proces testhost se ukončil s chybou: {0}. Další informace najdete v diagnostických protokolech. {0} a source, or very rarely list of sources, {1} the output error. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf index ef6e202ac5..ded59894c9 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf @@ -78,7 +78,7 @@ - Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Testhost process for source(s) '{0}' exited with error: {1}. Please check the diagnostic logs for more information. Der TestHost-Prozess wurde mit folgendem Fehler beendet: {0}. Weitere Informationen finden Sie in den Diagnoseprotokollen. {0} a source, or very rarely list of sources, {1} the output error. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.es.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.es.xlf index 27d18927d1..776c3d432b 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.es.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.es.xlf @@ -78,7 +78,7 @@ - Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Testhost process for source(s) '{0}' exited with error: {1}. Please check the diagnostic logs for more information. El proceso del host de prueba finalizó con el siguiente error: {0}. Consulte los registros de diagnóstico para obtener más información. {0} a source, or very rarely list of sources, {1} the output error. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.fr.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.fr.xlf index 6665c5f321..004fa43660 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.fr.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.fr.xlf @@ -78,7 +78,7 @@ - Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Testhost process for source(s) '{0}' exited with error: {1}. Please check the diagnostic logs for more information. Le processus Testhost s'est arrêté. Erreur : {0}. Pour plus d'informations, consultez les journaux de diagnostic. {0} a source, or very rarely list of sources, {1} the output error. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.it.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.it.xlf index 511d57813b..be2dcd0ddb 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.it.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.it.xlf @@ -78,7 +78,7 @@ - Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Testhost process for source(s) '{0}' exited with error: {1}. Please check the diagnostic logs for more information. Il processo testhost è terminato con l'errore {0}. Per altre informazioni, vedere i log di diagnostica. {0} a source, or very rarely list of sources, {1} the output error. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ja.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ja.xlf index 0c19dc36b7..55789062e0 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ja.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ja.xlf @@ -78,7 +78,7 @@ - Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Testhost process for source(s) '{0}' exited with error: {1}. Please check the diagnostic logs for more information. Testhost プロセスがエラーで終了しました: {0}。詳細については、診断ログを確認してください。 {0} a source, or very rarely list of sources, {1} the output error. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ko.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ko.xlf index 8dfce2a8d2..aed45d6aaf 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ko.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ko.xlf @@ -78,7 +78,7 @@ - Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Testhost process for source(s) '{0}' exited with error: {1}. Please check the diagnostic logs for more information. Testhost 프로세스가 종료되었습니다(오류: {0}). 자세한 내용은 진단 로그를 확인하세요. {0} a source, or very rarely list of sources, {1} the output error. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pl.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pl.xlf index ddb60f40ee..7da5bf9915 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pl.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pl.xlf @@ -78,7 +78,7 @@ - Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Testhost process for source(s) '{0}' exited with error: {1}. Please check the diagnostic logs for more information. Zakończono proces testhost z powodu błędu: {0}. Sprawdź dzienniki diagnostyczne, aby uzyskać więcej informacji. {0} a source, or very rarely list of sources, {1} the output error. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pt-BR.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pt-BR.xlf index 66c803c7fa..3252c13d16 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pt-BR.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pt-BR.xlf @@ -78,7 +78,7 @@ - Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Testhost process for source(s) '{0}' exited with error: {1}. Please check the diagnostic logs for more information. O processo do testhost foi encerrado com o erro: {0}. Verifique os logs de diagnóstico para obter mais informações. {0} a source, or very rarely list of sources, {1} the output error. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ru.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ru.xlf index 67bb2c7bc8..3787669cf1 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ru.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ru.xlf @@ -78,7 +78,7 @@ - Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Testhost process for source(s) '{0}' exited with error: {1}. Please check the diagnostic logs for more information. Процесс testhost завершился с ошибкой: {0}. Дополнительные сведения см. в журналах диагностики. {0} a source, or very rarely list of sources, {1} the output error. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.tr.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.tr.xlf index d8587e10e2..3568758c06 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.tr.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.tr.xlf @@ -78,7 +78,7 @@ - Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Testhost process for source(s) '{0}' exited with error: {1}. Please check the diagnostic logs for more information. Testhost işleminden şu hatayla çıkıldı: {0}. Daha fazla bilgi için lütfen tanılama günlüklerine bakın. {0} a source, or very rarely list of sources, {1} the output error. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.xlf index e7a01a628f..1d1078a44b 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.xlf @@ -64,7 +64,7 @@ - Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Testhost process for source(s) '{0}' exited with error: {1}. Please check the diagnostic logs for more information. Testhost process exited with error: {0} {0} a source, or very rarely list of sources, {1} the output error. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hans.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hans.xlf index 0ae9356824..2f5e04f447 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hans.xlf @@ -78,7 +78,7 @@ - Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Testhost process for source(s) '{0}' exited with error: {1}. Please check the diagnostic logs for more information. Testhost 进程已退出,但出现错误: {0}。请查看诊断日志了解详细信息。 {0} a source, or very rarely list of sources, {1} the output error. diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hant.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hant.xlf index 63553ec03a..ae7f09aa86 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hant.xlf @@ -78,7 +78,7 @@ - Testhost process for source {0} exited with error: {1}. Please check the diagnostic logs for more information. + Testhost process for source(s) '{0}' exited with error: {1}. Please check the diagnostic logs for more information. Testhost 處理序已結束。錯誤: {0}。如需詳細資訊,請查看診斷記錄。 {0} a source, or very rarely list of sources, {1} the output error. diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs index 38508248d3..aadbcf0a93 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs @@ -302,7 +302,7 @@ public void SetupChannelShouldThrowExceptionIfClientConnectionTimeout() } [TestMethod] - public void SetupChannelShouldThrowExceptionIfTestHostExitedBeforeConnectionIsEstablished() + public void SetupChannelShouldThrowExceptionWithOneSourceIfTestHostExitedBeforeConnectionIsEstablished() { string runsettings = "\r\n\r\n \r\n {0}\r\n \r\n"; @@ -312,6 +312,17 @@ public void SetupChannelShouldThrowExceptionIfTestHostExitedBeforeConnectionIsEs Assert.AreEqual(string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.Resources.TestHostExitedWithError, "source.dll", "I crashed!"), Assert.ThrowsException(() => _testExecutionManager.SetupChannel(new List { "source.dll" }, runsettings)).Message); } + [TestMethod] + public void SetupChannelShouldThrowExceptionWithAllSourcesIfTestHostExitedBeforeConnectionIsEstablished() + { + string runsettings = "\r\n\r\n \r\n {0}\r\n \r\n"; + + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(true)).Callback(() => _mockTestHostManager.Raise(t => t.HostExited += null, new HostProviderEventArgs("I crashed!"))); + + Assert.AreEqual(string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.Resources.TestHostExitedWithError, string.Join("', '", new[] { "source1.dll", "source2.dll" }), "I crashed!"), Assert.ThrowsException(() => _testExecutionManager.SetupChannel(new List { "source1.dll", "source2.dll" }, runsettings)).Message); + } + [TestMethod] public void StartTestRunShouldCatchExceptionAndCallHandleTestRunComplete() {