diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs index abef26cbd67..4adb8e88e64 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs @@ -23,7 +23,8 @@ namespace Semmle.Extraction.CSharp.DependencyFetching private readonly IDictionary unresolvedReferences = new ConcurrentDictionary(); private int failedProjects; private int succeededProjects; - private readonly List allSources; + private readonly List nonGeneratedSources; + private readonly List 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 /// public IEnumerable ProjectSourceFiles => sources.Where(s => s.Value).Select(s => s.Key); + /// + /// All of the generated source files in the source directory. + /// + public IEnumerable GeneratedSourceFiles => generatedSources; + /// /// All of the source files in the source directory. /// - public IEnumerable AllSourceFiles => allSources; + public IEnumerable AllSourceFiles => generatedSources.Concat(nonGeneratedSources); /// /// List of assembly IDs which couldn't be resolved.