@@ -10,7 +10,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
10
10
/// Used to represent a path to an assembly or a directory containing assemblies
11
11
/// and a selector function to determine which files to include, when indexing the assemblies.
12
12
/// </summary>
13
- internal sealed class AssemblyLookupLocation ( string p , Func < string , bool > includeFileName )
13
+ internal sealed class AssemblyLookupLocation ( string p , Func < string , bool > includeFileName , bool indexSubdirectories = true )
14
14
{
15
15
public string Path => p ;
16
16
@@ -26,23 +26,30 @@ public AssemblyLookupLocation(string p) : this(p, _ => true) { }
26
26
/// <param name="dir">The directory to index.</param>
27
27
private void AddReferenceDirectory ( List < string > dllsToIndex , ILogger logger )
28
28
{
29
- var dlls = new DirectoryInfo ( p ) . EnumerateFiles ( "*.dll" , new EnumerationOptions { RecurseSubdirectories = true , MatchCasing = MatchCasing . CaseInsensitive , AttributesToSkip = FileAttributes . None } ) ;
30
- if ( ! dlls . Any ( ) )
29
+ try
31
30
{
32
- logger . LogWarning ( $ "AssemblyLookupLocation: No DLLs found in the path '{ p } '.") ;
33
- return ;
34
- }
35
- foreach ( var dll in dlls )
36
- {
37
- if ( includeFileName ( dll . Name ) )
31
+ var dlls = new DirectoryInfo ( p ) . EnumerateFiles ( "*.dll" , new EnumerationOptions { RecurseSubdirectories = indexSubdirectories , MatchCasing = MatchCasing . CaseInsensitive , AttributesToSkip = FileAttributes . None } ) ;
32
+ if ( ! dlls . Any ( ) )
38
33
{
39
- dllsToIndex . Add ( dll . FullName ) ;
34
+ logger . LogWarning ( $ "AssemblyLookupLocation: No DLLs found in the path '{ p } '.") ;
35
+ return ;
40
36
}
41
- else
37
+ foreach ( var dll in dlls )
42
38
{
43
- logger . LogInfo ( $ "AssemblyLookupLocation: Skipping { dll . FullName } .") ;
39
+ if ( includeFileName ( dll . Name ) )
40
+ {
41
+ dllsToIndex . Add ( dll . FullName ) ;
42
+ }
43
+ else
44
+ {
45
+ logger . LogInfo ( $ "AssemblyLookupLocation: Skipping { dll . FullName } .") ;
46
+ }
44
47
}
45
48
}
49
+ catch ( Exception e )
50
+ {
51
+ logger . LogError ( $ "AssemblyLookupLocation: Error while searching for DLLs in '{ p } ': { e . Message } ") ;
52
+ }
46
53
}
47
54
48
55
/// <summary>
0 commit comments