C#: Exclude not existing or problematic files from extraction

This commit is contained in:
Tamas Vajk
2023-12-18 14:10:56 +01:00
parent 1a8857dab8
commit b14d26ab62

View File

@@ -439,6 +439,25 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
files = files.Where(f => !f.FullName.StartsWith(options.DotNetPath, StringComparison.OrdinalIgnoreCase));
}
files = files.Where(f =>
{
try
{
if (f.Exists)
{
return true;
}
progressMonitor.Log(Severity.Warning, $"File {f.FullName} could not be processed.");
return false;
}
catch (Exception ex)
{
progressMonitor.Log(Severity.Warning, $"File {f.FullName} could not be processed: {ex.Message}");
return false;
}
});
files = new FilePathFilter(sourceDir, progressMonitor).Filter(files);
return files;
}