diff --git a/GoogleTestAdapter/Core/GoogleTestConstants.cs b/GoogleTestAdapter/Core/GoogleTestConstants.cs index 312a0c276..9b5b42ff1 100644 --- a/GoogleTestAdapter/Core/GoogleTestConstants.cs +++ b/GoogleTestAdapter/Core/GoogleTestConstants.cs @@ -1,4 +1,4 @@ -// This file has been modified by Microsoft on 5/2018. +// This file has been modified by Microsoft on 4/2020. using System; @@ -32,6 +32,9 @@ public static class GoogleTestConstants public const string TypedTestMarker = ". # TypeParam = "; public const string GoogleTestDllMarker = "gtest.dll"; + public const string GoogleTestDllMarkerDebug = "gtestd.dll"; + public const string GoogleTestMainDllMarker = "gtest_main.dll"; + public const string GoogleTestMainDllMarkerDebug = "gtest_maind.dll"; public static readonly string[] GoogleTestExecutableMarkers = { diff --git a/GoogleTestAdapter/Core/GoogleTestDiscoverer.cs b/GoogleTestAdapter/Core/GoogleTestDiscoverer.cs index 398eb5149..3f9f24355 100644 --- a/GoogleTestAdapter/Core/GoogleTestDiscoverer.cs +++ b/GoogleTestAdapter/Core/GoogleTestDiscoverer.cs @@ -1,4 +1,4 @@ -// This file has been modified by Microsoft on 9/2017. +// This file has been modified by Microsoft on 4/2020. using GoogleTestAdapter.Common; using GoogleTestAdapter.DiaResolver; @@ -104,7 +104,10 @@ public static bool IsGoogleTestExecutable(string executable, string customRegex, if (string.IsNullOrWhiteSpace(customRegex)) { - if (PeParser.FindImport(executable, GoogleTestConstants.GoogleTestDllMarker, StringComparison.OrdinalIgnoreCase, logger) + List gtestImports = new List() { GoogleTestConstants.GoogleTestDllMarker, GoogleTestConstants.GoogleTestDllMarkerDebug, + GoogleTestConstants.GoogleTestMainDllMarker, GoogleTestConstants.GoogleTestMainDllMarkerDebug }; + + if (PeParser.FindImport(executable, gtestImports, StringComparison.OrdinalIgnoreCase, logger) || Utils.BinaryFileContainsStrings(executable, Encoding.ASCII, GoogleTestConstants.GoogleTestExecutableMarkers)) { return true; diff --git a/GoogleTestAdapter/DiaResolver/PeParser.cs b/GoogleTestAdapter/DiaResolver/PeParser.cs index ac8256fa4..75988e3d9 100644 --- a/GoogleTestAdapter/DiaResolver/PeParser.cs +++ b/GoogleTestAdapter/DiaResolver/PeParser.cs @@ -1,4 +1,4 @@ -// This file has been modified by Microsoft on 11/2017. +// This file has been modified by Microsoft on 4/2020. using GoogleTestAdapter.Common; using Microsoft.Win32.SafeHandles; @@ -277,12 +277,14 @@ public static List ParseImports(string executable, ILogger logger) return imports; } - public static bool FindImport(string executable, string import, StringComparison comparisonType, ILogger logger) + public static bool FindImport(string executable, List imports, StringComparison comparisonType, ILogger logger) { var found = false; ProcessImports(executable, logger, (currentImport) => { - found = String.Compare(import, currentImport, comparisonType) == 0; + foreach (var import in imports) + found = found || String.Compare(import, currentImport, comparisonType) == 0; + return !found; // Continue only if not found yet. }); return found;