Skip to content

Commit 99f0ed2

Browse files
committed
C#: Make the assembly lookup case insensitive on the dll file extension and log if no dlls are found in a directory.
1 parent 9eb1383 commit 99f0ed2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/AssemblyLookupLocation.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4+
using System.Linq;
45
using Semmle.Util.Logging;
56

67
namespace Semmle.Extraction.CSharp.DependencyFetching
@@ -25,7 +26,13 @@ public AssemblyLookupLocation(string p) : this(p, _ => true) { }
2526
/// <param name="dir">The directory to index.</param>
2627
private void AddReferenceDirectory(List<string> dllsToIndex, ILogger logger)
2728
{
28-
foreach (var dll in new DirectoryInfo(p).EnumerateFiles("*.dll", SearchOption.AllDirectories))
29+
var dlls = new DirectoryInfo(p).EnumerateFiles("*.dll", new EnumerationOptions { RecurseSubdirectories = true, MatchCasing = MatchCasing.CaseInsensitive, AttributesToSkip = FileAttributes.None });
30+
if (!dlls.Any())
31+
{
32+
logger.LogWarning($"AssemblyLookupLocation: No DLLs found in the path '{p}'.");
33+
return;
34+
}
35+
foreach (var dll in dlls)
2936
{
3037
if (includeFileName(dll.Name))
3138
{

0 commit comments

Comments
 (0)