Merge pull request #14311 from hvitved/csharp/dependency-manager-generated-files

C#: Expose generated files in `DependencyManager`
This commit is contained in:
Tom Hvitved 2023-09-26 08:15:32 +02:00 коммит произвёл GitHub
Родитель 7c230d61a8 a045e6b029
Коммит 5adacb8477
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 12 добавлений и 5 удалений

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

@ -23,7 +23,8 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
private readonly IDictionary<string, string> unresolvedReferences = new ConcurrentDictionary<string, string>();
private int failedProjects;
private int succeededProjects;
private readonly List<string> allSources;
private readonly List<string> nonGeneratedSources;
private readonly List<string> generatedSources;
private int conflictedReferences = 0;
private readonly IDependencyOptions options;
private readonly DirectoryInfo sourceDir;
@ -65,7 +66,8 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
var allNonBinaryFiles = allFiles.Where(f => !binaryFileExtensions.Contains(f.Extension.ToLowerInvariant())).ToList();
var smallNonBinaryFiles = allNonBinaryFiles.SelectSmallFiles(progressMonitor).SelectFileNames();
this.fileContent = new FileContent(progressMonitor, smallNonBinaryFiles);
this.allSources = allNonBinaryFiles.SelectFileNamesByExtension(".cs").ToList();
this.nonGeneratedSources = allNonBinaryFiles.SelectFileNamesByExtension(".cs").ToList();
this.generatedSources = new();
var allProjects = allNonBinaryFiles.SelectFileNamesByExtension(".csproj");
var solutions = options.SolutionFile is not null
? new[] { options.SolutionFile }
@ -219,7 +221,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
}
}
this.allSources.Add(path);
this.generatedSources.Add(path);
}
}
@ -241,7 +243,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
var razor = new Razor(sdk, dotnet, progressMonitor);
var targetDir = GetTemporaryWorkingDirectory("razor");
var generatedFiles = razor.GenerateFiles(views, usedReferences.Keys, targetDir);
this.allSources.AddRange(generatedFiles);
this.generatedSources.AddRange(generatedFiles);
}
catch (Exception ex)
{
@ -384,10 +386,15 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
/// </summary>
public IEnumerable<string> ProjectSourceFiles => sources.Where(s => s.Value).Select(s => s.Key);
/// <summary>
/// All of the generated source files in the source directory.
/// </summary>
public IEnumerable<string> GeneratedSourceFiles => generatedSources;
/// <summary>
/// All of the source files in the source directory.
/// </summary>
public IEnumerable<string> AllSourceFiles => allSources;
public IEnumerable<string> AllSourceFiles => generatedSources.Concat(nonGeneratedSources);
/// <summary>
/// List of assembly IDs which couldn't be resolved.