Skip to content

Commit a75c827

Browse files
committed
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.
1 parent 6724dea commit a75c827

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

csharp/autobuilder/Semmle.Autobuild.CSharp.Tests/BuildScripts.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,9 @@ bool IBuildActions.DirectoryExists(string dir)
116116

117117
string? IBuildActions.GetEnvironmentVariable(string name)
118118
{
119-
if (!GetEnvironmentVariable.TryGetValue(name, out var ret))
120-
throw new ArgumentException("Missing GetEnvironmentVariable " + name);
121-
122-
return ret;
119+
if (!GetEnvironmentVariable.ContainsKey(name))
120+
return null;
121+
return GetEnvironmentVariable[name];
123122
}
124123

125124
public string GetCurrentDirectory { get; set; } = "";

0 commit comments

Comments
 (0)