@@ -14,11 +14,24 @@ namespace Coverlet.Core.Helpers
14
14
{
15
15
internal static class InstrumentationHelper
16
16
{
17
- public static string [ ] GetCoverableModules ( string module )
17
+ public static string [ ] GetCoverableModules ( string module , string [ ] moduleDirs )
18
18
{
19
- IEnumerable < string > modules = Directory . EnumerateFiles ( Path . GetDirectoryName ( module ) ) . Where ( f => f . EndsWith ( ".exe" ) || f . EndsWith ( ".dll" ) ) ;
20
- modules = modules . Where ( m => IsAssembly ( m ) && Path . GetFileName ( m ) != Path . GetFileName ( module ) ) ;
21
- return modules . ToArray ( ) ;
19
+ // Prepare all the directories in which we probe for modules.
20
+ string [ ] dirs = new string [ moduleDirs . Length + 1 ] ;
21
+ moduleDirs . CopyTo ( dirs , 0 ) ;
22
+ // Add the test assembly's directory.
23
+ dirs [ dirs . Length - 1 ] = Path . GetDirectoryName ( module ) ;
24
+
25
+ // The test module's name must be unique.
26
+ var uniqueModules = new HashSet < string >
27
+ {
28
+ Path . GetFileName ( module )
29
+ } ;
30
+
31
+ return dirs . SelectMany ( d => Directory . EnumerateFiles ( d ) )
32
+ . Where ( f => f . EndsWith ( ".exe" ) || f . EndsWith ( ".dll" ) )
33
+ . Where ( m => IsAssembly ( m ) && uniqueModules . Add ( Path . GetFileName ( m ) ) )
34
+ . ToArray ( ) ;
22
35
}
23
36
24
37
public static bool HasPdb ( string module )
@@ -43,7 +56,7 @@ public static bool HasPdb(string module)
43
56
public static void BackupOriginalModule ( string module , string identifier )
44
57
{
45
58
var backupPath = GetBackupPath ( module , identifier ) ;
46
- File . Copy ( module , backupPath ) ;
59
+ File . Copy ( module , backupPath , true ) ;
47
60
}
48
61
49
62
public static void RestoreOriginalModule ( string module , string identifier )
0 commit comments