mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C#: Log information about asset file read errors.
This commit is contained in:
@@ -143,14 +143,31 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
||||
}
|
||||
}
|
||||
|
||||
private static bool TryReadAllText(string path, ProgressMonitor progressMonitor, out string content)
|
||||
{
|
||||
try
|
||||
{
|
||||
content = File.ReadAllText(path);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
progressMonitor.LogInfo($"Failed to read assets file '{path}': {e.Message}");
|
||||
content = "";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static DependencyContainer GetCompilationDependencies(ProgressMonitor progressMonitor, IEnumerable<string> assets)
|
||||
{
|
||||
var parser = new Assets(progressMonitor);
|
||||
var dependencies = new DependencyContainer();
|
||||
assets.ForEach(asset =>
|
||||
{
|
||||
var json = File.ReadAllText(asset);
|
||||
parser.TryParse(json, dependencies);
|
||||
if (TryReadAllText(asset, progressMonitor, out var json))
|
||||
{
|
||||
parser.TryParse(json, dependencies);
|
||||
}
|
||||
});
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user