C#: Change string.Format calls to interpolated strings

This commit is contained in:
Tamas Vajk
2024-06-27 09:20:44 +02:00
parent 4a98436884
commit 0c34b4535a
17 changed files with 58 additions and 58 deletions

View File

@@ -39,7 +39,7 @@ namespace Semmle.Autobuild.CSharp
if (notDotNetProject is not null)
{
builder.Logger.Log(Severity.Info, "Not using .NET Core because of incompatible project {0}", notDotNetProject);
builder.Logger.LogInfo($"Not using .NET Core because of incompatible project {notDotNetProject}");
return BuildScript.Failure;
}

View File

@@ -22,12 +22,12 @@ namespace Semmle.Autobuild.CSharp
}
catch (InvalidEnvironmentException ex)
{
Console.WriteLine("The environment is invalid: {0}", ex.Message);
Console.WriteLine($"The environment is invalid: {ex.Message}");
}
}
catch (ArgumentOutOfRangeException ex)
{
Console.WriteLine("The value \"{0}\" for parameter \"{1}\" is invalid", ex.ActualValue, ex.ParamName);
Console.WriteLine($"The value \"{ex.ActualValue}\" for parameter \"{ex.ParamName}\" is invalid");
}
return 1;
}

View File

@@ -22,12 +22,12 @@ namespace Semmle.Autobuild.Cpp
}
catch (InvalidEnvironmentException ex)
{
Console.WriteLine("The environment is invalid: {0}", ex.Message);
Console.WriteLine($"The environment is invalid: {ex.Message}");
}
}
catch (ArgumentOutOfRangeException ex)
{
Console.WriteLine("The value \"{0}\" for parameter \"{1}\" is invalid", ex.ActualValue, ex.ParamName);
Console.WriteLine($"The value \"{ex.ActualValue}\" for parameter \"{ex.ParamName}\" is invalid");
}
return 1;
}

View File

@@ -128,9 +128,9 @@ namespace Semmle.Autobuild.Shared
command.Argument("/t:" + target);
if (platform is not null)
command.Argument(string.Format("/p:Platform=\"{0}\"", platform));
command.Argument($"/p:Platform=\"{platform}\"");
if (configuration is not null)
command.Argument(string.Format("/p:Configuration=\"{0}\"", configuration));
command.Argument($"/p:Configuration=\"{configuration}\"");
// append the build script which invokes msbuild to the overall build script `ret`;
// we insert a check that building the current project or solution was successful:

View File

@@ -66,7 +66,7 @@ namespace Semmle.Autobuild.Shared
catch // lgtm[cs/catch-of-all-exceptions]
// Generic catch clause - Version constructor throws about 5 different exceptions.
{
builder.Logger.Log(Severity.Warning, "Project {0} has invalid tools version {1}", path, toolsVersion);
builder.Logger.LogWarning($"Project {path} has invalid tools version {toolsVersion}");
}
}