diff --git a/src/coverlet.core/Helpers/InstrumentationHelper.cs b/src/coverlet.core/Helpers/InstrumentationHelper.cs index f870ef042..025041a47 100644 --- a/src/coverlet.core/Helpers/InstrumentationHelper.cs +++ b/src/coverlet.core/Helpers/InstrumentationHelper.cs @@ -15,7 +15,7 @@ internal static class InstrumentationHelper { public static string[] GetCoverableModules(string module) { - IEnumerable modules = Directory.GetFiles(Path.GetDirectoryName(module), "*.dll"); + IEnumerable modules = Directory.EnumerateFiles(Path.GetDirectoryName(module)).Where(f => f.EndsWith(".exe") || f.EndsWith(".dll")); modules = modules.Where(m => IsAssembly(m) && Path.GetFileName(m) != Path.GetFileName(module)); return modules.ToArray(); } diff --git a/test/coverlet.core.tests/Helpers/InstrumentationHelperTests.cs b/test/coverlet.core.tests/Helpers/InstrumentationHelperTests.cs index a41c4646c..f88b35037 100644 --- a/test/coverlet.core.tests/Helpers/InstrumentationHelperTests.cs +++ b/test/coverlet.core.tests/Helpers/InstrumentationHelperTests.cs @@ -1,6 +1,5 @@ using System; using System.IO; - using Xunit; using System.Collections.Generic; using System.Linq; @@ -17,6 +16,21 @@ public void TestGetDependencies() Assert.False(Array.Exists(modules, m => m == module)); } + [Fact] + public void TestExeModulesCoverage() + { + string module = typeof(InstrumentationHelperTests).Assembly.Location; + string exeModule = Path.ChangeExtension(module, ".exe"); + string noExtModule = Path.ChangeExtension(module, "").TrimEnd('.'); + File.Delete(exeModule); + File.Copy(module, exeModule); + File.Delete(noExtModule); + File.Copy(module, noExtModule); + var modules = InstrumentationHelper.GetCoverableModules(module); + Assert.True(Array.Exists(modules, m => m == exeModule)); + Assert.False(Array.Exists(modules, m => m == noExtModule)); + } + [Fact] public void TestHasPdb() {