@@ -21,17 +21,18 @@ internal class AssemblyCache
21
21
/// <param name="progressMonitor">Callback for progress.</param>
22
22
public AssemblyCache ( IEnumerable < string > paths , IEnumerable < string > frameworkPaths , ProgressMonitor progressMonitor )
23
23
{
24
+ this . progressMonitor = progressMonitor ;
24
25
foreach ( var path in paths )
25
26
{
26
27
if ( File . Exists ( path ) )
27
28
{
28
- pendingDllsToIndex . Enqueue ( path ) ;
29
+ dllsToIndex . Add ( path ) ;
29
30
continue ;
30
31
}
31
32
32
33
if ( Directory . Exists ( path ) )
33
34
{
34
- progressMonitor . FindingFiles ( path ) ;
35
+ progressMonitor . LogInfo ( $ "Finding reference DLLs in { path } ..." ) ;
35
36
AddReferenceDirectory ( path ) ;
36
37
}
37
38
else
@@ -52,7 +53,7 @@ private void AddReferenceDirectory(string dir)
52
53
{
53
54
foreach ( var dll in new DirectoryInfo ( dir ) . EnumerateFiles ( "*.dll" , SearchOption . AllDirectories ) )
54
55
{
55
- pendingDllsToIndex . Enqueue ( dll . FullName ) ;
56
+ dllsToIndex . Add ( dll . FullName ) ;
56
57
}
57
58
}
58
59
@@ -62,12 +63,16 @@ private void AddReferenceDirectory(string dir)
62
63
/// </summary>
63
64
private void IndexReferences ( IEnumerable < string > frameworkPaths )
64
65
{
66
+ progressMonitor . LogInfo ( $ "Indexing { dllsToIndex . Count } assemblies...") ;
67
+
65
68
// Read all of the files
66
- foreach ( var filename in pendingDllsToIndex )
69
+ foreach ( var filename in dllsToIndex )
67
70
{
68
71
IndexReference ( filename ) ;
69
72
}
70
73
74
+ progressMonitor . LogInfo ( $ "Read { assemblyInfoByFileName . Count } assembly infos") ;
75
+
71
76
foreach ( var info in assemblyInfoByFileName . Values
72
77
. OrderBy ( info => info . Name )
73
78
. OrderAssemblyInfosByPreference ( frameworkPaths ) )
@@ -83,25 +88,16 @@ private void IndexReference(string filename)
83
88
{
84
89
try
85
90
{
91
+ progressMonitor . LogDebug ( $ "Reading assembly info from { filename } ") ;
86
92
var info = AssemblyInfo . ReadFromFile ( filename ) ;
87
93
assemblyInfoByFileName [ filename ] = info ;
88
94
}
89
95
catch ( AssemblyLoadException )
90
96
{
91
- failedAssemblyInfoFileNames . Add ( filename ) ;
97
+ progressMonitor . LogInfo ( $ "Couldn't read assembly info from { filename } " ) ;
92
98
}
93
99
}
94
100
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
-
105
101
/// <summary>
106
102
/// Given an assembly id, determine its full info.
107
103
/// </summary>
@@ -113,8 +109,7 @@ public AssemblyInfo ResolveReference(string id)
113
109
if ( failedAssemblyInfoIds . Contains ( id ) )
114
110
throw new AssemblyLoadException ( ) ;
115
111
116
- string assemblyName ;
117
- ( id , assemblyName ) = AssemblyInfo . ComputeSanitizedAssemblyInfo ( id ) ;
112
+ ( id , var assemblyName ) = AssemblyInfo . ComputeSanitizedAssemblyInfo ( id ) ;
118
113
119
114
// Look up the id in our references map.
120
115
if ( assemblyInfoById . TryGetValue ( id , out var result ) )
@@ -164,17 +159,15 @@ public AssemblyInfo GetAssemblyInfo(string filepath)
164
159
throw new AssemblyLoadException ( ) ;
165
160
}
166
161
167
- private readonly Queue < string > pendingDllsToIndex = new Queue < string > ( ) ;
162
+ private readonly List < string > dllsToIndex = new List < string > ( ) ;
168
163
169
164
private readonly Dictionary < string , AssemblyInfo > assemblyInfoByFileName = new Dictionary < string , AssemblyInfo > ( ) ;
170
165
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
-
175
166
// Map from assembly id (in various formats) to the full info.
176
167
private readonly Dictionary < string , AssemblyInfo > assemblyInfoById = new Dictionary < string , AssemblyInfo > ( ) ;
177
168
178
169
private readonly HashSet < string > failedAssemblyInfoIds = new HashSet < string > ( ) ;
170
+
171
+ private readonly ProgressMonitor progressMonitor ;
179
172
}
180
173
}
0 commit comments