1- using Semmle . Util ;
2- using System ;
1+ using System ;
2+ using System . Collections . Concurrent ;
33using System . Collections . Generic ;
44using System . IO ;
55using System . Linq ;
6- using Semmle . Extraction . CSharp . Standalone ;
7- using System . Threading . Tasks ;
8- using System . Collections . Concurrent ;
9- using System . Text ;
106using System . Security . Cryptography ;
7+ using System . Text ;
8+ using System . Threading . Tasks ;
9+ using Semmle . Util ;
10+ using Semmle . Util . Logging ;
1111
12- namespace Semmle . BuildAnalyser
12+ namespace Semmle . Extraction . CSharp . DependencyFetching
1313{
1414 /// <summary>
1515 /// Main implementation of the build analysis.
1616 /// </summary>
17- internal sealed class BuildAnalysis : IDisposable
17+ public sealed class DependencyManager : IDisposable
1818 {
1919 private readonly AssemblyCache assemblyCache ;
2020 private readonly ProgressMonitor progressMonitor ;
@@ -25,25 +25,25 @@ internal sealed class BuildAnalysis : IDisposable
2525 private int succeededProjects ;
2626 private readonly string [ ] allSources ;
2727 private int conflictedReferences = 0 ;
28- private readonly Options options ;
28+ private readonly IDependencyOptions options ;
2929 private readonly DirectoryInfo sourceDir ;
3030 private readonly DotNet dotnet ;
3131 private readonly FileContent fileContent ;
3232 private readonly TemporaryDirectory packageDirectory ;
3333
3434
3535 /// <summary>
36- /// Performs a C# build analysis .
36+ /// Performs C# dependency fetching .
3737 /// </summary>
38- /// <param name="options">Analysis options from the command line. </param>
39- /// <param name="progressMonitor">Display of analysis progress.</param>
40- public BuildAnalysis ( Options options , ProgressMonitor progressMonitor )
38+ /// <param name="options">Dependency fetching options </param>
39+ /// <param name="logger">Logger for dependency fetching progress.</param>
40+ public DependencyManager ( string srcDir , IDependencyOptions options , ILogger logger )
4141 {
4242 var startTime = DateTime . Now ;
4343
4444 this . options = options ;
45- this . progressMonitor = progressMonitor ;
46- this . sourceDir = new DirectoryInfo ( options . SrcDir ) ;
45+ this . progressMonitor = new ProgressMonitor ( logger ) ;
46+ this . sourceDir = new DirectoryInfo ( srcDir ) ;
4747
4848 try
4949 {
@@ -55,7 +55,7 @@ public BuildAnalysis(Options options, ProgressMonitor progressMonitor)
5555 throw ;
5656 }
5757
58- this . progressMonitor . FindingFiles ( options . SrcDir ) ;
58+ this . progressMonitor . FindingFiles ( srcDir ) ;
5959
6060 packageDirectory = new TemporaryDirectory ( ComputeTempDirectory ( sourceDir . FullName ) ) ;
6161
@@ -106,7 +106,7 @@ public BuildAnalysis(Options options, ProgressMonitor progressMonitor)
106106 {
107107 Restore ( solutions ) ;
108108 Restore ( allProjects ) ;
109- DownloadMissingPackages ( allProjects ) ;
109+ DownloadMissingPackages ( ) ;
110110 }
111111 }
112112
@@ -143,6 +143,8 @@ public BuildAnalysis(Options options, ProgressMonitor progressMonitor)
143143 DateTime . Now - startTime ) ;
144144 }
145145
146+ public DependencyManager ( string srcDir ) : this ( srcDir , DependencyOptions . Default , new ConsoleLogger ( Verbosity . Info ) ) { }
147+
146148 private IEnumerable < string > GetFiles ( string pattern , bool recurseSubdirectories = true )
147149 {
148150 return sourceDir . GetFiles ( pattern , new EnumerationOptions { RecurseSubdirectories = recurseSubdirectories , MatchCasing = MatchCasing . CaseInsensitive } )
@@ -285,7 +287,7 @@ private void AnalyseProject(FileInfo project)
285287
286288 try
287289 {
288- var csProj = new Extraction . CSharp . CsProjFile ( project ) ;
290+ var csProj = new CsProjFile ( project ) ;
289291
290292 foreach ( var @ref in csProj . References )
291293 {
@@ -329,8 +331,7 @@ private void Restore(IEnumerable<string> targets, string? pathToNugetConfig = nu
329331 }
330332 }
331333
332-
333- private void DownloadMissingPackages ( IEnumerable < string > restoreTargets )
334+ private void DownloadMissingPackages ( )
334335 {
335336 var nugetConfigs = GetFiles ( "nuget.config" , recurseSubdirectories : true ) . ToArray ( ) ;
336337 string ? nugetConfig = null ;
0 commit comments