C#: Address review comments.

This commit is contained in:
Michael Nebel
2025-12-02 16:16:29 +01:00
parent 1d9b88de8b
commit 3197b50da7

View File

@@ -46,7 +46,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
private void Info() private void Info()
{ {
// Allow up to three retry attempts to run `dotnet --info`, to mitigate transient issues // Allow up to four attempts (with up to three retries) to run `dotnet --info`, to mitigate transient issues
for (int attempt = 0; attempt < 4; attempt++) for (int attempt = 0; attempt < 4; attempt++)
{ {
var exitCode = dotnetCliInvoker.RunCommandExitCode("--info", silent: false); var exitCode = dotnetCliInvoker.RunCommandExitCode("--info", silent: false);
@@ -220,16 +220,17 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
RunCommand(dotnet). RunCommand(dotnet).
Argument("--info"); Argument("--info");
var script = info.Script; var script = info.Script;
for (int attempt = 0; attempt < 4; attempt++) for (var attempt = 0; attempt < 4; attempt++)
{ {
var attemptCopy = attempt; // Capture in local variable
script = BuildScript.Bind(script, ret => script = BuildScript.Bind(script, ret =>
{ {
switch (ret) switch (ret)
{ {
case 0: case 0:
return BuildScript.Success; return BuildScript.Success;
case 143 when attempt < 3: case 143 when attemptCopy < 3:
HandleRetryExitCode143(dotnet, attempt, logger); HandleRetryExitCode143(dotnet, attemptCopy, logger);
return info.Script; return info.Script;
default: default:
return BuildScript.Failure; return BuildScript.Failure;