Skip to content

Commit c7c2da5

Browse files
committed
getting cli abstractions to compile locally by adding system to environment reference
1 parent e134e8e commit c7c2da5

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

src/Cli/Abstractions/Environment/EnvironmentProvider.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// Note that this file is copied from: https://github.com/dotnet/sdk/blob/4a81a96a9f1bd661592975c8269e078f6e3f18c9/src/Cli/Microsoft.DotNet.Cli.Utils/EnvironmentProvider.cs
55
// Once the dotnet cli utils package is in a published consumable state, we will migrate over to use that
66

7-
using System;
87
using Azure.Functions.Cli.Abstractions.Extensions;
98
using System.Runtime.InteropServices;
109

@@ -15,7 +14,7 @@ public class EnvironmentProvider : IEnvironmentProvider
1514
private static char[] s_pathSeparator = new char[] { Path.PathSeparator };
1615
private static char[] s_quote = new char[] { '"' };
1716
private IEnumerable<string>? _searchPaths;
18-
private readonly Lazy<string> _userHomeDirectory = new(() => Environment.GetEnvironmentVariable("HOME") ?? string.Empty);
17+
private readonly Lazy<string> _userHomeDirectory = new(() => System.Environment.GetEnvironmentVariable("HOME") ?? string.Empty);
1918
private IEnumerable<string>? _executableExtensions;
2019

2120
public IEnumerable<string> ExecutableExtensions
@@ -25,7 +24,7 @@ public IEnumerable<string> ExecutableExtensions
2524
if (_executableExtensions == null)
2625
{
2726
_executableExtensions = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
28-
? Environment.GetEnvironmentVariable("PATHEXT")?
27+
? System.Environment.GetEnvironmentVariable("PATHEXT")?
2928
.Split(';')
3029
.Select(e => e.ToLower().Trim('"')) ?? [string.Empty]
3130
: [string.Empty];
@@ -43,7 +42,7 @@ private IEnumerable<string> SearchPaths
4342
{
4443
var searchPaths = new List<string> { AppContext.BaseDirectory };
4544

46-
searchPaths.AddRange(Environment
45+
searchPaths.AddRange(System.Environment
4746
.GetEnvironmentVariable("PATH")?
4847
.Split(s_pathSeparator)
4948
.Select(p => p.Trim(s_quote))
@@ -116,12 +115,12 @@ public EnvironmentProvider(
116115

117116
public string? GetEnvironmentVariable(string name)
118117
{
119-
return Environment.GetEnvironmentVariable(name);
118+
return System.Environment.GetEnvironmentVariable(name);
120119
}
121120

122121
public bool GetEnvironmentVariableAsBool(string name, bool defaultValue)
123122
{
124-
var str = Environment.GetEnvironmentVariable(name);
123+
var str = System.Environment.GetEnvironmentVariable(name);
125124
if (string.IsNullOrEmpty(str))
126125
{
127126
return defaultValue;
@@ -144,17 +143,17 @@ public bool GetEnvironmentVariableAsBool(string name, bool defaultValue)
144143

145144
public string? GetEnvironmentVariable(string variable, EnvironmentVariableTarget target)
146145
{
147-
return Environment.GetEnvironmentVariable(variable, target);
146+
return System.Environment.GetEnvironmentVariable(variable, target);
148147
}
149148

150149
public void SetEnvironmentVariable(string variable, string value, EnvironmentVariableTarget target)
151150
{
152-
Environment.SetEnvironmentVariable(variable, value, target);
151+
System.Environment.SetEnvironmentVariable(variable, value, target);
153152
}
154153

155154
public int? GetEnvironmentVariableAsNullableInt(string variable)
156155
{
157-
if (Environment.GetEnvironmentVariable(variable) is string strValue && int.TryParse(strValue, out int intValue))
156+
if (System.Environment.GetEnvironmentVariable(variable) is string strValue && int.TryParse(strValue, out int intValue))
158157
{
159158
return intValue;
160159
}

src/Cli/Abstractions/Extensions/AnsiExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public static class AnsiExtensions
1111
private static readonly Lazy<bool> _xtermEnabled = new(
1212
() =>
1313
{
14-
var environment = Environment.GetEnvironmentVariable("TERM");
14+
var environment = System.Environment.GetEnvironmentVariable("TERM");
1515
if (!string.IsNullOrWhiteSpace(environment))
1616
{
1717
return environment.IndexOf("xterm", StringComparison.OrdinalIgnoreCase) >= 0;

src/Cli/Abstractions/Logging/AnsiConsole.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ private AnsiConsole(TextWriter writer)
1818
OriginalForegroundColor = Console.ForegroundColor;
1919
_boldRecursion = ((int)OriginalForegroundColor & Light) != 0 ? 1 : 0;
2020

21-
_ansiEnabled = string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("NO_COLOR"));
21+
_ansiEnabled = string.IsNullOrWhiteSpace(System.Environment.GetEnvironmentVariable("NO_COLOR"));
2222
}
2323

2424
private int _boldRecursion;

src/Cli/Abstractions/ProcessReaper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public void NotifyProcessStarted()
5656
// but nested jobs are transparently implemented with respect to the Job Objects API.
5757
// Note: Windows 8.1 and later may report as Windows 8 (see https://docs.microsoft.com/en-us/windows/desktop/sysinfo/operating-system-version).
5858
// However, for the purpose of this check that is still sufficient.
59-
if (Environment.OSVersion.Version.Major > 6 ||
60-
(Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor >= 2))
59+
if (System.Environment.OSVersion.Version.Major > 6 ||
60+
(System.Environment.OSVersion.Version.Major == 6 && System.Environment.OSVersion.Version.Minor >= 2))
6161
{
6262
_job = AssignProcessToJobObject(_process.Handle);
6363
}
@@ -153,7 +153,7 @@ private void HandleProcessExit(object? sender, EventArgs args)
153153
// If SIGTERM was ignored by the target, then we'll still wait
154154
_process.WaitForExit();
155155

156-
Environment.ExitCode = _process.ExitCode;
156+
System.Environment.ExitCode = _process.ExitCode;
157157
}
158158

159159
private static bool SetKillOnJobClose(IntPtr job, bool value)

0 commit comments

Comments
 (0)