@@ -36,6 +36,7 @@ public sealed partial class DependencyManager : IDisposable
3636 private readonly TemporaryDirectory legacyPackageDirectory ;
3737 private readonly TemporaryDirectory missingPackageDirectory ;
3838 private readonly TemporaryDirectory tempWorkingDirectory ;
39+ private readonly FileProvider fileProvider ;
3940 private readonly bool cleanupTempWorkingDirectory ;
4041
4142 private readonly Lazy < Runtime > runtimeLazy ;
@@ -79,20 +80,10 @@ public DependencyManager(string srcDir, ILogger logger)
7980
8081 tempWorkingDirectory = new TemporaryDirectory ( FileUtils . GetTemporaryWorkingDirectory ( out cleanupTempWorkingDirectory ) ) ;
8182
82- logger . LogInfo ( $ "Finding files in { srcDir } ...") ;
83-
84- var allFiles = GetAllFiles ( ) . ToList ( ) ;
85- var binaryFileExtensions = new HashSet < string > ( new [ ] { ".dll" , ".exe" } ) ; // TODO: add more binary file extensions.
86- var allNonBinaryFiles = allFiles . Where ( f => ! binaryFileExtensions . Contains ( f . Extension . ToLowerInvariant ( ) ) ) . ToList ( ) ;
87- var smallNonBinaryFiles = allNonBinaryFiles . SelectSmallFiles ( logger ) . SelectFileNames ( ) . ToList ( ) ;
88- this . fileContent = new FileContent ( logger , smallNonBinaryFiles ) ;
89- this . nonGeneratedSources = allNonBinaryFiles . SelectFileNamesByExtension ( ".cs" ) . ToList ( ) ;
90- this . generatedSources = new ( ) ;
91- var allProjects = allNonBinaryFiles . SelectFileNamesByExtension ( ".csproj" ) . ToList ( ) ;
92- var allSolutions = allNonBinaryFiles . SelectFileNamesByExtension ( ".sln" ) . ToList ( ) ;
93- var dllLocations = allFiles . SelectFileNamesByExtension ( ".dll" ) . Select ( x => new AssemblyLookupLocation ( x ) ) . ToHashSet ( ) ;
94-
95- logger . LogInfo ( $ "Found { allFiles . Count } files, { nonGeneratedSources . Count } source files, { allProjects . Count } project files, { allSolutions . Count } solution files, { dllLocations . Count } DLLs.") ;
83+ this . fileProvider = new FileProvider ( sourceDir , logger ) ;
84+ this . fileContent = new FileContent ( logger , this . fileProvider . SmallNonBinary ) ;
85+ this . nonGeneratedSources = fileProvider . Sources . ToList ( ) ;
86+ this . generatedSources = [ ] ;
9687
9788 void startCallback ( string s , bool silent )
9889 {
@@ -104,7 +95,7 @@ void exitCallback(int ret, string msg, bool silent)
10495 logger . Log ( silent ? Severity . Debug : Severity . Info , $ "Exit code { ret } { ( string . IsNullOrEmpty ( msg ) ? "" : $ ": { msg } ") } ") ;
10596 }
10697
107- DotNet . WithDotNet ( SystemBuildActions . Instance , logger , smallNonBinaryFiles , tempWorkingDirectory . ToString ( ) , shouldCleanUp : false , ensureDotNetAvailable : true , version : null , installDir =>
98+ DotNet . WithDotNet ( SystemBuildActions . Instance , logger , fileProvider . GlobalJsons , tempWorkingDirectory . ToString ( ) , shouldCleanUp : false , ensureDotNetAvailable : true , version : null , installDir =>
10899 {
109100 this . dotnetPath = installDir ;
110101 return BuildScript . Success ;
@@ -121,13 +112,14 @@ void exitCallback(int ret, string msg, bool silent)
121112 throw ;
122113 }
123114
124- RestoreNugetPackages ( allNonBinaryFiles , allProjects , allSolutions , dllLocations ) ;
115+ var dllLocations = fileProvider . Dlls . Select ( x => new AssemblyLookupLocation ( x ) ) . ToHashSet ( ) ;
116+ RestoreNugetPackages ( dllLocations ) ;
125117 // Find DLLs in the .Net / Asp.Net Framework
126118 // This needs to come after the nuget restore, because the nuget restore might fetch the .NET Core/Framework reference assemblies.
127119 var frameworkLocations = AddFrameworkDlls ( dllLocations ) ;
128120
129121 assemblyCache = new AssemblyCache ( dllLocations , frameworkLocations , logger ) ;
130- AnalyseSolutions ( allSolutions ) ;
122+ AnalyseSolutions ( fileProvider . Solutions ) ;
131123
132124 foreach ( var filename in assemblyCache . AllAssemblies . Select ( a => a . Filename ) )
133125 {
@@ -154,7 +146,7 @@ void exitCallback(int ret, string msg, bool silent)
154146 shouldExtractWebViews )
155147 {
156148 CompilationInfos . Add ( ( "WebView extraction enabled" , "1" ) ) ;
157- GenerateSourceFilesFromWebViews ( allNonBinaryFiles ) ;
149+ GenerateSourceFilesFromWebViews ( ) ;
158150 }
159151 else
160152 {
@@ -171,8 +163,8 @@ void exitCallback(int ret, string msg, bool silent)
171163 logger . LogInfo ( "Build analysis summary:" ) ;
172164 logger . LogInfo ( $ "{ nonGeneratedSources . Count , align } source files found on the filesystem") ;
173165 logger . LogInfo ( $ "{ generatedSources . Count , align } source files have been generated") ;
174- logger . LogInfo ( $ "{ allSolutions . Count , align } solution files found on the filesystem") ;
175- logger . LogInfo ( $ "{ allProjects . Count , align } project files found on the filesystem") ;
166+ logger . LogInfo ( $ "{ fileProvider . Solutions . Count , align } solution files found on the filesystem") ;
167+ logger . LogInfo ( $ "{ fileProvider . Projects . Count , align } project files found on the filesystem") ;
176168 logger . LogInfo ( $ "{ usedReferences . Keys . Count , align } resolved references") ;
177169 logger . LogInfo ( $ "{ unresolvedReferences . Count , align } unresolved references") ;
178170 logger . LogInfo ( $ "{ conflictedReferences , align } resolved assembly conflicts") ;
@@ -182,8 +174,8 @@ void exitCallback(int ret, string msg, bool silent)
182174 CompilationInfos . AddRange ( [
183175 ( "Source files on filesystem" , nonGeneratedSources . Count . ToString ( ) ) ,
184176 ( "Source files generated" , generatedSources . Count . ToString ( ) ) ,
185- ( "Solution files on filesystem" , allSolutions . Count . ToString ( ) ) ,
186- ( "Project files on filesystem" , allProjects . Count . ToString ( ) ) ,
177+ ( "Solution files on filesystem" , fileProvider . Solutions . Count . ToString ( ) ) ,
178+ ( "Project files on filesystem" , fileProvider . Projects . Count . ToString ( ) ) ,
187179 ( "Resolved references" , usedReferences . Keys . Count . ToString ( ) ) ,
188180 ( "Unresolved references" , unresolvedReferences . Count . ToString ( ) ) ,
189181 ( "Resolved assembly conflicts" , conflictedReferences . ToString ( ) ) ,
@@ -467,15 +459,15 @@ private void GenerateSourceFileFromImplicitUsings()
467459 }
468460 }
469461
470- private void GenerateSourceFilesFromWebViews ( List < FileInfo > allFiles )
462+ private void GenerateSourceFilesFromWebViews ( )
471463 {
472- var views = allFiles . SelectFileNamesByExtension ( ".cshtml" , ".razor" ) . ToArray ( ) ;
473- if ( views . Length == 0 )
464+ var views = fileProvider . RazorViews ;
465+ if ( views . Count == 0 )
474466 {
475467 return ;
476468 }
477469
478- logger . LogInfo ( $ "Found { views . Length } cshtml and razor files.") ;
470+ logger . LogInfo ( $ "Found { views . Count } cshtml and razor files.") ;
479471
480472 if ( ! IsAspNetCoreDetected ( ) )
481473 {
@@ -503,38 +495,6 @@ private void GenerateSourceFilesFromWebViews(List<FileInfo> allFiles)
503495 }
504496 }
505497
506- private IEnumerable < FileInfo > GetAllFiles ( )
507- {
508- IEnumerable < FileInfo > files = sourceDir . GetFiles ( "*.*" , new EnumerationOptions { RecurseSubdirectories = true } ) ;
509-
510- if ( dotnetPath != null )
511- {
512- files = files . Where ( f => ! f . FullName . StartsWith ( dotnetPath , StringComparison . OrdinalIgnoreCase ) ) ;
513- }
514-
515- files = files . Where ( f =>
516- {
517- try
518- {
519- if ( f . Exists )
520- {
521- return true ;
522- }
523-
524- logger . LogWarning ( $ "File { f . FullName } could not be processed.") ;
525- return false ;
526- }
527- catch ( Exception ex )
528- {
529- logger . LogWarning ( $ "File { f . FullName } could not be processed: { ex . Message } ") ;
530- return false ;
531- }
532- } ) ;
533-
534- files = new FilePathFilter ( sourceDir , logger ) . Filter ( files ) ;
535- return files ;
536- }
537-
538498 /// <summary>
539499 /// Computes a unique temp directory for the packages associated
540500 /// with this source tree. Use a SHA1 of the directory name.
0 commit comments