5
5
using System . Linq ;
6
6
using Newtonsoft . Json . Linq ;
7
7
using Semmle . Util ;
8
+ using Semmle . Util . Logging ;
8
9
9
10
namespace Semmle . Extraction . CSharp . DependencyFetching
10
11
{
@@ -13,11 +14,11 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
13
14
/// </summary>
14
15
internal class Assets
15
16
{
16
- private readonly ProgressMonitor progressMonitor ;
17
+ private readonly ILogger logger ;
17
18
18
- internal Assets ( ProgressMonitor progressMonitor )
19
+ internal Assets ( ILogger logger )
19
20
{
20
- this . progressMonitor = progressMonitor ;
21
+ this . logger = logger ;
21
22
}
22
23
23
24
/// <summary>
@@ -35,7 +36,7 @@ private record class ReferenceInfo(string? Type, Dictionary<string, object>? Com
35
36
36
37
/// <summary>
37
38
/// Add the package dependencies from the assets file to dependencies.
38
- ///
39
+ ///
39
40
/// Parse a part of the JSon assets file and add the paths
40
41
/// to the dependencies required for compilation (and collect
41
42
/// information about used packages).
@@ -60,7 +61,7 @@ private record class ReferenceInfo(string? Type, Dictionary<string, object>? Com
60
61
/// }
61
62
/// }
62
63
/// }
63
- ///
64
+ ///
64
65
/// Adds the following dependencies
65
66
/// Paths: {
66
67
/// "castle.core/4.4.1/lib/netstandard1.5/Castle.Core.dll",
@@ -85,7 +86,7 @@ private void AddPackageDependencies(JObject json, DependencyContainer dependenci
85
86
86
87
if ( references is null )
87
88
{
88
- progressMonitor . LogDebug ( "No references found in the targets section in the assets file." ) ;
89
+ logger . LogDebug ( "No references found in the targets section in the assets file." ) ;
89
90
return ;
90
91
}
91
92
@@ -157,7 +158,7 @@ private void AddFrameworkDependencies(JObject json, DependencyContainer dependen
157
158
158
159
if ( frameworks is null )
159
160
{
160
- progressMonitor . LogDebug ( "No framework section in assets.json." ) ;
161
+ logger . LogDebug ( "No framework section in assets.json." ) ;
161
162
return ;
162
163
}
163
164
@@ -171,7 +172,7 @@ private void AddFrameworkDependencies(JObject json, DependencyContainer dependen
171
172
172
173
if ( references is null )
173
174
{
174
- progressMonitor . LogDebug ( "No framework references in assets.json." ) ;
175
+ logger . LogDebug ( "No framework references in assets.json." ) ;
175
176
return ;
176
177
}
177
178
@@ -196,12 +197,12 @@ public bool TryParse(string json, DependencyContainer dependencies)
196
197
}
197
198
catch ( Exception e )
198
199
{
199
- progressMonitor . LogDebug ( $ "Failed to parse assets file (unexpected error): { e . Message } ") ;
200
+ logger . LogDebug ( $ "Failed to parse assets file (unexpected error): { e . Message } ") ;
200
201
return false ;
201
202
}
202
203
}
203
204
204
- private static bool TryReadAllText ( string path , ProgressMonitor progressMonitor , [ NotNullWhen ( returnValue : true ) ] out string ? content )
205
+ private static bool TryReadAllText ( string path , ILogger logger , [ NotNullWhen ( returnValue : true ) ] out string ? content )
205
206
{
206
207
try
207
208
{
@@ -210,19 +211,19 @@ private static bool TryReadAllText(string path, ProgressMonitor progressMonitor,
210
211
}
211
212
catch ( Exception e )
212
213
{
213
- progressMonitor . LogInfo ( $ "Failed to read assets file '{ path } ': { e . Message } ") ;
214
+ logger . LogInfo ( $ "Failed to read assets file '{ path } ': { e . Message } ") ;
214
215
content = null ;
215
216
return false ;
216
217
}
217
218
}
218
219
219
- public static DependencyContainer GetCompilationDependencies ( ProgressMonitor progressMonitor , IEnumerable < string > assets )
220
+ public static DependencyContainer GetCompilationDependencies ( ILogger logger , IEnumerable < string > assets )
220
221
{
221
- var parser = new Assets ( progressMonitor ) ;
222
+ var parser = new Assets ( logger ) ;
222
223
var dependencies = new DependencyContainer ( ) ;
223
224
assets . ForEach ( asset =>
224
225
{
225
- if ( TryReadAllText ( asset , progressMonitor , out var json ) )
226
+ if ( TryReadAllText ( asset , logger , out var json ) )
226
227
{
227
228
parser . TryParse ( json , dependencies ) ;
228
229
}
0 commit comments