Skip to content

Commit b14d26a

Browse files
committed
C#: Exclude not existing or problematic files from extraction
1 parent 1a8857d commit b14d26a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,25 @@ private IEnumerable<FileInfo> GetAllFiles()
439439
files = files.Where(f => !f.FullName.StartsWith(options.DotNetPath, StringComparison.OrdinalIgnoreCase));
440440
}
441441

442+
files = files.Where(f =>
443+
{
444+
try
445+
{
446+
if (f.Exists)
447+
{
448+
return true;
449+
}
450+
451+
progressMonitor.Log(Severity.Warning, $"File {f.FullName} could not be processed.");
452+
return false;
453+
}
454+
catch (Exception ex)
455+
{
456+
progressMonitor.Log(Severity.Warning, $"File {f.FullName} could not be processed: {ex.Message}");
457+
return false;
458+
}
459+
});
460+
442461
files = new FilePathFilter(sourceDir, progressMonitor).Filter(files);
443462
return files;
444463
}

0 commit comments

Comments
 (0)