Skip to content

Commit 31327f4

Browse files
committed
C#: Only access the DotNetCliWrapper using the IDotNet interface.
1 parent 1fd85f4 commit 31327f4

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public sealed class DependencyManager : IDisposable
2727
private int conflictedReferences = 0;
2828
private readonly IDependencyOptions options;
2929
private readonly DirectoryInfo sourceDir;
30-
private readonly DotNetCliWrapper dotnet;
30+
private readonly IDotNet dotnet;
3131
private readonly FileContent fileContent;
3232
private readonly TemporaryDirectory packageDirectory;
3333
private readonly TemporaryDirectory tempWorkingDirectory;
@@ -47,7 +47,7 @@ public DependencyManager(string srcDir, IDependencyOptions options, ILogger logg
4747

4848
try
4949
{
50-
this.dotnet = new DotNetCliWrapper(options, progressMonitor);
50+
this.dotnet = DotNetCliWrapper.Make(options, progressMonitor);
5151
}
5252
catch
5353
{

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DotNetCliWrapper.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,18 @@ internal partial class DotNetCliWrapper : IDotNet
1414
private readonly IDotNetCliInvoker dotnet;
1515
private readonly ProgressMonitor progressMonitor;
1616

17-
internal DotNetCliWrapper(IDotNetCliInvoker dotnet, ProgressMonitor progressMonitor)
17+
private DotNetCliWrapper(IDotNetCliInvoker dotnet, ProgressMonitor progressMonitor)
1818
{
1919
this.progressMonitor = progressMonitor;
2020
this.dotnet = dotnet;
2121
Info();
2222
}
2323

24-
public DotNetCliWrapper(IDependencyOptions options, ProgressMonitor progressMonitor) : this(new DotNetCliInvoker(progressMonitor, Path.Combine(options.DotNetPath ?? string.Empty, "dotnet")), progressMonitor) { }
24+
private DotNetCliWrapper(IDependencyOptions options, ProgressMonitor progressMonitor) : this(new DotNetCliInvoker(progressMonitor, Path.Combine(options.DotNetPath ?? string.Empty, "dotnet")), progressMonitor) { }
2525

26+
internal static IDotNet Make(IDotNetCliInvoker dotnet, ProgressMonitor progressMonitor) => new DotNetCliWrapper(dotnet, progressMonitor);
27+
28+
public static IDotNet Make(IDependencyOptions options, ProgressMonitor progressMonitor) => new DotNetCliWrapper(options, progressMonitor);
2629

2730
private void Info()
2831
{

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/Razor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ internal class Razor
1010
{
1111
private readonly DotnetVersion sdk;
1212
private readonly ProgressMonitor progressMonitor;
13-
private readonly DotNetCliWrapper dotNet;
13+
private readonly IDotNet dotNet;
1414
private readonly string sourceGeneratorFolder;
1515
private readonly string cscPath;
1616

17-
public Razor(DotnetVersion sdk, DotNetCliWrapper dotNet, ProgressMonitor progressMonitor)
17+
public Razor(DotnetVersion sdk, IDotNet dotNet, ProgressMonitor progressMonitor)
1818
{
1919
this.sdk = sdk;
2020
this.progressMonitor = progressMonitor;

csharp/extractor/Semmle.Extraction.Tests/DotNetCliWrapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public bool RunCommand(string args, out IList<string> output)
3838
public class DotNetCliWrapperTests
3939
{
4040
private static IDotNet MakeDotnet(IDotNetCliInvoker dotnetCliInvoker) =>
41-
new DotNetCliWrapper(dotnetCliInvoker, new ProgressMonitor(new LoggerStub()));
41+
DotNetCliWrapper.Make(dotnetCliInvoker, new ProgressMonitor(new LoggerStub()));
4242

4343
private static IList<string> MakeDotnetRestoreOutput() =>
4444
new List<string> {

0 commit comments

Comments
 (0)