Skip to content

Commit 5adacb8

Browse files
authored
Merge pull request github#14311 from hvitved/csharp/dependency-manager-generated-files
C#: Expose generated files in `DependencyManager`
2 parents 7c230d6 + a045e6b commit 5adacb8

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 }
@@ -219,7 +221,7 @@ private void GenerateSourceFileFromImplicitUsings()
219221
}
220222
}
221223

222-
this.allSources.Add(path);
224+
this.generatedSources.Add(path);
223225
}
224226
}
225227

@@ -241,7 +243,7 @@ private void GenerateSourceFilesFromWebViews(List<FileInfo> allFiles)
241243
var razor = new Razor(sdk, dotnet, progressMonitor);
242244
var targetDir = GetTemporaryWorkingDirectory("razor");
243245
var generatedFiles = razor.GenerateFiles(views, usedReferences.Keys, targetDir);
244-
this.allSources.AddRange(generatedFiles);
246+
this.generatedSources.AddRange(generatedFiles);
245247
}
246248
catch (Exception ex)
247249
{
@@ -384,10 +386,15 @@ private void ResolveConflicts()
384386
/// </summary>
385387
public IEnumerable<string> ProjectSourceFiles => sources.Where(s => s.Value).Select(s => s.Key);
386388

389+
/// <summary>
390+
/// All of the generated source files in the source directory.
391+
/// </summary>
392+
public IEnumerable<string> GeneratedSourceFiles => generatedSources;
393+
387394
/// <summary>
388395
/// All of the source files in the source directory.
389396
/// </summary>
390-
public IEnumerable<string> AllSourceFiles => allSources;
397+
public IEnumerable<string> AllSourceFiles => generatedSources.Concat(nonGeneratedSources);
391398

392399
/// <summary>
393400
/// List of assembly IDs which couldn't be resolved.

0 commit comments

Comments
 (0)