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,21 +220,22 @@ 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)
{ {
case 0: switch (ret)
return BuildScript.Success; {
case 143 when attempt < 3: case 0:
HandleRetryExitCode143(dotnet, attempt, logger); return BuildScript.Success;
return info.Script; case 143 when attemptCopy < 3:
default: HandleRetryExitCode143(dotnet, attemptCopy, logger);
return BuildScript.Failure; return info.Script;
} default:
}); return BuildScript.Failure;
}
});
} }
return script; return script;
} }