C#: Only use small files during file content reference analysis.

This commit is contained in:
Michael Nebel 2023-08-24 19:16:11 +02:00
Родитель a81d982c90
Коммит 61a523510e
2 изменённых файлов: 17 добавлений и 2 удалений

Просмотреть файл

@ -60,7 +60,8 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
packageDirectory = new TemporaryDirectory(ComputeTempDirectory(sourceDir.FullName));
var allFiles = GetFiles("*.*").ToList();
this.fileContent = new FileContent(progressMonitor, GetFileNames(allFiles));
var smallFiles = GetSmallFiles(allFiles);
this.fileContent = new FileContent(progressMonitor, GetFileNames(smallFiles));
this.allSources = GetFileNames(allFiles, ".cs").ToList();
var allProjects = GetFileNames(allFiles, ".csproj");
var solutions = options.SolutionFile is not null
@ -194,6 +195,20 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
private static IEnumerable<string> GetFileNames(IEnumerable<FileInfo> files, params string[] extensions) =>
files.Where(fi => !extensions.Any() || extensions.Contains(fi.Extension)).Select(fi => fi.FullName);
private IEnumerable<FileInfo> GetSmallFiles(IEnumerable<FileInfo> files)
{
const int oneMb = 1_048_576;
return files.Where(file =>
{
if (file.Length > oneMb)
{
progressMonitor.LogDebug($"Skipping {file.FullName} because it is bigger than 1MB.");
return false;
}
return true;
});
}
/// <summary>
/// Computes a unique temp directory for the packages associated
/// with this source tree. Use a SHA1 of the directory name.

Просмотреть файл

@ -18,7 +18,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
public void LogInfo(string message) =>
logger.Log(Severity.Info, message);
private void LogDebug(string message) =>
public void LogDebug(string message) =>
logger.Log(Severity.Debug, message);
private void LogError(string message) =>