@@ -21,17 +21,18 @@ internal class AssemblyCache
2121 /// <param name="progressMonitor">Callback for progress.</param>
2222 public AssemblyCache ( IEnumerable < string > paths , IEnumerable < string > frameworkPaths , ProgressMonitor progressMonitor )
2323 {
24+ this . progressMonitor = progressMonitor ;
2425 foreach ( var path in paths )
2526 {
2627 if ( File . Exists ( path ) )
2728 {
28- pendingDllsToIndex . Enqueue ( path ) ;
29+ dllsToIndex . Add ( path ) ;
2930 continue ;
3031 }
3132
3233 if ( Directory . Exists ( path ) )
3334 {
34- progressMonitor . FindingFiles ( path ) ;
35+ progressMonitor . LogInfo ( $ "Finding reference DLLs in { path } ..." ) ;
3536 AddReferenceDirectory ( path ) ;
3637 }
3738 else
@@ -52,7 +53,7 @@ private void AddReferenceDirectory(string dir)
5253 {
5354 foreach ( var dll in new DirectoryInfo ( dir ) . EnumerateFiles ( "*.dll" , SearchOption . AllDirectories ) )
5455 {
55- pendingDllsToIndex . Enqueue ( dll . FullName ) ;
56+ dllsToIndex . Add ( dll . FullName ) ;
5657 }
5758 }
5859
@@ -62,12 +63,16 @@ private void AddReferenceDirectory(string dir)
6263 /// </summary>
6364 private void IndexReferences ( IEnumerable < string > frameworkPaths )
6465 {
66+ progressMonitor . LogInfo ( $ "Indexing { dllsToIndex . Count } assemblies...") ;
67+
6568 // Read all of the files
66- foreach ( var filename in pendingDllsToIndex )
69+ foreach ( var filename in dllsToIndex )
6770 {
6871 IndexReference ( filename ) ;
6972 }
7073
74+ progressMonitor . LogInfo ( $ "Read { assemblyInfoByFileName . Count } assembly infos") ;
75+
7176 foreach ( var info in assemblyInfoByFileName . Values
7277 . OrderBy ( info => info . Name )
7378 . OrderAssemblyInfosByPreference ( frameworkPaths ) )
@@ -83,25 +88,16 @@ private void IndexReference(string filename)
8388 {
8489 try
8590 {
91+ progressMonitor . LogDebug ( $ "Reading assembly info from { filename } ") ;
8692 var info = AssemblyInfo . ReadFromFile ( filename ) ;
8793 assemblyInfoByFileName [ filename ] = info ;
8894 }
8995 catch ( AssemblyLoadException )
9096 {
91- failedAssemblyInfoFileNames . Add ( filename ) ;
97+ progressMonitor . LogInfo ( $ "Couldn't read assembly info from { filename } " ) ;
9298 }
9399 }
94100
95- /// <summary>
96- /// The number of DLLs which are assemblies.
97- /// </summary>
98- public int AssemblyCount => assemblyInfoByFileName . Count ;
99-
100- /// <summary>
101- /// The number of DLLs which weren't assemblies. (E.g. C++).
102- /// </summary>
103- public int NonAssemblyCount => failedAssemblyInfoFileNames . Count ;
104-
105101 /// <summary>
106102 /// Given an assembly id, determine its full info.
107103 /// </summary>
@@ -113,8 +109,7 @@ public AssemblyInfo ResolveReference(string id)
113109 if ( failedAssemblyInfoIds . Contains ( id ) )
114110 throw new AssemblyLoadException ( ) ;
115111
116- string assemblyName ;
117- ( id , assemblyName ) = AssemblyInfo . ComputeSanitizedAssemblyInfo ( id ) ;
112+ ( id , var assemblyName ) = AssemblyInfo . ComputeSanitizedAssemblyInfo ( id ) ;
118113
119114 // Look up the id in our references map.
120115 if ( assemblyInfoById . TryGetValue ( id , out var result ) )
@@ -164,17 +159,15 @@ public AssemblyInfo GetAssemblyInfo(string filepath)
164159 throw new AssemblyLoadException ( ) ;
165160 }
166161
167- private readonly Queue < string > pendingDllsToIndex = new Queue < string > ( ) ;
162+ private readonly List < string > dllsToIndex = new List < string > ( ) ;
168163
169164 private readonly Dictionary < string , AssemblyInfo > assemblyInfoByFileName = new Dictionary < string , AssemblyInfo > ( ) ;
170165
171- // List of DLLs which are not assemblies.
172- // We probably don't need to keep this
173- private readonly List < string > failedAssemblyInfoFileNames = new List < string > ( ) ;
174-
175166 // Map from assembly id (in various formats) to the full info.
176167 private readonly Dictionary < string , AssemblyInfo > assemblyInfoById = new Dictionary < string , AssemblyInfo > ( ) ;
177168
178169 private readonly HashSet < string > failedAssemblyInfoIds = new HashSet < string > ( ) ;
170+
171+ private readonly ProgressMonitor progressMonitor ;
179172 }
180173}
0 commit comments