Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tools] Fix nullability for the Execution.Environment field. #15084

Merged
merged 1 commit into from
May 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions tools/common/Execution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Xamarin.Utils {
public class Execution {
public string? FileName;
public IList<string>? Arguments;
public IDictionary<string, string>? Environment;
public IDictionary<string, string?>? Environment;
public string? WorkingDirectory;
public TimeSpan? Timeout;
public CancellationToken? CancellationToken;
Expand Down Expand Up @@ -81,7 +81,7 @@ public Task<Execution> RunAsync ()

if (Environment != null) {
foreach (var kvp in Environment) {
if (kvp.Value == null) {
if (kvp.Value is null) {
p.StartInfo.EnvironmentVariables.Remove (kvp.Key);
} else {
p.StartInfo.EnvironmentVariables [kvp.Key] = kvp.Value;
Expand Down Expand Up @@ -154,7 +154,7 @@ public Task<Execution> RunAsync ()
return tcs.Task;
}

public static Task<Execution> RunWithCallbacksAsync (string filename, IList<string> arguments, Dictionary<string, string>? environment = null, Action<string>? standardOutput = null, Action<string>? standardError = null, TextWriter? log = null, string? workingDirectory = null, TimeSpan? timeout = null, CancellationToken? cancellationToken = null)
public static Task<Execution> RunWithCallbacksAsync (string filename, IList<string> arguments, Dictionary<string, string?>? environment = null, Action<string>? standardOutput = null, Action<string>? standardError = null, TextWriter? log = null, string? workingDirectory = null, TimeSpan? timeout = null, CancellationToken? cancellationToken = null)
{
CallbackWriter? outputCallback = null;
CallbackWriter? errorCallback = null;
Expand All @@ -167,7 +167,7 @@ public static Task<Execution> RunWithCallbacksAsync (string filename, IList<stri
return RunAsync (filename, arguments, environment, outputCallback, errorCallback, log, workingDirectory, timeout, cancellationToken);
}

public static Task<Execution> RunAsync (string filename, IList<string> arguments, Dictionary<string, string>? environment = null, TextWriter? standardOutput = null, TextWriter? standardError = null, TextWriter? log = null, string? workingDirectory = null, TimeSpan? timeout = null, CancellationToken? cancellationToken = null)
public static Task<Execution> RunAsync (string filename, IList<string> arguments, Dictionary<string, string?>? environment = null, TextWriter? standardOutput = null, TextWriter? standardError = null, TextWriter? log = null, string? workingDirectory = null, TimeSpan? timeout = null, CancellationToken? cancellationToken = null)
{
return new Execution {
FileName = filename,
Expand All @@ -182,14 +182,14 @@ public static Task<Execution> RunAsync (string filename, IList<string> arguments
}.RunAsync ();
}

public static Task<Execution> RunAsync (string filename, IList<string> arguments, Dictionary<string, string>? environment = null, bool mergeOutput = false, string? workingDirectory = null, TextWriter? log = null, TimeSpan? timeout = null, CancellationToken? cancellationToken = null)
public static Task<Execution> RunAsync (string filename, IList<string> arguments, Dictionary<string, string?>? environment = null, bool mergeOutput = false, string? workingDirectory = null, TextWriter? log = null, TimeSpan? timeout = null, CancellationToken? cancellationToken = null)
{
var standardOutput = new StringWriter ();
var standardError = mergeOutput ? standardOutput : new StringWriter ();
return RunAsync (filename, arguments, environment, standardOutput, standardError, log, workingDirectory, timeout, cancellationToken);
}

public static Task<Execution> RunWithStringBuildersAsync (string filename, IList<string> arguments, Dictionary<string, string>? environment = null, StringBuilder? standardOutput = null, StringBuilder? standardError = null, TextWriter? log = null, string? workingDirectory = null, TimeSpan? timeout = null, CancellationToken? cancellationToken = null)
public static Task<Execution> RunWithStringBuildersAsync (string filename, IList<string> arguments, Dictionary<string, string?>? environment = null, StringBuilder? standardOutput = null, StringBuilder? standardError = null, TextWriter? log = null, string? workingDirectory = null, TimeSpan? timeout = null, CancellationToken? cancellationToken = null)
{
var stdout = standardOutput == null ? null : new StringWriter (standardOutput);
var stderr = standardError == null ? null : (standardOutput == standardError ? stdout : new StringWriter (standardError));
Expand Down