Merge pull request #1483 from lzybkr/if_unix

Change preprocessor macro LINUX to UNIX
This commit is contained in:
Jason Shirk authored and GitHub committed 2016-07-22 13:14:28 -07:00
commit 1c3361bf20
88 files changed
+167 -167

No files matched your search

@@ -10,7 +10,7 @@
"configurations": {
"Linux": {
"buildOptions": {
"define": ["LINUX"]
"define": ["UNIX"]
}
}
},
@@ -10,7 +10,7 @@
"configurations": {
"Linux": {
"buildOptions": {
"define": ["LINUX"]
"define": ["UNIX"]
}
}
},
@@ -10,7 +10,7 @@
"configurations": {
"Linux": {
"buildOptions": {
"define": ["LINUX"]
"define": ["UNIX"]
}
}
},
@@ -10,7 +10,7 @@
"configurations": {
"Linux": {
"buildOptions": {
"define": ["LINUX"]
"define": ["UNIX"]
}
}
},
@@ -10,7 +10,7 @@
"configurations": {
"Linux": {
"buildOptions": {
"define": ["LINUX"]
"define": ["UNIX"]
}
}
},
@@ -171,7 +171,7 @@
// or $env:programfiles\NuGet\Packages\ if you are an admin.
try
{
#if LINUX
#if UNIX
// there is only 1 installation location by default for linux ("HOME/.local/share/powershell/PackageManagement/NuGet/Packages")
string basePath = CurrentUserDefaultInstallLocation;
#else
@@ -220,7 +220,7 @@
get
{
#if CORECLR
#if LINUX
#if UNIX
return Path.Combine(Path.GetDirectoryName(Platform.SelectProductNameForDirectory(Platform.XDG_Type.DATA)), "PackageManagement", "NuGet", "Packages");
#else
return Path.Combine(Environment.GetEnvironmentVariable("LocalAppData"), "PackageManagement", "NuGet", "Packages");
@@ -237,7 +237,7 @@
get
{
#if CORECLR
#if LINUX
#if UNIX
return Path.Combine(Path.GetDirectoryName(Platform.SelectProductNameForDirectory(Platform.XDG_Type.DATA)), "PackageManagement", "NuGet", "Packages");
#else
return Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), "NuGet", "Packages");
@@ -1302,7 +1302,7 @@
}
} else {
#if LINUX
#if UNIX
var appdataFolder = Path.GetDirectoryName(Platform.SelectProductNameForDirectory(Platform.XDG_Type.CONFIG));
#else
var appdataFolder = Environment.GetEnvironmentVariable("appdata");
@@ -10,7 +10,7 @@
"configurations": {
"Linux": {
"buildOptions": {
"define": ["LINUX"]
"define": ["UNIX"]
}
}
},
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
//
// Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
//
// Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
using System;
using System.Collections.Generic;
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
//
// Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
//
// Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
//
// Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
//
// Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
//
// Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
//
// Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
//
// Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
//
// Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
namespace Microsoft.PackageManagement.PackageSourceListProvider
{
@@ -10,7 +10,7 @@
"configurations": {
"Linux": {
"buildOptions": {
"define": [ "LINUX" ]
"define": [ "UNIX" ]
}
}
},
@@ -81,7 +81,7 @@ namespace Microsoft.PackageManagement.Internal.Implementation {
/// <param name="providerPath"></param>
public void SetSwidTag(string providerPath)
{
#if !LINUX
#if !UNIX
if (!string.IsNullOrWhiteSpace(providerPath))
{
// check whether there is swidtag attached to the provider path
@@ -177,7 +177,7 @@ namespace Microsoft.PackageManagement.Internal.Implementation {
Debug(request, "Calling 'ProviderService::IsSignedAndTrusted, '{0}'", filename);
// we are not using this function anywhere
#if !LINUX
#if !UNIX
var wtd = new WinTrustData(filename);
var result = NativeMethods.WinVerifyTrust(new IntPtr(-1), new Guid("{00AAC56B-CD44-11d0-8CC2-00C04FC295EE}"), wtd);
@@ -19,7 +19,7 @@ namespace Microsoft.PackageManagement.Internal.Utility.Extensions {
internal static class ExceptionExtensions {
public static void Dump(this Exception e) {
#if !LINUX
#if !UNIX
var text = string.Format(CultureInfo.CurrentCulture, "{0}/{1}\r\n{2}", e.GetType().Name, e.Message, e.StackTrace);
// for now, this is the only way we'll see exceptions in the wild.
NativeMethods.OutputDebugString(text);
@@ -186,7 +186,7 @@ namespace Microsoft.PackageManagement.Internal.Utility.Extensions {
// is this a unc path?
if (string.IsNullOrWhiteSpace(pathUri.Host)) {
#if !LINUX
#if !UNIX
// no, this is a drive:\path path
// use API to resolve out the drive letter to see if it is a remote
var drive = pathUri.Segments[1].Replace('/', '\\'); // the zero segment is always just '/'
@@ -27,7 +27,7 @@ namespace Microsoft.PackageManagement.Internal.Utility.Platform {
/// </returns>
public static bool IsElevated {
get {
#if LINUX
#if UNIX
return string.Equals(System.Environment.GetEnvironmentVariable("SUDO_UID"), "1000");
#else
var id = WindowsIdentity.GetCurrent();
@@ -22,7 +22,7 @@ namespace Microsoft.PackageManagement.Internal.Utility.Platform {
internal static class Manifest {
private static readonly byte[] _utf = {0xef, 0xbb, 0xbf};
#if !LINUX
#if !UNIX
public static IEnumerable<XElement> LoadFrom(string filename) {
var manifests = new List<XElement>();
@@ -12,7 +12,7 @@
// limitations under the License.
//
#if !LINUX
#if !UNIX
namespace Microsoft.PackageManagement.Internal.Utility.Platform {
using System;
using System.Diagnostics.CodeAnalysis;
+1 -1
View File
@@ -10,7 +10,7 @@
"configurations": {
"Linux": {
"buildOptions": {
"define": [ "LINUX" ]
"define": [ "UNIX" ]
}
}
},
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
/********************************************************************++
Copyright (c) Microsoft Corporation. All rights reserved.
@@ -866,7 +866,7 @@ namespace Microsoft.PowerShell.Commands
private static string RetrieveProcessUserName(Process process, Cmdlet cmdlet)
{
string userName = null;
#if LINUX
#if UNIX
userName = Platform.NonWindowsGetUserFromPid(process.Id);
#else
IntPtr tokenUserInfo = IntPtr.Zero;
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
using System;
using System.Collections.Generic;
@@ -15,7 +15,7 @@
"configurations": {
"Linux": {
"buildOptions": {
"define": [ "LINUX" ]
"define": [ "UNIX" ]
}
}
},
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
/********************************************************************++
Copyright (c) Microsoft Corporation. All rights reserved.
--********************************************************************/
@@ -286,7 +286,7 @@ namespace Microsoft.PowerShell
#if LINUX
#if UNIX
/// <summary>
///
/// The break handler for the program. Dispatches a break event to the current Executor.
@@ -466,7 +466,7 @@ namespace Microsoft.PowerShell
// call the console APIs directly, instead of ui.rawui.FlushInputHandle, as ui may be finalized
// already if this thread is lagging behind the main thread.
#if !LINUX
#if !UNIX
ConsoleHandle handle = ConsoleControl.GetConioDeviceHandle();
ConsoleControl.FlushConsoleInputBuffer(handle);
#endif
@@ -1064,7 +1064,7 @@ namespace Microsoft.PowerShell
private void BindBreakHandler()
{
#if LINUX
#if UNIX
Console.CancelKeyPress += new ConsoleCancelEventHandler(MyBreakHandler);
#else
breakHandlerGcHandle = GCHandle.Alloc(new ConsoleControl.BreakHandler(MyBreakHandler));
@@ -1123,7 +1123,7 @@ namespace Microsoft.PowerShell
{
if (!isDisposed)
{
#if !LINUX
#if !UNIX
Dbg.Assert(breakHandlerGcHandle != null, "break handler should be set");
ConsoleControl.RemoveBreakHandler();
breakHandlerGcHandle.Free();
@@ -2872,7 +2872,7 @@ namespace Microsoft.PowerShell
/// </summary>
private RunspaceRef runspaceRef;
#if !LINUX
#if !UNIX
private GCHandle breakHandlerGcHandle;
#endif
private System.Threading.Thread breakHandlerThread;
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
/********************************************************************++
Copyright (c) Microsoft Corporation. All rights reserved.
--********************************************************************/
@@ -14,7 +14,7 @@ using System.Management.Automation.Internal;
using System.Management.Automation.Host;
using System.Security;
using Dbg = System.Management.Automation.Diagnostics;
#if !LINUX
#if !UNIX
using ConsoleHandle = Microsoft.Win32.SafeHandles.SafeFileHandle;
#endif
@@ -61,7 +61,7 @@ namespace Microsoft.PowerShell
this.parent = parent;
this.rawui = new ConsoleHostRawUserInterface(this);
#if LINUX
#if UNIX
this._supportsVirtualTerminal = true;
#else
try
@@ -297,7 +297,7 @@ namespace Microsoft.PowerShell
null;
SecureString secureResult = new SecureString();
StringBuilder result = new StringBuilder();
#if LINUX
#if UNIX
bool treatControlCAsInput = Console.TreatControlCAsInput;
#else
ConsoleHandle handle = ConsoleControl.GetConioDeviceHandle();
@@ -309,7 +309,7 @@ namespace Microsoft.PowerShell
try
{
#if LINUX
#if UNIX
Console.TreatControlCAsInput = true;
#else
// Ensure that we're in the proper line-input mode.
@@ -349,14 +349,14 @@ namespace Microsoft.PowerShell
// end up having a immutable string holding the
// secret in memory.
//
#if LINUX
#if UNIX
ConsoleKeyInfo keyInfo = Console.ReadKey(true);
#else
uint unused = 0;
string key = ConsoleControl.ReadConsole(handle, string.Empty, 1, false, out unused);
#endif
#if LINUX
#if UNIX
// Handle Ctrl-C ending input
if (keyInfo.Key == ConsoleKey.C && keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control))
#else
@@ -366,7 +366,7 @@ namespace Microsoft.PowerShell
PipelineStoppedException e = new PipelineStoppedException();
throw e;
}
#if LINUX
#if UNIX
if (keyInfo.Key == ConsoleKey.Enter)
#else
if ((char)13 == key[0])
@@ -377,7 +377,7 @@ namespace Microsoft.PowerShell
//
break;
}
#if LINUX
#if UNIX
if (keyInfo.Key == ConsoleKey.Backspace)
#else
if ((char)8 == key[0])
@@ -397,7 +397,7 @@ namespace Microsoft.PowerShell
WriteBackSpace(originalCursorPos);
}
}
#if LINUX
#if UNIX
else if (Char.IsControl(keyInfo.KeyChar))
{
// blacklist control characters
@@ -411,7 +411,7 @@ namespace Microsoft.PowerShell
//
if (isSecureString)
{
#if LINUX
#if UNIX
secureResult.AppendChar(keyInfo.KeyChar);
#else
secureResult.AppendChar(key[0]);
@@ -419,7 +419,7 @@ namespace Microsoft.PowerShell
}
else
{
#if LINUX
#if UNIX
result.Append(keyInfo.KeyChar);
#else
result.Append(key);
@@ -433,7 +433,7 @@ namespace Microsoft.PowerShell
}
while (true);
}
#if LINUX
#if UNIX
catch (InvalidOperationException)
{
// ReadKey() failed so we stop
@@ -442,7 +442,7 @@ namespace Microsoft.PowerShell
#endif
finally
{
#if LINUX
#if UNIX
Console.TreatControlCAsInput = treatControlCAsInput;
#else
if (isModeChanged)
@@ -573,7 +573,7 @@ namespace Microsoft.PowerShell
}
#if !LINUX
#if !UNIX
/// <summary>
///
/// If <paramref name="m"/> is set on <paramref name="flagToUnset"/>, unset it and return true;
@@ -611,7 +611,7 @@ namespace Microsoft.PowerShell
internal void WriteToConsole(string value, bool transcribeResult)
{
#if !LINUX
#if !UNIX
ConsoleHandle handle = ConsoleControl.GetActiveScreenBufferHandle();
// Ensure that we're in the proper line-output mode. We don't lock here as it does not matter if we
@@ -634,7 +634,7 @@ namespace Microsoft.PowerShell
// This is atomic, so we don't lock here...
#if !LINUX
#if !UNIX
ConsoleControl.WriteConsole(handle, value);
#else
Console.Out.Write(value);
@@ -1691,7 +1691,7 @@ namespace Microsoft.PowerShell
PreRead();
// Ensure that we're in the proper line-input mode.
#if !LINUX
#if !UNIX
ConsoleHandle handle = ConsoleControl.GetConioDeviceHandle();
ConsoleControl.ConsoleModes m = ConsoleControl.GetMode(handle);
@@ -1723,7 +1723,7 @@ namespace Microsoft.PowerShell
// If input is terminated with a break key (Ctrl-C, Ctrl-Break, Close, etc.), then the buffer will be
// the empty string.
#if LINUX
#if UNIX
// For Unix systems, we implement a basic readline loop around Console.ReadKey(), that
// supports backspace, arrow keys, Ctrl-C, and Ctrl-D. This readline is only used for
// interactive prompts (like Read-Host), otherwise it is assumed that PSReadLine is
@@ -1748,14 +1748,14 @@ namespace Microsoft.PowerShell
#endif
do
{
#if LINUX
#if UNIX
keyInfo = Console.ReadKey(true);
#else
s += ConsoleControl.ReadConsole(handle, initialContent, maxInputLineLength, endOnTab, out keyState);
Dbg.Assert(s != null, "s should never be null");
#endif
#if LINUX
#if UNIX
// Handle Ctrl-C ending input
if (keyInfo.Key == ConsoleKey.C && keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control))
#else
@@ -1774,14 +1774,14 @@ namespace Microsoft.PowerShell
break;
}
#if LINUX
#if UNIX
if (keyInfo.Key == ConsoleKey.Enter)
#else
if (s.EndsWith(Crlf, StringComparison.CurrentCulture))
#endif
{
result = ReadLineResult.endedOnEnter;
#if LINUX
#if UNIX
// We're intercepting characters, so we need to echo the newline
Console.Out.WriteLine();
#else
@@ -1790,7 +1790,7 @@ namespace Microsoft.PowerShell
break;
}
#if LINUX
#if UNIX
if (keyInfo.Key == ConsoleKey.Tab)
{
// This is unsupported
@@ -1847,7 +1847,7 @@ namespace Microsoft.PowerShell
break;
}
#endif
#if LINUX
#if UNIX
if (keyInfo.Key == ConsoleKey.Backspace)
{
if (index > 0)
@@ -1969,7 +1969,7 @@ namespace Microsoft.PowerShell
"s should only be null if input ended with a break");
return s;
#if LINUX
#if UNIX
}
finally
{
@@ -1978,7 +1978,7 @@ namespace Microsoft.PowerShell
#endif
}
#if !LINUX
#if !UNIX
/// <summary>
/// Get the character at the cursor when the user types 'tab' in the middle of line.
/// </summary>
@@ -2052,7 +2052,7 @@ namespace Microsoft.PowerShell
ReadLineResult rlResult = ReadLineResult.endedOnEnter;
#if !LINUX
#if !UNIX
ConsoleHandle handle = ConsoleControl.GetActiveScreenBufferHandle();
string lastCompletion = "";
@@ -2086,7 +2086,7 @@ namespace Microsoft.PowerShell
break;
}
#if LINUX // Portable code only ends on enter (or no input), so tab is not processed
#if UNIX // Portable code only ends on enter (or no input), so tab is not processed
throw new PlatformNotSupportedException("This readline state is unsupported in portable code!");
#else
@@ -2212,7 +2212,7 @@ namespace Microsoft.PowerShell
return input;
}
#if !LINUX
#if !UNIX
private void SendLeftArrows(int length)
{
var inputs = new ConsoleControl.INPUT[length * 2];
@@ -51,7 +51,7 @@
"configurations": {
"Linux": {
"buildOptions": {
"define": [ "LINUX" ]
"define": [ "UNIX" ]
}
}
},
@@ -13,7 +13,7 @@
"configurations": {
"Linux": {
"buildOptions": {
"define": [ "LINUX" ]
"define": [ "UNIX" ]
}
}
},
@@ -73,7 +73,7 @@ namespace Microsoft.PowerShell
public class PSConsoleReadlineOptions
{
#if LINUX // TODO: why different schemes for LINUX?
#if UNIX // TODO: why different schemes for LINUX?
public const ConsoleColor DefaultCommentForegroundColor = ConsoleColor.Magenta;
public const ConsoleColor DefaultOperatorForegroundColor = ConsoleColor.Gray;
public const ConsoleColor DefaultParameterForegroundColor = ConsoleColor.Green;
@@ -93,7 +93,7 @@ namespace Microsoft.PowerShell
public const ConsoleColor DefaultErrorForegroundColor = ConsoleColor.Red;
public const EditMode DefaultEditMode =
#if LINUX
#if UNIX
EditMode.Emacs;
#else
EditMode.Windows;
@@ -168,7 +168,7 @@ namespace Microsoft.PowerShell
HistorySaveStyle = DefaultHistorySaveStyle;
string historyFileName = hostName + "_history.txt";
#if LINUX
#if UNIX
// PSReadline does not have access to Utils.CorePSPlatform. Must set PSReadline path separately
string historyPath = System.Environment.GetEnvironmentVariable("XDG_DATA_HOME");
@@ -6,7 +6,7 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
#if LINUX
#if UNIX
using System.Reflection;
#endif
using System.Runtime.InteropServices;
@@ -214,7 +214,7 @@ namespace Microsoft.PowerShell
{
// default for unprintables and unhandled
char keyChar = '\u0000';
#if LINUX
#if UNIX
Type keyType = typeof (Keys);
FieldInfo[] keyFields = keyType.GetFields();
@@ -314,13 +314,13 @@ namespace Microsoft.PowerShell.Internal
public char UnicodeChar;
public ConsoleColor ForegroundColor;
public ConsoleColor BackgroundColor;
#if !LINUX
#if !UNIX
public bool IsLeadByte;
public bool IsTrailByte;
#endif
public bool Inverse;
#if !LINUX
#if !UNIX
public CHAR_INFO ToCharInfo()
{
int fg = (int) ForegroundColor;
@@ -386,7 +386,7 @@ namespace Microsoft.PowerShell.Internal
sb.Append("Alt");
}
#if LINUX
#if UNIX
if (sb.Length > 0)
sb.Append("+");
// TODO: find better way to map these characters to something more friendly
@@ -429,7 +429,7 @@ namespace Microsoft.PowerShell.Internal
}
}
#if !LINUX
#if !UNIX
internal class ConhostConsole : IConsole
{
[SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")]
@@ -161,7 +161,7 @@ namespace Microsoft.PowerShell
{ Keys.CtrlSpace, MakeKeyHandler(MenuComplete, "MenuComplete") },
{ Keys.Tab, MakeKeyHandler(TabCompleteNext, "TabCompleteNext") },
{ Keys.ShiftTab, MakeKeyHandler(TabCompletePrevious, "TabCompletePrevious") },
#if !LINUX
#if !UNIX
{ Keys.VolumeDown, MakeKeyHandler(Ignore, "Ignore") },
{ Keys.VolumeUp, MakeKeyHandler(Ignore, "Ignore") },
{ Keys.VolumeMute, MakeKeyHandler(Ignore, "Ignore") },
@@ -200,7 +200,7 @@ namespace Microsoft.PowerShell
{ Keys.ShiftF3, MakeKeyHandler(CharacterSearchBackward, "CharacterSearchBackward") },
{ Keys.F8, MakeKeyHandler(HistorySearchBackward, "HistorySearchBackward") },
{ Keys.ShiftF8, MakeKeyHandler(HistorySearchForward, "HistorySearchForward") },
#if !LINUX
#if !UNIX
{ Keys.PageUp, MakeKeyHandler(ScrollDisplayUp, "ScrollDisplayUp") },
{ Keys.PageDown, MakeKeyHandler(ScrollDisplayDown, "ScrollDisplayDown") },
{ Keys.CtrlPageUp, MakeKeyHandler(ScrollDisplayUpLine, "ScrollDisplayUpLine") },
@@ -284,7 +284,7 @@ namespace Microsoft.PowerShell
{ Keys.AltPeriod, MakeKeyHandler(YankLastArg, "YankLastArg") },
{ Keys.AltUnderbar, MakeKeyHandler(YankLastArg, "YankLastArg") },
{ Keys.AltCtrlY, MakeKeyHandler(YankNthArg, "YankNthArg") },
#if !LINUX
#if !UNIX
{ Keys.VolumeDown, MakeKeyHandler(Ignore, "Ignore") },
{ Keys.VolumeUp, MakeKeyHandler(Ignore, "Ignore") },
{ Keys.VolumeMute, MakeKeyHandler(Ignore, "Ignore") },
@@ -70,7 +70,7 @@ namespace Microsoft.PowerShell
{ Keys.Tab, MakeKeyHandler(ViTabCompleteNext, "ViTabCompleteNext") },
{ Keys.ShiftTab, MakeKeyHandler(ViTabCompletePrevious, "ViTabCompletePrevious") },
{ Keys.CtrlV, MakeKeyHandler(Paste, "Paste") },
#if !LINUX
#if !UNIX
{ Keys.VolumeDown, MakeKeyHandler(Ignore, "Ignore") },
{ Keys.VolumeUp, MakeKeyHandler(Ignore, "Ignore") },
{ Keys.VolumeMute, MakeKeyHandler(Ignore, "Ignore") },
@@ -109,7 +109,7 @@ namespace Microsoft.PowerShell
{ Keys.Tab, MakeKeyHandler(TabCompleteNext, "TabCompleteNext") },
{ Keys.ShiftTab, MakeKeyHandler(TabCompletePrevious, "TabCompletePrevious") },
{ Keys.CtrlV, MakeKeyHandler(Paste, "Paste") },
#if !LINUX
#if !UNIX
{ Keys.VolumeDown, MakeKeyHandler(Ignore, "Ignore") },
{ Keys.VolumeUp, MakeKeyHandler(Ignore, "Ignore") },
{ Keys.VolumeMute, MakeKeyHandler(Ignore, "Ignore") },
+1 -1
View File
@@ -290,7 +290,7 @@ namespace Microsoft.PowerShell
public static ConsoleKeyInfo ShiftF8 = new ConsoleKeyInfo((char)0, ConsoleKey.F8, true, false, false);
// Keys to ignore
#if !LINUX
#if !UNIX
public static ConsoleKeyInfo VolumeUp = new ConsoleKeyInfo((char)0, /*ConsoleKey.VolumeUp*/(ConsoleKey)175, false, false, false);
public static ConsoleKeyInfo VolumeDown = new ConsoleKeyInfo((char)0, /*ConsoleKey.VolumeDown*/(ConsoleKey)174, false, false, false);
public static ConsoleKeyInfo VolumeMute = new ConsoleKeyInfo((char)0, /*ConsoleKey.VolumeMute*/(ConsoleKey)173, false, false, false);
@@ -434,7 +434,7 @@ namespace Microsoft.PowerShell
public static void ClearScreen(ConsoleKeyInfo? key = null, object arg = null)
{
var console = _singleton._console;
#if LINUX // TODO: this is not correct, it should only scroll
#if UNIX // TODO: this is not correct, it should only scroll
console.Clear();
_singleton._initialY = 0;
_singleton.Render();
@@ -55,7 +55,7 @@ namespace Microsoft.PowerShell
void StartRender();
int LengthInBufferCells(char c);
void EndRender();
#if LINUX
#if UNIX
void Clear();
#endif
}
@@ -34,7 +34,7 @@ namespace Microsoft.PowerShell
private IConsole _console;
private EngineIntrinsics _engineIntrinsics;
#if !LINUX
#if !UNIX
private static GCHandle _breakHandlerGcHandle;
#endif
private Thread _readKeyThread;
@@ -479,7 +479,7 @@ namespace Microsoft.PowerShell
private PSConsoleReadLine()
{
_mockableMethods = this;
#if LINUX
#if UNIX
_console = new TTYConsole();
#else
_console = new ConhostConsole();
@@ -558,7 +558,7 @@ namespace Microsoft.PowerShell
_statusIsErrorMessage = false;
_consoleBuffer = ReadBufferLines(_initialY, 1 + Options.ExtraPromptLineCount);
#if LINUX // TODO: not necessary if ReadBufferLines worked, or if rendering worked on spans instead of complete lines
#if UNIX // TODO: not necessary if ReadBufferLines worked, or if rendering worked on spans instead of complete lines
string newPrompt = GetPrompt();
for (int i=0; i<newPrompt.Length; ++i)
{
@@ -612,7 +612,7 @@ namespace Microsoft.PowerShell
}
}
#if LINUX
#if UNIX
_historyFileMutex = new Mutex(false);
#else
_historyFileMutex = new Mutex(false, GetHistorySaveFileMutexName());
@@ -649,7 +649,7 @@ namespace Microsoft.PowerShell
_killIndex = -1; // So first add indexes 0.
_killRing = new List<string>(Options.MaximumKillRingCount);
#if !LINUX
#if !UNIX
_breakHandlerGcHandle = GCHandle.Alloc(new BreakHandler(_singleton.BreakHandler));
NativeMethods.SetConsoleCtrlHandler((BreakHandler)_breakHandlerGcHandle.Target, true);
#endif
@@ -865,7 +865,7 @@ namespace Microsoft.PowerShell
_singleton._initialX = _singleton._console.CursorLeft;
_singleton._consoleBuffer = ReadBufferLines(_singleton._initialY, 1 + _singleton.Options.ExtraPromptLineCount);
#if LINUX // TODO: ReadBufferLines only needed for extra line, but doesn't work on Linux
#if UNIX // TODO: ReadBufferLines only needed for extra line, but doesn't work on Linux
for (int i=0; i<newPrompt.Length; ++i)
{
_singleton._consoleBuffer[i].UnicodeChar = newPrompt[i];
@@ -13,7 +13,7 @@ namespace Microsoft.PowerShell
{
public partial class PSConsoleReadLine
{
#if LINUX
#if UNIX
private const ConsoleColor UnknownColor = (ConsoleColor) (-1);
#endif
private BufferChar[] _consoleBuffer;
@@ -228,7 +228,7 @@ namespace Microsoft.PowerShell
MaybeEmphasize(ref _consoleBuffer[j++], i, foregroundColor, backgroundColor);
}
#if !LINUX
#if !UNIX
else if (size > 1)
{
_consoleBuffer[j].UnicodeChar = charToRender;
@@ -313,7 +313,7 @@ namespace Microsoft.PowerShell
if ((_initialY + bufferLineCount) > (_console.WindowTop + _console.WindowHeight))
{
#if !LINUX // TODO: verify this isn't necessary for LINUX
#if !UNIX // TODO: verify this isn't necessary for LINUX
_console.WindowTop = _initialY + bufferLineCount - _console.WindowHeight;
#endif
}
@@ -466,7 +466,7 @@ namespace Microsoft.PowerShell
// to invert only the lower 3 bits to change the color is somewhat
// but looks best with the 2 default color schemes - starting PowerShell
// from it's shortcut or from a cmd shortcut.
#if LINUX // TODO: set Inverse attribute and let render choose what to do.
#if UNIX // TODO: set Inverse attribute and let render choose what to do.
ConsoleColor tempColor = (foregroundColor == UnknownColor) ? ConsoleColor.White : foregroundColor;
foregroundColor = (backgroundColor == UnknownColor) ? ConsoleColor.Black : backgroundColor;
backgroundColor = tempColor;
@@ -656,7 +656,7 @@ namespace Microsoft.PowerShell
case BellStyle.None:
break;
case BellStyle.Audible:
#if LINUX
#if UNIX
Console.Beep();
#else
Console.Beep(Options.DingTone, Options.DingDuration);
@@ -690,7 +690,7 @@ namespace Microsoft.PowerShell
#region Screen scrolling
#if !LINUX
#if !UNIX
/// <summary>
/// Scroll the display up one screen.
/// </summary>
@@ -2,7 +2,7 @@
Copyright (c) Microsoft Corporation. All rights reserved.
--********************************************************************/
#if !LINUX
#if !UNIX
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
@@ -13,7 +13,7 @@
"configurations": {
"Linux": {
"buildOptions": {
"define": [ "LINUX" ]
"define": [ "UNIX" ]
}
}
},
@@ -477,7 +477,7 @@ namespace Microsoft.PowerShell.PackageManagement.Cmdlets {
#region Event and telemetry stuff
//Calling PowerShell Telemetry APIs
protected void TraceMessage(string message, SoftwareIdentity swidObject) {
#if !LINUX
#if !UNIX
TelemetryAPI.TraceMessage(message,
new {
PackageName = swidObject.Name,
@@ -510,7 +510,7 @@ namespace Microsoft.PowerShell.PackageManagement.Cmdlets {
protected void LogEvent(EventTask task, EventId id, string context, string name, string version, string providerName, string source, string status, string destinationPath)
{
#if !LINUX
#if !UNIX
var iis = InitialSessionState.CreateDefault2();
using (Runspace rs = RunspaceFactory.CreateRunspace(iis))
@@ -10,7 +10,7 @@
"configurations": {
"Linux": {
"buildOptions": {
"define": ["LINUX"]
"define": ["UNIX"]
}
}
},
@@ -15,7 +15,7 @@
"configurations": {
"Linux": {
"buildOptions": {
"define": [ "LINUX" ]
"define": [ "UNIX" ]
}
}
},
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
/********************************************************************++
Copyright (c) Microsoft Corporation. All rights reserved.
@@ -893,7 +893,7 @@ namespace System.Management.Automation
return GetEnvironmentVariables();
}
#if LINUX
#if UNIX
return null;
#else
@@ -954,7 +954,7 @@ namespace System.Management.Automation
return System.Environment.GetEnvironmentVariable(variable);
}
#if LINUX
#if UNIX
return null;
#else
@@ -1409,7 +1409,7 @@ namespace System.Management.Automation.Security
}
#if LINUX
#if UNIX
// Porting note: Tracing is absolutely not available on Linux
namespace System.Management.Automation.Tracing
@@ -19,7 +19,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'UNIX|AnyCPU'">
<OutputPath>bin\UNIX\</OutputPath>
<DefineConstants>DEBUG;CORECLR;LINUX;NOT_SIGNED</DefineConstants>
<DefineConstants>DEBUG;CORECLR;UNIX;NOT_SIGNED</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'CORECLR|AnyCPU'">
<OutputPath>bin\CORECLR\</OutputPath>
@@ -4464,7 +4464,7 @@ namespace System.Management.Automation
internal static List<string> GetFileShares(string machine, bool ignoreHidden)
{
#if LINUX
#if UNIX
return new List<string>();
#else
IntPtr shBuf;
@@ -1905,7 +1905,7 @@ namespace System.Management.Automation
{
string result = null;
#if !LINUX
#if !UNIX
try
{
RegistryKey shellKey = Registry.LocalMachine.OpenSubKey(Utils.GetRegistryConfigurationPath(shellID));
@@ -5286,8 +5286,8 @@ end
"Stop-Service", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("sv",
"Set-Variable", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
// Porting note: #if !LINUX is used to disable alises for cmdlets which conflict with Linux / OS X
#if !LINUX
// Porting note: #if !UNIX is used to disable alises for cmdlets which conflict with Linux / OS X
#if !UNIX
// ac is a native command on OS X
new SessionStateAliasEntry("ac",
"Add-Content", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
@@ -5510,14 +5510,14 @@ if($paths) {
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("more", DefaultMoreFunctionText, isProductCode: true),
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("help", GetHelpPagingFunctionText(), isProductCode: true),
// Porting note: we remove mkdir on Linux because it is a conflict
#if !LINUX
#if !UNIX
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("mkdir", GetMkdirFunctionText(), isProductCode: true),
#endif
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("Get-Verb", GetGetVerbText(), isProductCode: true),
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("oss", GetOSTFunctionText(), isProductCode: true),
// Porting note: we remove the drive functions from Linux because they make no sense
#if !LINUX
#if !UNIX
// Default drives
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("A:", DefaultSetDriveFunctionText, SetDriveScriptBlock),
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("B:", DefaultSetDriveFunctionText, SetDriveScriptBlock),
@@ -103,7 +103,7 @@ namespace System.Management.Automation
{
Version version = null;
#if !LINUX
#if !UNIX
try
{
using (RegistryKey wsManStackVersionKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\WSMAN"))
@@ -87,7 +87,7 @@ namespace System.Management.Automation
CommandOrigin origin,
PSHost host)
{
#if LINUX
#if UNIX
// TODO:PSL this is a workaround since the exception below
// hides the internal issue of what's going on in terms of
// execution policy.
@@ -1469,7 +1469,7 @@ namespace System.Management.Automation
bool driveIsValid = true;
// If the drive is auto-mounted, ensure that it still exists, or remove the drive.
#if !LINUX
#if !UNIX
if (drive.IsAutoMounted || IsAStaleVhdMountedDrive(drive))
{
driveIsValid = ValidateOrRemoveAutoMountedDrive(drive, lookupScope);
@@ -359,7 +359,7 @@ namespace System.Management.Automation
/// </summary>
internal static bool IsWinPEHost()
{
#if !LINUX
#if !UNIX
RegistryKey winPEKey = null;
try
@@ -616,7 +616,7 @@ namespace System.Management.Automation
internal static Dictionary<string, object> GetGroupPolicySetting(string groupPolicyBase, string settingName, RegistryKey[] preferenceOrder)
{
#if LINUX
#if UNIX
return _emptyDictionary;
#else
lock (cachedGroupPolicySettings)
@@ -927,7 +927,7 @@ namespace System.Management.Automation
// permissions. To fit into PowerShell's existing model of pre-emptively checking
// permissions (which cannot be assumed on Unix), we "assume" the user is an
// administrator by returning true, thus nullifying this check on Unix.
#if LINUX
#if UNIX
return true;
#else
System.Security.Principal.WindowsIdentity currentIdentity = System.Security.Principal.WindowsIdentity.GetCurrent();
@@ -956,7 +956,7 @@ namespace System.Management.Automation
isDirectory = false;
return false;
}
#if LINUX
#if UNIX
isDirectory = Platform.NonWindowsIsDirectory(path);
return Platform.NonWindowsIsFile(path);
#else
@@ -1093,7 +1093,7 @@ namespace System.Management.Automation
internal static bool PathIsUnc(string path)
{
#if LINUX
#if UNIX
return false;
#else
Uri uri;
@@ -96,7 +96,7 @@ namespace Microsoft.PowerShell.Commands
/// </summary>
internal static void CheckRemotingCmdletPrerequisites()
{
#if LINUX
#if UNIX
// TODO: check that PSRP requirements are installed
return;
#else
@@ -2303,7 +2303,7 @@ namespace System.Management.Automation.Remoting.Client
#region DllImports ClientAPI
#if !LINUX
#if !UNIX
internal const string WSManApiDll = @"WsmSvc.dll";
#else
internal const string WSManApiDll = @"libpsrpomiprov";
@@ -2971,7 +2971,7 @@ namespace System.Management.Automation.Remoting.Client
IntPtr requestDetails,
int flags,
IntPtr context);
#if LINUX
#if UNIX
/// <summary>
/// Registers the shutdown callback.
/// </summary>
@@ -3073,7 +3073,7 @@ namespace System.Management.Automation.Remoting.Client
IntPtr shutdownCallback,
IntPtr shutdownContext)
{
#if LINUX
#if UNIX
WSManNativeApi.WSManPluginRegisterShutdownCallback(requestDetails, shutdownCallback, shutdownContext);
#endif
}
@@ -677,7 +677,7 @@ namespace System.Management.Automation.Language
private static TypeInfo GetComObjectType()
{
#if LINUX
#if UNIX
return null;
#else
return typeof(object).GetTypeInfo().Assembly.GetType("System.__ComObject").GetTypeInfo();
@@ -700,7 +700,7 @@ namespace Microsoft.PowerShell.Commands
this.WriteVerbose(string.Format(CultureInfo.InvariantCulture, HelpDisplayStrings.OnlineHelpUri, uriToLaunch.OriginalString));
System.Diagnostics.Process browserProcess = new System.Diagnostics.Process();
#if LINUX
#if UNIX
browserProcess.StartInfo.FileName = Platform.IsLinux ? "xdg-open" : /* OS X */ "open";
browserProcess.StartInfo.Arguments = uriToLaunch.OriginalString;
browserProcess.Start();
@@ -172,7 +172,7 @@ namespace System.Management.Automation
#endif
Collection<LogProvider> providers = new Collection<LogProvider>();
// Porting note: Linux does not support ETW
#if !LINUX
#if !UNIX
try
{
#if !CORECLR //TODO:CORECLR EventLogLogProvider not handled yet
@@ -607,7 +607,7 @@ namespace Microsoft.PowerShell.Commands
/// </returns>
protected override PSDriveInfo RemoveDrive(PSDriveInfo drive)
{
#if LINUX
#if UNIX
return drive;
#else
return WinRemoveDrive(drive);
@@ -681,7 +681,7 @@ namespace Microsoft.PowerShell.Commands
/// <returns></returns>
internal static string GetUNCForNetworkDrive(string driveName)
{
#if LINUX
#if UNIX
return driveName;
#else
return WinGetUNCForNetworkDrive(driveName);
@@ -739,7 +739,7 @@ namespace Microsoft.PowerShell.Commands
/// <returns></returns>
internal static string GetSubstitutedPathForNetworkDosDevice(string driveName)
{
#if LINUX
#if UNIX
throw new PlatformNotSupportedException();
#else
return WinGetSubstitutedPathForNetworkDosDevice(driveName);
@@ -919,7 +919,7 @@ namespace Microsoft.PowerShell.Commands
// the platform itself then has no real network drive support
// as required by this context. Solution: check for network
// drive support before using it.
#if LINUX
#if UNIX
continue;
#else
displayRoot = GetRootPathForNetworkDriveOrDosDevice(newDrive);
@@ -936,7 +936,7 @@ namespace Microsoft.PowerShell.Commands
root = newDrive.RootDirectory.FullName;
}
#if LINUX
#if UNIX
// Porting notes: On platforms with single root filesystems, only
// add the filesystem with the root "/" to the initial drive list,
// otherwise path handling will not work correctly because there
@@ -1324,7 +1324,7 @@ namespace Microsoft.PowerShell.Commands
{
System.Diagnostics.Process invokeProcess = new System.Diagnostics.Process();
#if LINUX
#if UNIX
invokeProcess.StartInfo.FileName = Platform.IsLinux ? "xdg-open" : /* OS X */ "open";
invokeProcess.StartInfo.Arguments = path;
invokeProcess.Start();
@@ -6962,7 +6962,7 @@ namespace Microsoft.PowerShell.Commands
internal static int SafeGetFileAttributes(string path)
{
#if LINUX
#if UNIX
System.IO.FileAttributes attr = System.IO.File.GetAttributes(path);
int result = 0;
@@ -7064,7 +7064,7 @@ namespace Microsoft.PowerShell.Commands
/// <returns></returns>
internal static bool PathIsNetworkPath(string path)
{
#if LINUX
#if UNIX
return false;
#else
return WinPathIsNetworkPath(path);
@@ -8585,7 +8585,7 @@ namespace Microsoft.PowerShell.Commands
private static SafeFileHandle OpenReparsePoint(string reparsePoint, FileDesiredAccess accessMode)
{
#if LINUX
#if UNIX
throw new PlatformNotSupportedException();
#else
return WinOpenReparsePoint(reparsePoint,accessMode);
@@ -1589,7 +1589,7 @@ namespace System.Management.Automation
/// </returns>
internal static bool IsSingleFileSystemAbsolutePath(string path)
{
#if LINUX
#if UNIX
return path.StartsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal)
|| path.StartsWith(StringLiterals.AlternatePathSeparatorString, StringComparison.Ordinal);
#else
@@ -136,7 +136,7 @@ namespace Microsoft.PowerShell.Commands
{
Collection<PSDriveInfo> drives = new Collection<PSDriveInfo>();
#if !LINUX
#if !UNIX
drives.Add(
new PSDriveInfo(
"HKLM",
@@ -58,7 +58,7 @@ namespace Microsoft.PowerShell.Commands.Internal
override protected bool ReleaseHandle()
{
#if LINUX
#if UNIX
return true;
#else
// Returns a Win32 error code, 0 for success
@@ -15,7 +15,7 @@
"configurations": {
"Linux": {
"buildOptions": {
"define": [ "LINUX" ]
"define": [ "UNIX" ]
}
}
},
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
/********************************************************************++
Copyright (c) Microsoft Corporation. All rights reserved.
@@ -138,7 +138,7 @@ namespace System.Management.Automation
internal static void SetExecutionPolicy(ExecutionPolicyScope scope, ExecutionPolicy policy, string shellId)
{
#if LINUX
#if UNIX
throw new PlatformNotSupportedException();
#else
string executionPolicy = "Restricted";
@@ -282,7 +282,7 @@ namespace System.Management.Automation
internal static ExecutionPolicy GetExecutionPolicy(string shellId, ExecutionPolicyScope scope)
{
#if LINUX
#if UNIX
return ExecutionPolicy.Unrestricted;
#else
switch (scope)
@@ -429,7 +429,7 @@ namespace System.Management.Automation
return false;
}
#if LINUX
#if UNIX
// There is no signature support on non-Windows platforms (yet), when
// execution reaches here, we are sure the file is under product folder
return true;
@@ -1631,7 +1631,7 @@ namespace System.Management.Automation
/// <returns>AMSI_RESULT_DETECTED if malware was detected in the sample.</returns>
internal static AmsiNativeMethods.AMSI_RESULT ScanContent(string content, string sourceMetadata)
{
#if LINUX
#if UNIX
return AmsiNativeMethods.AMSI_RESULT.AMSI_RESULT_NOT_DETECTED;
#else
return WinScanContent(content,sourceMetadata);
@@ -1725,7 +1725,7 @@ namespace System.Management.Automation
internal static void CurrentDomain_ProcessExit(object sender, EventArgs e)
{
#if !LINUX
#if !UNIX
VerifyAmsiUninitializeCalled();
#endif
}
@@ -1743,7 +1743,7 @@ namespace System.Management.Automation
/// </summary>
internal static void CloseSession()
{
#if !LINUX
#if !UNIX
WinCloseSession();
#endif
}
@@ -1772,7 +1772,7 @@ namespace System.Management.Automation
/// </summary>
internal static void Uninitialize()
{
#if !LINUX
#if !UNIX
WinUninitialize();
#endif
}
@@ -130,7 +130,7 @@ namespace System.Management.Automation
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static bool IsComObject(this Type type)
{
#if LINUX
#if UNIX
return false;
#elif CORECLR // Type.IsComObject(Type) is not in CoreCLR
return ComObjectType.IsAssignableFrom(type);
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
//
// Copyright (C) Microsoft. All rights reserved.
//
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
//
// Copyright (C) Microsoft. All rights reserved.
//
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
//-----------------------------------------------------------------------
// <copyright file="EtwActivityReverter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
//-----------------------------------------------------------------------
// <copyright file="EtwActivityReverterMethodInvoker.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
//-----------------------------------------------------------------------
// <copyright file="EtwEventCorrelator.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
//-----------------------------------------------------------------------
// <copyright file="IMethodInvoker.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
//
// Copyright (C) Microsoft. All rights reserved.
//
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
//
// Copyright (C) Microsoft. All rights reserved.
//
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
//
// Copyright (C) Microsoft. All rights reserved.
//
@@ -1,4 +1,4 @@
#if !LINUX
#if !UNIX
using System;
using System.Collections;
using System.Diagnostics.Eventing;