Skip to content

Commit 3197b50

Browse files
committed
C#: Address review comments.
1 parent 1d9b88d commit 3197b50

File tree

1 file changed

+14
-13
lines changed
  • csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching

1 file changed

+14
-13
lines changed

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private static void HandleRetryExitCode143(string dotnet, int attempt, ILogger l
4646

4747
private void Info()
4848
{
49-
// Allow up to three retry attempts to run `dotnet --info`, to mitigate transient issues
49+
// Allow up to four attempts (with up to three retries) to run `dotnet --info`, to mitigate transient issues
5050
for (int attempt = 0; attempt < 4; attempt++)
5151
{
5252
var exitCode = dotnetCliInvoker.RunCommandExitCode("--info", silent: false);
@@ -220,21 +220,22 @@ public static BuildScript InfoScript(IBuildActions actions, string dotnet, IDict
220220
RunCommand(dotnet).
221221
Argument("--info");
222222
var script = info.Script;
223-
for (int attempt = 0; attempt < 4; attempt++)
223+
for (var attempt = 0; attempt < 4; attempt++)
224224
{
225+
var attemptCopy = attempt; // Capture in local variable
225226
script = BuildScript.Bind(script, ret =>
226-
{
227-
switch (ret)
228227
{
229-
case 0:
230-
return BuildScript.Success;
231-
case 143 when attempt < 3:
232-
HandleRetryExitCode143(dotnet, attempt, logger);
233-
return info.Script;
234-
default:
235-
return BuildScript.Failure;
236-
}
237-
});
228+
switch (ret)
229+
{
230+
case 0:
231+
return BuildScript.Success;
232+
case 143 when attemptCopy < 3:
233+
HandleRetryExitCode143(dotnet, attemptCopy, logger);
234+
return info.Script;
235+
default:
236+
return BuildScript.Failure;
237+
}
238+
});
238239
}
239240
return script;
240241
}

0 commit comments

Comments
 (0)