mirror of
https://github.com/github/codeql.git
synced 2026-05-05 21:55:19 +02:00
C#: Use var everywhere
This commit is contained in:
@@ -379,7 +379,7 @@ namespace Semmle.Autobuild.CSharp.Tests
|
||||
string? nugetRestore = null, string? allSolutions = null,
|
||||
string cwd = @"C:\Project")
|
||||
{
|
||||
string codeqlUpperLanguage = Language.CSharp.UpperCaseName;
|
||||
var codeqlUpperLanguage = Language.CSharp.UpperCaseName;
|
||||
Actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_TRAP_DIR"] = "";
|
||||
Actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_SOURCE_ARCHIVE_DIR"] = "";
|
||||
Actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_ROOT"] = $@"C:\codeql\{codeqlUpperLanguage.ToLowerInvariant()}";
|
||||
@@ -591,7 +591,7 @@ Microsoft.NETCore.App 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.Ap
|
||||
Assert.Equal(commandsRun, EndCallbackReturn.Count);
|
||||
|
||||
var action = Actions.RunProcess.GetEnumerator();
|
||||
for (int cmd = 0; cmd < commandsRun; ++cmd)
|
||||
for (var cmd = 0; cmd < commandsRun; ++cmd)
|
||||
{
|
||||
Assert.True(action.MoveNext());
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Semmle.Autobuild.CSharp
|
||||
|
||||
private static BuildScript WithDotNet(Autobuilder builder, Func<string?, IDictionary<string, string>?, bool, BuildScript> f)
|
||||
{
|
||||
string? installDir = builder.Actions.PathCombine(builder.Options.RootDirectory, ".dotnet");
|
||||
var installDir = builder.Actions.PathCombine(builder.Options.RootDirectory, ".dotnet");
|
||||
var installScript = DownloadDotNet(builder, installDir);
|
||||
return BuildScript.Bind(installScript, installed =>
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Semmle.Autobuild.Shared
|
||||
chmod.RunCommand("/bin/chmod", $"u+x {scriptPath}");
|
||||
var chmodScript = builder.Actions.IsWindows() ? BuildScript.Success : BuildScript.Try(chmod.Script);
|
||||
|
||||
string? dir = builder.Actions.GetDirectoryName(scriptPath);
|
||||
var dir = builder.Actions.GetDirectoryName(scriptPath);
|
||||
|
||||
// A specific .NET Core version may be required
|
||||
return chmodScript & withDotNet(builder, environment =>
|
||||
|
||||
@@ -31,12 +31,12 @@ namespace Semmle.Autobuild.Shared
|
||||
yield break;
|
||||
|
||||
// Attempt to use vswhere to find installations of Visual Studio
|
||||
string vswhere = actions.PathCombine(programFilesx86, "Microsoft Visual Studio", "Installer", "vswhere.exe");
|
||||
var vswhere = actions.PathCombine(programFilesx86, "Microsoft Visual Studio", "Installer", "vswhere.exe");
|
||||
|
||||
if (actions.FileExists(vswhere))
|
||||
{
|
||||
int exitCode1 = actions.RunProcess(vswhere, "-prerelease -legacy -property installationPath", null, null, out var installationList);
|
||||
int exitCode2 = actions.RunProcess(vswhere, "-prerelease -legacy -property installationVersion", null, null, out var versionList);
|
||||
var exitCode1 = actions.RunProcess(vswhere, "-prerelease -legacy -property installationPath", null, null, out var installationList);
|
||||
var exitCode2 = actions.RunProcess(vswhere, "-prerelease -legacy -property installationVersion", null, null, out var versionList);
|
||||
|
||||
if (exitCode1 == 0 && exitCode2 == 0 && versionList.Count == installationList.Count)
|
||||
{
|
||||
@@ -45,7 +45,7 @@ namespace Semmle.Autobuild.Shared
|
||||
{
|
||||
var dot = vsInstallation.Version.IndexOf('.');
|
||||
var majorVersionString = dot == -1 ? vsInstallation.Version : vsInstallation.Version.Substring(0, dot);
|
||||
if (int.TryParse(majorVersionString, out int majorVersion))
|
||||
if (int.TryParse(majorVersionString, out var majorVersion))
|
||||
{
|
||||
if (majorVersion < 15)
|
||||
{
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Semmle.Autobuild.Shared
|
||||
/// </remarks>
|
||||
private void ArgvQuote(string argument, bool force)
|
||||
{
|
||||
bool cmd = escapingMode == EscapeMode.Cmd;
|
||||
var cmd = escapingMode == EscapeMode.Cmd;
|
||||
if (!force &&
|
||||
!string.IsNullOrEmpty(argument) &&
|
||||
argument.IndexOfAny(specialChars) == -1)
|
||||
@@ -104,7 +104,7 @@ namespace Semmle.Autobuild.Shared
|
||||
|
||||
arguments.Append('\"');
|
||||
|
||||
for (int it = 0; ; ++it)
|
||||
for (var it = 0; ; ++it)
|
||||
{
|
||||
var numBackslashes = 0;
|
||||
while (it != argument.Length && argument[it] == '\\')
|
||||
|
||||
@@ -98,9 +98,9 @@ namespace Semmle.Autobuild.Shared
|
||||
|
||||
command.Argument("/p:UseSharedCompilation=false");
|
||||
|
||||
string target = builder.Options.MsBuildTarget ?? "rebuild";
|
||||
string? platform = builder.Options.MsBuildPlatform ?? (projectOrSolution is ISolution s1 ? s1.DefaultPlatformName : null);
|
||||
string? configuration = builder.Options.MsBuildConfiguration ?? (projectOrSolution is ISolution s2 ? s2.DefaultConfigurationName : null);
|
||||
var target = builder.Options.MsBuildTarget ?? "rebuild";
|
||||
var platform = builder.Options.MsBuildPlatform ?? (projectOrSolution is ISolution s1 ? s1.DefaultPlatformName : null);
|
||||
var configuration = builder.Options.MsBuildConfiguration ?? (projectOrSolution is ISolution s2 ? s2.DefaultConfigurationName : null);
|
||||
|
||||
command.Argument("/t:" + target);
|
||||
if (platform != null)
|
||||
|
||||
Reference in New Issue
Block a user