mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C#: Remove progress monitor from dependency fetcher, use logger directly
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user