Skip to content

Commit e425d75

Browse files
committed
C#: Gracefully handle non-zero exitcodes for dotnet --info.
1 parent c43b03b commit e425d75

File tree

2 files changed

+1
-26
lines changed
  • csharp/extractor

2 files changed

+1
-26
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,7 @@ private DotNet(ILogger logger, string? dotNetPath, TemporaryDirectory tempWorkin
3838

3939
private void Info()
4040
{
41-
var res = dotnetCliInvoker.RunCommand("--info", silent: false);
42-
if (!res)
43-
{
44-
throw new Exception($"{dotnetCliInvoker.Exec} --info failed.");
45-
}
41+
dotnetCliInvoker.RunCommand("--info", silent: false);
4642
}
4743

4844
private string GetRestoreArgs(RestoreSettings restoreSettings)

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

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,27 +79,6 @@ public void TestDotnetInfo()
7979
Assert.Equal("--info", lastArgs);
8080
}
8181

82-
[Fact]
83-
public void TestDotnetInfoFailure()
84-
{
85-
// Setup
86-
var dotnetCliInvoker = new DotNetCliInvokerStub(new List<string>()) { Success = false };
87-
88-
// Execute
89-
try
90-
{
91-
_ = MakeDotnet(dotnetCliInvoker);
92-
}
93-
94-
// Verify
95-
catch (Exception e)
96-
{
97-
Assert.Equal("dotnet --info failed.", e.Message);
98-
return;
99-
}
100-
Assert.Fail("Expected exception");
101-
}
102-
10382
[Fact]
10483
public void TestDotnetRestoreProjectToDirectory1()
10584
{

0 commit comments

Comments
 (0)