Skip to content

Commit a045e6b

Browse files
committed
C#: Expose generated files in DependencyManager
1 parent 06cb277 commit a045e6b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ public sealed class DependencyManager : IDisposable
2323
private readonly IDictionary<string, string> unresolvedReferences = new ConcurrentDictionary<string, string>();
2424
private int failedProjects;
2525
private int succeededProjects;
26-
private readonly List<string> allSources;
26+
private readonly List<string> nonGeneratedSources;
27+
private readonly List<string> generatedSources;
2728
private int conflictedReferences = 0;
2829
private readonly IDependencyOptions options;
2930
private readonly DirectoryInfo sourceDir;
@@ -65,7 +66,8 @@ public DependencyManager(string srcDir, IDependencyOptions options, ILogger logg
6566
var allNonBinaryFiles = allFiles.Where(f => !binaryFileExtensions.Contains(f.Extension.ToLowerInvariant())).ToList();
6667
var smallNonBinaryFiles = allNonBinaryFiles.SelectSmallFiles(progressMonitor).SelectFileNames();
6768
this.fileContent = new FileContent(progressMonitor, smallNonBinaryFiles);
68-
this.allSources = allNonBinaryFiles.SelectFileNamesByExtension(".cs").ToList();
69+
this.nonGeneratedSources = allNonBinaryFiles.SelectFileNamesByExtension(".cs").ToList();
70+
this.generatedSources = new();
6971
var allProjects = allNonBinaryFiles.SelectFileNamesByExtension(".csproj");
7072
var solutions = options.SolutionFile is not null
7173
? new[] { options.SolutionFile }
@@ -214,7 +216,7 @@ private void GenerateSourceFileFromImplicitUsings()
214216
}
215217
}
216218

217-
this.allSources.Add(path);
219+
this.generatedSources.Add(path);
218220
}
219221
}
220222

@@ -236,7 +238,7 @@ private void GenerateSourceFilesFromWebViews(List<FileInfo> allFiles)
236238
var razor = new Razor(sdk, dotnet, progressMonitor);
237239
var targetDir = GetTemporaryWorkingDirectory("razor");
238240
var generatedFiles = razor.GenerateFiles(views, usedReferences.Keys, targetDir);
239-
this.allSources.AddRange(generatedFiles);
241+
this.generatedSources.AddRange(generatedFiles);
240242
}
241243
catch (Exception ex)
242244
{
@@ -379,10 +381,15 @@ private void ResolveConflicts()
379381
/// </summary>
380382
public IEnumerable<string> ProjectSourceFiles => sources.Where(s => s.Value).Select(s => s.Key);
381383

384+
/// <summary>
385+
/// All of the generated source files in the source directory.
386+
/// </summary>
387+
public IEnumerable<string> GeneratedSourceFiles => generatedSources;
388+
382389
/// <summary>
383390
/// All of the source files in the source directory.
384391
/// </summary>
385-
public IEnumerable<string> AllSourceFiles => allSources;
392+
public IEnumerable<string> AllSourceFiles => generatedSources.Concat(nonGeneratedSources);
386393

387394
/// <summary>
388395
/// List of assembly IDs which couldn't be resolved.

0 commit comments

Comments
 (0)