C#: Allow checking environment variables that may be undefined

The build mode environment variable for instance is only set when a build mode is specified.
This commit is contained in:
Henry Mercer
2024-01-23 20:33:16 +00:00
parent 6724dea54d
commit a75c8273f9

View File

@@ -116,10 +116,9 @@ namespace Semmle.Autobuild.CSharp.Tests
string? IBuildActions.GetEnvironmentVariable(string name)
{
if (!GetEnvironmentVariable.TryGetValue(name, out var ret))
throw new ArgumentException("Missing GetEnvironmentVariable " + name);
return ret;
if (!GetEnvironmentVariable.ContainsKey(name))
return null;
return GetEnvironmentVariable[name];
}
public string GetCurrentDirectory { get; set; } = "";