@@ -12,23 +12,22 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
1212 // This class is used to read a set of files and decide different properties about the
1313 // content (by reading the content of the files only once).
1414 // The implementation is lazy, so the properties are only calculated when
15- // the first property is accessed.
15+ // the first property is accessed.
1616 // </summary>
1717 internal partial class FileContent
1818 {
1919 private readonly ProgressMonitor progressMonitor ;
2020 private readonly IUnsafeFileReader unsafeFileReader ;
2121 private readonly Func < IEnumerable < string > > getFiles ;
22- private readonly Func < HashSet < string > > getAlreadyDownloadedPackages ;
23- private readonly HashSet < string > notYetDownloadedPackages = new HashSet < string > ( ) ;
22+ private readonly HashSet < string > allPackages = new HashSet < string > ( ) ;
2423 private readonly Initializer initialize ;
2524
26- public HashSet < string > NotYetDownloadedPackages
25+ public HashSet < string > AllPackages
2726 {
2827 get
2928 {
3029 initialize . Run ( ) ;
31- return notYetDownloadedPackages ;
30+ return allPackages ;
3231 }
3332 }
3433
@@ -50,23 +49,18 @@ public bool UseAspNetDlls
5049 }
5150 }
5251
53- internal FileContent ( Func < HashSet < string > > getAlreadyDownloadedPackages ,
54- ProgressMonitor progressMonitor ,
52+ internal FileContent ( ProgressMonitor progressMonitor ,
5553 Func < IEnumerable < string > > getFiles ,
5654 IUnsafeFileReader unsafeFileReader )
5755 {
58- this . getAlreadyDownloadedPackages = getAlreadyDownloadedPackages ;
5956 this . progressMonitor = progressMonitor ;
6057 this . getFiles = getFiles ;
6158 this . unsafeFileReader = unsafeFileReader ;
6259 this . initialize = new Initializer ( DoInitialize ) ;
6360 }
6461
6562
66- public FileContent ( TemporaryDirectory packageDirectory , ProgressMonitor progressMonitor , Func < IEnumerable < string > > getFiles ) : this ( ( ) => Directory . GetDirectories ( packageDirectory . DirInfo . FullName )
67- . Select ( d => Path . GetFileName ( d )
68- . ToLowerInvariant ( ) )
69- . ToHashSet ( ) , progressMonitor , getFiles , new UnsafeFileReader ( ) )
63+ public FileContent ( ProgressMonitor progressMonitor , Func < IEnumerable < string > > getFiles ) : this ( progressMonitor , getFiles , new UnsafeFileReader ( ) )
7064 { }
7165
7266 private static string GetGroup ( ReadOnlySpan < char > input , ValueMatch valueMatch , string groupPrefix )
@@ -101,22 +95,21 @@ private static bool IsGroupMatch(ReadOnlySpan<char> line, Regex regex, string gr
10195
10296 private void DoInitialize ( )
10397 {
104- var alreadyDownloadedPackages = getAlreadyDownloadedPackages ( ) ;
10598 foreach ( var file in getFiles ( ) )
10699 {
107100 try
108101 {
109102 foreach ( ReadOnlySpan < char > line in unsafeFileReader . ReadLines ( file ) )
110103 {
111104
112- // Find the not yet downloaded packages.
105+ // Find all the packages.
113106 foreach ( var valueMatch in PackageReference ( ) . EnumerateMatches ( line ) )
114107 {
115108 // We can't get the group from the ValueMatch, so doing it manually:
116109 var packageName = GetGroup ( line , valueMatch , "Include" ) ;
117- if ( ! string . IsNullOrEmpty ( packageName ) && ! alreadyDownloadedPackages . Contains ( packageName ) )
110+ if ( ! string . IsNullOrEmpty ( packageName ) )
118111 {
119- notYetDownloadedPackages . Add ( packageName ) ;
112+ allPackages . Add ( packageName ) ;
120113 }
121114 }
122115
0 commit comments