@@ -10,7 +10,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
1010 /// Used to represent a path to an assembly or a directory containing assemblies
1111 /// and a selector function to determine which files to include, when indexing the assemblies.
1212 /// </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 )
1414 {
1515 public string Path => p ;
1616
@@ -26,23 +26,30 @@ public AssemblyLookupLocation(string p) : this(p, _ => true) { }
2626 /// <param name="dir">The directory to index.</param>
2727 private void AddReferenceDirectory ( List < string > dllsToIndex , ILogger logger )
2828 {
29- var dlls = new DirectoryInfo ( p ) . EnumerateFiles ( "*.dll" , new EnumerationOptions { RecurseSubdirectories = true , MatchCasing = MatchCasing . CaseInsensitive , AttributesToSkip = FileAttributes . None } ) ;
30- if ( ! dlls . Any ( ) )
29+ try
3130 {
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 ( ) )
3833 {
39- dllsToIndex . Add ( dll . FullName ) ;
34+ logger . LogWarning ( $ "AssemblyLookupLocation: No DLLs found in the path '{ p } '.") ;
35+ return ;
4036 }
41- else
37+ foreach ( var dll in dlls )
4238 {
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+ }
4447 }
4548 }
49+ catch ( Exception e )
50+ {
51+ logger . LogError ( $ "AssemblyLookupLocation: Error while searching for DLLs in '{ p } ': { e . Message } ") ;
52+ }
4653 }
4754
4855 /// <summary>
0 commit comments