C#: Remove progress monitor from dependency fetcher, use logger directly

This commit is contained in:
Tamas Vajk
2024-01-24 11:20:14 +01:00
parent 13a8168c8e
commit d742cd3e44
16 changed files with 190 additions and 196 deletions

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using Semmle.Util;
using Semmle.Util.Logging;
namespace Semmle.Extraction.CSharp.DependencyFetching
{
@@ -10,13 +11,13 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
/// </summary>
internal sealed class DotNetCliInvoker : IDotNetCliInvoker
{
private readonly ProgressMonitor progressMonitor;
private readonly ILogger logger;
public string Exec { get; }
public DotNetCliInvoker(ProgressMonitor progressMonitor, string exec)
public DotNetCliInvoker(ILogger logger, string exec)
{
this.progressMonitor = progressMonitor;
this.logger = logger;
this.Exec = exec;
}
@@ -35,15 +36,15 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
private bool RunCommandAux(string args, out IList<string> output)
{
progressMonitor.LogInfo($"Running {Exec} {args}");
logger.LogInfo($"Running {Exec} {args}");
var pi = MakeDotnetStartInfo(args);
var threadId = Environment.CurrentManagedThreadId;
void onOut(string s) => progressMonitor.LogInfo(s, threadId);
void onError(string s) => progressMonitor.LogError(s, threadId);
void onOut(string s) => logger.LogInfo(s, threadId);
void onError(string s) => logger.LogError(s, threadId);
var exitCode = pi.ReadOutput(out output, onOut, onError);
if (exitCode != 0)
{
progressMonitor.LogError($"Command {Exec} {args} failed with exit code {exitCode}");
logger.LogError($"Command {Exec} {args} failed with exit code {exitCode}");
return false;
}
return true;