diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/ClearRecycleBinCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/ClearRecycleBinCommand.cs index 5c67e1899..60653a6de 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/ClearRecycleBinCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/ClearRecycleBinCommand.cs @@ -1,5 +1,4 @@ -#if !CORECLR -using System; +using System; using System.Management.Automation; using System.Runtime.InteropServices; using System.IO; @@ -252,5 +251,4 @@ namespace Microsoft.PowerShell.Commands [DllImport("Shell32.dll", CharSet = CharSet.Unicode)] internal static extern uint SHEmptyRecycleBin(IntPtr hwnd, string pszRootPath, RecycleFlags dwFlags); } -} -#endif +} \ No newline at end of file diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/CommitTransactionCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/CommitTransactionCommand.cs index 6c77912b9..63669c7e5 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/CommitTransactionCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/CommitTransactionCommand.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -33,5 +32,3 @@ namespace Microsoft.PowerShell.Commands } // namespace Microsoft.PowerShell.Commands - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs index 978a492d9..88a2ee2b1 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -7385,5 +7384,3 @@ $result #endregion }//End namespace - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Eventlog.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Eventlog.cs index 4473fb52f..15059f3e7 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Eventlog.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Eventlog.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -1632,5 +1631,3 @@ namespace Microsoft.PowerShell.Commands }//Microsoft.PowerShell.Commands - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/GetClipboardCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/GetClipboardCommand.cs index 99ab75198..9db034e2c 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/GetClipboardCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/GetClipboardCommand.cs @@ -1,5 +1,4 @@ -#if !CORECLR -using System; +using System; using System.Management.Automation; using System.Collections.Generic; using System.Windows.Forms; @@ -201,5 +200,4 @@ namespace Microsoft.PowerShell.Commands return result; } } -} -#endif +} \ No newline at end of file diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/GetTransactionCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/GetTransactionCommand.cs index aedba2dbd..366b6274d 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/GetTransactionCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/GetTransactionCommand.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -27,5 +26,3 @@ namespace Microsoft.PowerShell.Commands } // namespace Microsoft.PowerShell.Commands - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/GetWMIObjectCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/GetWMIObjectCommand.cs index e3aad4779..c2e6736f1 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/GetWMIObjectCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/GetWMIObjectCommand.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -469,5 +468,3 @@ namespace Microsoft.PowerShell.Commands } // namespace Microsoft.PowerShell.Commands - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Hotfix.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Hotfix.cs index 8af70ed1c..e693b0f69 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Hotfix.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Hotfix.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -277,5 +276,3 @@ namespace Microsoft.PowerShell.Commands #endregion }//Microsoft.Powershell.commands - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/InvokeWMIMethodCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/InvokeWMIMethodCommand.cs index 68206ef9a..904d4a909 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/InvokeWMIMethodCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/InvokeWMIMethodCommand.cs @@ -1,4 +1,3 @@ -#if !CORECLR // // Copyright (C) Microsoft. All rights reserved. // @@ -299,5 +298,3 @@ namespace Microsoft.PowerShell.Commands #endregion Command code }//InvokeWMIObject } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/ParsePathCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/ParsePathCommand.cs index 341d713ac..4f137484d 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/ParsePathCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/ParsePathCommand.cs @@ -272,7 +272,6 @@ namespace Microsoft.PowerShell.Commands #region Command code - private static string volumeSeparatorCharAsString = System.IO.Path.VolumeSeparatorChar.ToString(); /// /// Parses the specified path and returns the portion determined by the /// boolean parameters. @@ -396,7 +395,7 @@ namespace Microsoft.PowerShell.Commands continue; case qualifierSet : - int separatorIndex = pathsToParse[index].IndexOf(volumeSeparatorCharAsString, StringComparison.CurrentCulture); + int separatorIndex = pathsToParse[index].IndexOf(":", StringComparison.CurrentCulture); if (separatorIndex < 0) { @@ -538,15 +537,10 @@ namespace Microsoft.PowerShell.Commands string result = path; - // Platform notes: On single root fileystems, there is no such thing - // as a drive qualifier, and so this is a noop - if (Platform.HasSingleRootFilesystem()) - { - } - else if (SessionState.Path.IsProviderQualified(path)) + if (SessionState.Path.IsProviderQualified(path)) { int index = path.IndexOf("::", StringComparison.CurrentCulture); - + if (index != -1) { // remove the qualifier @@ -559,8 +553,8 @@ namespace Microsoft.PowerShell.Commands if (SessionState.Path.IsPSAbsolute(path, out driveName)) { - // Remove the drive name and colon + result = path.Substring(driveName.Length + 1); } } diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs index 5d9fe6800..b4664a5d5 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs @@ -1362,7 +1362,7 @@ namespace Microsoft.PowerShell.Commands continue; } - if (Platform.IsWindows() && !Force) + if (!Force) { // Check if the process is owned by current user if (!IsProcessOwnedByCurrentUser(process)) @@ -2001,9 +2001,6 @@ namespace Microsoft.PowerShell.Commands } private SwitchParameter _UseNewEnvironment; - private StreamWriter OutputWriter; - private StreamWriter ErrorWriter; - #endregion #region overrides @@ -2097,10 +2094,7 @@ namespace Microsoft.PowerShell.Commands } //LoadUserProfile. - if (Platform.IsWindows()) - { - startInfo.LoadUserProfile = _loaduserprofile; - } + startInfo.LoadUserProfile = _loaduserprofile; if (_credential != null) { @@ -2192,30 +2186,8 @@ namespace Microsoft.PowerShell.Commands } #endif //Starts the Process - Process process; - if (Platform.IsWindows()) - { - process = start(startInfo); - } - else - { - process = new Process(); - process.StartInfo = startInfo; - SetupInputOutputRedirection(process); - process.Start(); - if (process.StartInfo.RedirectStandardOutput) - { - process.BeginOutputReadLine(); - } - if (process.StartInfo.RedirectStandardError) - { - process.BeginErrorReadLine(); - } - if (process.StartInfo.RedirectStandardInput) - { - WriteToStandardInput(process); - } - } + Process process = start(startInfo); + //Wait and Passthru Implementation. if (_passthru.IsPresent) @@ -2238,27 +2210,20 @@ namespace Microsoft.PowerShell.Commands { if (!process.HasExited) { - if (Platform.IsWindows()) - { - waithandle = new ManualResetEvent(false); + waithandle = new ManualResetEvent(false); - // Create and start the job object - ProcessCollection jobObject = new ProcessCollection(); - if (jobObject.AssignProcessToJobObject(process)) - { - // Wait for the job object to finish - jobObject.WaitOne(waithandle); - } - else - { - // WinBlue: 27537 Start-Process -Wait doesn't work in a remote session on Windows 7 or lower. - process.Exited += new EventHandler(myProcess_Exited); - process.EnableRaisingEvents = true; - process.WaitForExit(); - } + // Create and start the job object + ProcessCollection jobObject = new ProcessCollection(); + if (jobObject.AssignProcessToJobObject(process)) + { + // Wait for the job object to finish + jobObject.WaitOne(waithandle); } else { + // WinBlue: 27537 Start-Process -Wait doesn't work in a remote session on Windows 7 or lower. + process.Exited += new EventHandler(myProcess_Exited); + process.EnableRaisingEvents = true; process.WaitForExit(); } } @@ -2317,104 +2282,6 @@ namespace Microsoft.PowerShell.Commands } } - private void StdOutputHandler(object sendingProcess, DataReceivedEventArgs outLine) - { - if (!String.IsNullOrEmpty(outLine.Data)) - { - OutputWriter.WriteLine(outLine.Data); - OutputWriter.Flush(); - } - } - - private void StdErrorHandler(object sendingProcess, DataReceivedEventArgs outLine) - { - if (!String.IsNullOrEmpty(outLine.Data)) - { - ErrorWriter.WriteLine(outLine.Data); - ErrorWriter.Flush(); - } - } - - private void ExitHandler(object sendingProcess, System.EventArgs e) - { - // To avoid a race condition with Std*Handler, let's wait a bit before closing the streams - // System.Timer is not supported in CoreCLR, so let's spawn a new thread to do the wait - - Thread delayedStreamClosing = new Thread(StreamClosing); - delayedStreamClosing.Start(); - } - - private void StreamClosing() - { - Thread.Sleep(1000); - - if (OutputWriter != null) - { - OutputWriter.Dispose(); - } - if (ErrorWriter != null) - { - ErrorWriter.Dispose(); - } - } - - private void SetupInputOutputRedirection(Process p) - { - if (_redirectstandardinput != null) - { - p.StartInfo.RedirectStandardInput = true; - _redirectstandardinput = ResolveFilePath(_redirectstandardinput); - } - else - { - p.StartInfo.RedirectStandardInput = false; - } - - if (_redirectstandardoutput != null) - { - p.StartInfo.RedirectStandardOutput = true; - _redirectstandardoutput = ResolveFilePath(_redirectstandardoutput); - p.OutputDataReceived += new DataReceivedEventHandler(StdOutputHandler); - - // Can't do StreamWriter(string) in coreCLR - OutputWriter = new StreamWriter(new FileStream(_redirectstandardoutput, FileMode.Create)); - } - else - { - p.StartInfo.RedirectStandardOutput = false; - OutputWriter = null; - } - - if (_redirectstandarderror != null) - { - p.StartInfo.RedirectStandardError = true; - _redirectstandarderror = ResolveFilePath(_redirectstandarderror); - p.ErrorDataReceived += new DataReceivedEventHandler(StdErrorHandler); - - // Can't do StreamWriter(string) in coreCLR - ErrorWriter = new StreamWriter(new FileStream(_redirectstandarderror, FileMode.Create)); - } - else - { - p.StartInfo.RedirectStandardError = false; - ErrorWriter = null; - } - - p.EnableRaisingEvents = true; - p.Exited += new EventHandler(ExitHandler); - } - - private void WriteToStandardInput(Process p) - { - StreamWriter writer = p.StandardInput; - using (StreamReader reader = new StreamReader(new FileStream(_redirectstandardinput, FileMode.Open))) - { - string line = reader.ReadToEnd(); - writer.WriteLine(line); - } - writer.Dispose(); - } - private Process StartWithCreateProcess(ProcessStartInfo startinfo) { diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/RegisterWMIEventCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/RegisterWMIEventCommand.cs index 80d9f0235..a3be5e099 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/RegisterWMIEventCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/RegisterWMIEventCommand.cs @@ -1,4 +1,3 @@ -#if !CORECLR // // Copyright (C) Microsoft. All rights reserved. // @@ -217,5 +216,3 @@ namespace Microsoft.PowerShell.Commands } } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/RemoveWMIObjectCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/RemoveWMIObjectCommand.cs index b135fbc2f..706196dc6 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/RemoveWMIObjectCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/RemoveWMIObjectCommand.cs @@ -1,4 +1,3 @@ -#if !CORECLR // // Copyright (C) Microsoft. All rights reserved. // @@ -172,5 +171,3 @@ namespace Microsoft.PowerShell.Commands #endregion Command code } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/RollbackTransactionCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/RollbackTransactionCommand.cs index b8ab72dae..b5ae078fb 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/RollbackTransactionCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/RollbackTransactionCommand.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -33,5 +32,3 @@ namespace Microsoft.PowerShell.Commands } // namespace Microsoft.PowerShell.Commands - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/SetClipboardCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/SetClipboardCommand.cs index 8dcd5e72b..d83d4b870 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/SetClipboardCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/SetClipboardCommand.cs @@ -1,5 +1,4 @@ -#if !CORECLR -using System; +using System; using System.Management.Automation; using System.Collections.Generic; using System.Globalization; @@ -419,5 +418,4 @@ EndSelection:<<<<<<<<4"; } } -} -#endif +} \ No newline at end of file diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/SetWMIInstanceCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/SetWMIInstanceCommand.cs index 84317267a..f43d604c7 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/SetWMIInstanceCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/SetWMIInstanceCommand.cs @@ -1,4 +1,3 @@ -#if !CORECLR // // Copyright (C) Microsoft. All rights reserved. // @@ -194,5 +193,3 @@ namespace Microsoft.PowerShell.Commands #endregion Command code } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/StartTransactionCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/StartTransactionCommand.cs index bf1c14d2b..3754775dc 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/StartTransactionCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/StartTransactionCommand.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -104,5 +103,3 @@ namespace Microsoft.PowerShell.Commands } // namespace Microsoft.PowerShell.Commands - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/UseTransactionCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/UseTransactionCommand.cs index 229d8a201..b0b105dc0 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/UseTransactionCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/UseTransactionCommand.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -94,5 +93,3 @@ namespace Microsoft.PowerShell.Commands } // namespace Microsoft.PowerShell.Commands - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/WMIHelper.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/WMIHelper.cs index af5295934..21f4c6e7d 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/WMIHelper.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/WMIHelper.cs @@ -1,4 +1,3 @@ -#if !CORECLR // // Copyright (C) Microsoft. All rights reserved. // @@ -2112,5 +2111,3 @@ namespace Microsoft.PowerShell.Commands } // HandleThrottleComplete } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/WebServiceProxy.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/WebServiceProxy.cs index d5c16a2f2..3f300bea7 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/WebServiceProxy.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/WebServiceProxy.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************-- Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -478,5 +477,3 @@ namespace Microsoft.PowerShell.Commands #endregion }//Microsoft.Powershell.commands - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Management/singleshell/installer/MshManagementMshSnapin.cs b/src/Microsoft.PowerShell.Commands.Management/singleshell/installer/MshManagementMshSnapin.cs index 526fb6ebe..49166075b 100644 --- a/src/Microsoft.PowerShell.Commands.Management/singleshell/installer/MshManagementMshSnapin.cs +++ b/src/Microsoft.PowerShell.Commands.Management/singleshell/installer/MshManagementMshSnapin.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -92,5 +91,3 @@ namespace Microsoft.PowerShell } } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs index fc1fb2da4..cc74cf431 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs @@ -1137,7 +1137,7 @@ namespace Microsoft.PowerShell.Commands // First try by strong name try { - loadedAssembly = ClrFacade.Load(new AssemblyName(assemblyName)); + loadedAssembly = System.Reflection.Assembly.Load(new AssemblyName(assemblyName)); } // Generates a FileNotFoundException if you can't load the strong type. // So we'll try from the short name. @@ -1912,7 +1912,7 @@ namespace Microsoft.PowerShell.Commands { foreach(string path in paths) { - generatedTypes.AddRange(ClrFacade.LoadFrom(path).GetTypes()); + generatedTypes.AddRange(System.Reflection.Assembly.LoadFrom(path).GetTypes()); } } // Load the assembly by name @@ -2030,7 +2030,7 @@ namespace Microsoft.PowerShell.Commands // First try by strong name try { - loadedAssembly = ClrFacade.Load(assemblyName); + loadedAssembly = System.Reflection.Assembly.Load(assemblyName); } // Generates a FileNotFoundException if you can't load the strong type. // So we'll try from the short name. @@ -2042,7 +2042,7 @@ namespace Microsoft.PowerShell.Commands // Next, try an exact match if (StrongNames.Value.ContainsKey(assemblyName)) { - return ClrFacade.Load(StrongNames.Value[assemblyName]); + return System.Reflection.Assembly.Load(StrongNames.Value[assemblyName]); } // If the assembly name doesn't contain wildcards, return null. The caller generates an error here. @@ -2085,7 +2085,7 @@ namespace Microsoft.PowerShell.Commands return null; // Otherwise, load the assembly. - return ClrFacade.Load(matchedStrongName); + return System.Reflection.Assembly.Load(matchedStrongName); } private static ConcurrentDictionary InitializeStrongNameDictionary() diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ColumnInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ColumnInfo.cs index c46519159..03cd917ed 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ColumnInfo.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ColumnInfo.cs @@ -1,4 +1,3 @@ -#if !CORECLR // // Copyright (C) Microsoft. All rights reserved. // @@ -57,5 +56,4 @@ namespace Microsoft.PowerShell.Commands return HostUtilities.GetMaxLines(srcString, 10); } } -} -#endif +} \ No newline at end of file diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ExpressionColumnInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ExpressionColumnInfo.cs index 95d49653f..093cd12df 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ExpressionColumnInfo.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ExpressionColumnInfo.cs @@ -1,4 +1,3 @@ -#if !CORECLR // // Copyright (C) Microsoft. All rights reserved. // @@ -39,5 +38,4 @@ namespace Microsoft.PowerShell.Commands return objectResult == null ? String.Empty : ColumnInfo.LimitString(objectResult.ToString()); } } -} -#endif +} \ No newline at end of file diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/HeaderInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/HeaderInfo.cs index 968aa94da..b51748868 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/HeaderInfo.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/HeaderInfo.cs @@ -1,4 +1,3 @@ -#if !CORECLR // // Copyright (C) Microsoft. All rights reserved. // @@ -60,5 +59,4 @@ namespace Microsoft.PowerShell.Commands return staleObject; } } -} -#endif +} \ No newline at end of file diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OriginalColumnInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OriginalColumnInfo.cs index de3982895..5e89c754c 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OriginalColumnInfo.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OriginalColumnInfo.cs @@ -1,4 +1,3 @@ -#if !CORECLR // // Copyright (C) Microsoft. All rights reserved. // @@ -72,5 +71,3 @@ namespace Microsoft.PowerShell.Commands } } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutGridViewCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutGridViewCommand.cs index 1d6ce8830..bfc3a5396 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutGridViewCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutGridViewCommand.cs @@ -1,4 +1,3 @@ -#if !CORECLR // // Copyright (C) Microsoft. All rights reserved. // @@ -530,5 +529,3 @@ namespace Microsoft.PowerShell.Commands } } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutWindowProxy.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutWindowProxy.cs index 5d8cd0802..635af783b 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutWindowProxy.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutWindowProxy.cs @@ -1,4 +1,3 @@ -#if !CORECLR // // Copyright (C) Microsoft. All rights reserved. // @@ -308,5 +307,3 @@ namespace Microsoft.PowerShell.Commands } } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ScalarTypeColumnInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ScalarTypeColumnInfo.cs index 989116e5e..2ee294cca 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ScalarTypeColumnInfo.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ScalarTypeColumnInfo.cs @@ -1,4 +1,3 @@ -#if !CORECLR // // Copyright (C) Microsoft. All rights reserved. // @@ -77,5 +76,4 @@ namespace Microsoft.PowerShell.Commands return index++; } } -} -#endif +} \ No newline at end of file diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/TableView.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/TableView.cs index a05506e32..7822caf5c 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/TableView.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/TableView.cs @@ -1,4 +1,3 @@ -#if !CORECLR // // Copyright (C) Microsoft. All rights reserved. // @@ -282,5 +281,3 @@ namespace Microsoft.PowerShell.Commands } } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/out-printer/PrinterLineOutput.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/out-printer/PrinterLineOutput.cs index 97393fa21..018f907f9 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/out-printer/PrinterLineOutput.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/out-printer/PrinterLineOutput.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -332,5 +331,3 @@ namespace Microsoft.PowerShell.Commands.Internal.Format } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/out-printer/out-printer.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/out-printer/out-printer.cs index 77f0093fb..11c537537 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/out-printer/out-printer.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/out-printer/out-printer.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -75,5 +74,3 @@ namespace Microsoft.PowerShell.Commands - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs index d24ce82ec..115f44d69 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -2032,7 +2031,9 @@ namespace Microsoft.PowerShell.Commands return result.ToString(); } - private const string SectionSeparator = "\r\n##############################################################################\r\n"; + private const string SectionSeparator = @" +############################################################################## +"; private void GenerateSectionSeparator(TextWriter writer) { @@ -2079,7 +2080,14 @@ namespace Microsoft.PowerShell.Commands #region Generating header of a proxy module - private const string TopCommentTemplate = "\r\n<#\r\n # {0}\r\n # {1}\r\n # {2}\r\n # {3}\r\n #>\r\n"; + private const string TopCommentTemplate = @" +<# + # {0} + # {1} + # {2} + # {3} + #> + "; private void GenerateTopComment(TextWriter writer) { @@ -2395,7 +2403,8 @@ function Get-PSImplicitRemotingSession -ErrorAction SilentlyContinue ) }} if (($script:PSSession -ne $null) -and ($script:PSSession.Runspace.RunspaceStateInfo.State -eq 'Disconnected')) - {{ # If we are handed a disconnected session, try re-connecting it before creating a new session. + {{ + # If we are handed a disconnected session, try re-connecting it before creating a new session. Set-PSImplicitRemotingSession ` (& $script:ConnectPSSession ` -Session $script:PSSession ` @@ -2847,7 +2856,12 @@ function Get-PSImplicitRemotingClientSideParameters }} Process {{ {6} }} End {{ {7} }} -" + "\r\n # .ForwardHelpTargetName {1}\r\n # .ForwardHelpCategory {5}\r\n # .RemoteHelpRunspace PSSession\r\n}}\r\n "; + + # .ForwardHelpTargetName {1} + # .ForwardHelpCategory {5} + # .RemoteHelpRunspace PSSession +}} + "; private void GenerateCommandProxy(TextWriter writer, CommandMetadata commandMetadata) { @@ -3143,4 +3157,3 @@ function Get-PSImplicitRemotingClientSideParameters } } -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Import-LocalizedData.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Import-LocalizedData.cs index c2c65f557..a568cd6b8 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Import-LocalizedData.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Import-LocalizedData.cs @@ -294,11 +294,18 @@ namespace Microsoft.PowerShell.Commands } CultureInfo currentCulture = culture; + StringBuilder stringBuilder; string filePath; - string fullFileName = fileName + ".psd1"; while (currentCulture != null && !String.IsNullOrEmpty(currentCulture.Name)) { - filePath = Path.Combine(dir, currentCulture.Name, fullFileName); + stringBuilder = new StringBuilder(dir); + stringBuilder.Append("\\"); + stringBuilder.Append(currentCulture.Name); + stringBuilder.Append("\\"); + stringBuilder.Append(fileName); + stringBuilder.Append(".psd1"); + + filePath = stringBuilder.ToString(); if (File.Exists(filePath)) { @@ -308,7 +315,12 @@ namespace Microsoft.PowerShell.Commands currentCulture = currentCulture.Parent; } - filePath = Path.Combine(dir, fullFileName); + stringBuilder = new StringBuilder(dir); + stringBuilder.Append("\\"); + stringBuilder.Append(fileName); + stringBuilder.Append(".psd1"); + + filePath = stringBuilder.ToString(); if (File.Exists(filePath)) { @@ -318,11 +330,11 @@ namespace Microsoft.PowerShell.Commands InvalidOperationException ioe = PSTraceSource.NewInvalidOperationException( ImportLocalizedDataStrings.CannotFindPsd1File, - fullFileName, - Path.Combine(dir, culture.Name) + fileName + ".psd1", + dir + "\\" + culture.Name + "\\" ); WriteError(new ErrorRecord(ioe, "ImportLocalizedData", ErrorCategory.ObjectNotFound, - Path.Combine(dir, culture.Name, fullFileName))); + dir + "\\" + culture.Name + "\\" + fileName + ".psd1")); return null; } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs index 015c7a4e8..7bc100225 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs @@ -548,7 +548,7 @@ namespace Microsoft.PowerShell.Commands // properties... foreach (string p in Property) { - MshExpression expression = new MshExpression(p, true); + MshExpression expression = new MshExpression(p); List resolvedNames = expression.ResolveNames(inObj); if (resolvedNames == null || resolvedNames.Count == 0) { diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Send-MailMessage.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Send-MailMessage.cs index d7aa65d82..1e691675d 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Send-MailMessage.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Send-MailMessage.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -549,5 +548,4 @@ namespace Microsoft.PowerShell.Commands } #endregion -} -#endif +} \ No newline at end of file diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/SetDateCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/SetDateCommand.cs index 1cd50f686..5abd52537 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/SetDateCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/SetDateCommand.cs @@ -117,28 +117,21 @@ namespace Microsoft.PowerShell.Commands if ( ShouldProcess( dateToUse.ToString() ) ) { - if (Platform.IsWindows()) + #pragma warning disable 56523 + + if (!NativeMethods.SetLocalTime(ref systemTime)) { - #pragma warning disable 56523 - - if (!NativeMethods.SetLocalTime(ref systemTime)) - { - throw new Win32Exception(Marshal.GetLastWin32Error()); - } - - // MSDN says to call this twice to account for changes - // between DST - if (!NativeMethods.SetLocalTime(ref systemTime)) - { - throw new Win32Exception(Marshal.GetLastWin32Error()); - } - - #pragma warning restore 56523 + throw new Win32Exception(Marshal.GetLastWin32Error()); } - else + + // MSDN says to call this twice to account for changes + // between DST + if (!NativeMethods.SetLocalTime(ref systemTime)) { - Platform.NonWindowsSetDate(dateToUse); + throw new Win32Exception(Marshal.GetLastWin32Error()); } + + #pragma warning restore 56523 } //output DateTime object wrapped in an PSObject with DisplayHint attached diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommand.cs index 162cfd3ae..2614de1d0 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommand.cs @@ -1,7 +1,6 @@ -#if !CORECLR -//----------------------------------------------------------------------- +//----------------------------------------------------------------------- // -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright © Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------- namespace Microsoft.PowerShell.Commands @@ -694,5 +693,3 @@ namespace Microsoft.PowerShell.Commands } } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandCommandInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandCommandInfo.cs index 260165cc3..577d805f9 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandCommandInfo.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandCommandInfo.cs @@ -1,7 +1,6 @@ -#if !CORECLR -//----------------------------------------------------------------------- +//----------------------------------------------------------------------- // -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright © Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------- namespace Microsoft.PowerShell.Commands.ShowCommandExtension @@ -153,5 +152,4 @@ namespace Microsoft.PowerShell.Commands.ShowCommandExtension /// public ICollection ParameterSets { get; private set; } } -} -#endif +} \ No newline at end of file diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandModuleInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandModuleInfo.cs index bc028672b..81dd4e572 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandModuleInfo.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandModuleInfo.cs @@ -1,7 +1,6 @@ -#if !CORECLR //----------------------------------------------------------------------- // -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright © Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------- namespace Microsoft.PowerShell.Commands.ShowCommandExtension @@ -59,5 +58,4 @@ namespace Microsoft.PowerShell.Commands.ShowCommandExtension /// public string Name { get; private set; } } -} -#endif +} \ No newline at end of file diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterInfo.cs index a5638ae8c..50961f1c0 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterInfo.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterInfo.cs @@ -1,7 +1,6 @@ -#if !CORECLR //----------------------------------------------------------------------- // -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright © Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------- namespace Microsoft.PowerShell.Commands.ShowCommandExtension @@ -111,5 +110,4 @@ namespace Microsoft.PowerShell.Commands.ShowCommandExtension /// public int Position { get; private set; } } -} -#endif +} \ No newline at end of file diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterSetInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterSetInfo.cs index 0f0be2b54..4a61dac7b 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterSetInfo.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterSetInfo.cs @@ -1,7 +1,6 @@ -#if !CORECLR -//----------------------------------------------------------------------- +//----------------------------------------------------------------------- // -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright © Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------- namespace Microsoft.PowerShell.Commands.ShowCommandExtension @@ -75,5 +74,4 @@ namespace Microsoft.PowerShell.Commands.ShowCommandExtension /// public ICollection Parameters { get; private set; } } -} -#endif +} \ No newline at end of file diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterType.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterType.cs index 7ee008bab..af40834a2 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterType.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterType.cs @@ -1,7 +1,6 @@ -#if !CORECLR -//----------------------------------------------------------------------- +//----------------------------------------------------------------------- // -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright © Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------- namespace Microsoft.PowerShell.Commands.ShowCommandExtension @@ -162,5 +161,4 @@ namespace Microsoft.PowerShell.Commands.ShowCommandExtension /// public ArrayList EnumValues { get; private set; } } -} -#endif +} \ No newline at end of file diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandProxy.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandProxy.cs index c3b4b0a2d..3e5acfa98 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandProxy.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandProxy.cs @@ -1,7 +1,6 @@ -#if !CORECLR -//----------------------------------------------------------------------- +//----------------------------------------------------------------------- // -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright © Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------- namespace Microsoft.PowerShell.Commands @@ -196,5 +195,3 @@ namespace Microsoft.PowerShell.Commands } } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/BasicHtmlWebResponseObject.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/BasicHtmlWebResponseObject.cs index 5d48a73e2..d5b3d1cd8 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/BasicHtmlWebResponseObject.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/BasicHtmlWebResponseObject.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -270,5 +269,3 @@ namespace Microsoft.PowerShell.Commands #endregion Methods } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/ContentHelper.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/ContentHelper.cs index 42da7742d..e2b0f76f1 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/ContentHelper.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/ContentHelper.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -207,5 +206,3 @@ namespace Microsoft.PowerShell.Commands #endregion Internal Helper Methods } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/HtmlWebResponseObject.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/HtmlWebResponseObject.cs index 6267602de..ee5e174a8 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/HtmlWebResponseObject.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/HtmlWebResponseObject.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -551,5 +550,3 @@ namespace Microsoft.PowerShell.Commands } } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/InvokeRestMethodCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/InvokeRestMethodCommand.cs index b4765f0ba..31c2748b2 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/InvokeRestMethodCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/InvokeRestMethodCommand.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -17,7 +16,7 @@ namespace Microsoft.PowerShell.Commands /// The Invoke-RestMethod command /// This command makes an HTTP or HTTPS request to a web service, /// and returns the response in an appropriate way. - /// Intended to work against the wide spectrum of "RESTful" web services + /// Intended to work against the wide spectrum of “RESTful” web services /// currently deployed across the web. /// [Cmdlet(VerbsLifecycle.Invoke, "RestMethod", HelpUri = "http://go.microsoft.com/fwlink/?LinkID=217034")] @@ -373,5 +372,3 @@ namespace Microsoft.PowerShell.Commands } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/InvokeWebRequestCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/InvokeWebRequestCommand.cs index 37c210882..beb9819c2 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/InvokeWebRequestCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/InvokeWebRequestCommand.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -62,5 +61,3 @@ namespace Microsoft.PowerShell.Commands #endregion Virtual Method Overrides } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObjectTypeResolver.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObjectTypeResolver.cs index 070033082..a279a6df1 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObjectTypeResolver.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObjectTypeResolver.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -28,5 +27,3 @@ namespace Microsoft.PowerShell.Commands } } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/PSUserAgent.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/PSUserAgent.cs index 4bafc0599..e513f1216 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/PSUserAgent.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/PSUserAgent.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -175,5 +174,3 @@ namespace Microsoft.PowerShell.Commands } } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs index 5c7bcd515..edd1ff6af 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -493,5 +492,3 @@ namespace Microsoft.PowerShell.Commands #endregion Static Methods } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebRequestPSCmdlet.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebRequestPSCmdlet.cs index 0111bc81d..041147285 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebRequestPSCmdlet.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebRequestPSCmdlet.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -1357,5 +1356,3 @@ namespace Microsoft.PowerShell.Commands #endregion private State class } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebRequestSession.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebRequestSession.cs index c82b71552..a8a87eeee 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebRequestSession.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebRequestSession.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -99,5 +98,3 @@ namespace Microsoft.PowerShell.Commands } } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebResponseHelper.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebResponseHelper.cs index e413d27ce..d8afb0a7c 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebResponseHelper.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebResponseHelper.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -72,5 +71,3 @@ namespace Microsoft.PowerShell.Commands } } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebResponseObject.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebResponseObject.cs index 2e896419a..7791ad00c 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebResponseObject.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebResponseObject.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -191,5 +190,3 @@ namespace Microsoft.PowerShell.Commands #endregion Methods } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebResponseObjectFactory.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebResponseObjectFactory.cs index 68c791266..e2019ae76 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebResponseObjectFactory.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebResponseObjectFactory.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -39,5 +38,3 @@ namespace Microsoft.PowerShell.Commands } } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteConsoleCmdlet.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteConsoleCmdlet.cs index 1b9283221..23a7754fe 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteConsoleCmdlet.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteConsoleCmdlet.cs @@ -170,11 +170,6 @@ namespace Microsoft.PowerShell.Commands // Expected if the host is not interactive, or doesn't have Foreground / Background // colours. } - catch (System.PlatformNotSupportedException) - { - // TODO:PSL Support setting these colors. Expected - // exception on non-windows CoreCLR for now. - } this.WriteInformation(informationMessage, new string[] { "PSHOST" }); this.Host.UI.TranscribeResult(result); diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/convert-HTML.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/convert-HTML.cs index 15c6a95d4..c992b38e4 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/convert-HTML.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/convert-HTML.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -624,5 +623,3 @@ namespace Microsoft.PowerShell.Commands } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/GetTracerCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/GetTracerCommand.cs index b9ad3e7d4..ce47c25bb 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/GetTracerCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/GetTracerCommand.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -60,5 +59,3 @@ namespace Microsoft.PowerShell.Commands } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/MshHostTraceListener.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/MshHostTraceListener.cs index 30b6050e9..5cafcba4f 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/MshHostTraceListener.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/MshHostTraceListener.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -145,5 +144,3 @@ namespace Microsoft.PowerShell.Commands } // class PSHostTraceListener } // namespace System.Management.Automation - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/SetTracerCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/SetTracerCommand.cs index 6f6a04450..c6f08afe8 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/SetTracerCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/SetTracerCommand.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -187,5 +186,3 @@ namespace Microsoft.PowerShell.Commands } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceCommandBase.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceCommandBase.cs index e9b13f9a0..995754330 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceCommandBase.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceCommandBase.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -135,5 +134,3 @@ namespace Microsoft.PowerShell.Commands } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceExpressionCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceExpressionCommand.cs index 3f48f6796..29e6de6da 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceExpressionCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceExpressionCommand.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -574,5 +573,3 @@ namespace Microsoft.PowerShell.Commands } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceListenerCommandBase.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceListenerCommandBase.cs index 6af1f02b6..186f40f97 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceListenerCommandBase.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceListenerCommandBase.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -633,5 +632,3 @@ namespace Microsoft.PowerShell.Commands } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/update-list.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/update-list.cs index 2fc2a113f..5e8a72a53 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/update-list.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/update-list.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -215,5 +214,3 @@ namespace Microsoft.PowerShell.Commands } } } - -#endif diff --git a/src/Microsoft.PowerShell.Commands.Utility/singleshell/installer/MshUtilityMshSnapin.cs b/src/Microsoft.PowerShell.Commands.Utility/singleshell/installer/MshUtilityMshSnapin.cs index c52f0e7a7..9920e6b9c 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/singleshell/installer/MshUtilityMshSnapin.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/singleshell/installer/MshUtilityMshSnapin.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -92,5 +91,3 @@ namespace Microsoft.PowerShell } } } - -#endif diff --git a/src/Microsoft.PowerShell.ConsoleHost/Modules/Microsoft.PowerShell.Diagnostics/Microsoft.PowerShell.Diagnostics.psd1 b/src/Microsoft.PowerShell.ConsoleHost/Modules/Microsoft.PowerShell.Diagnostics/Microsoft.PowerShell.Diagnostics.psd1 index d72eb9e28..3be74226f 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/Modules/Microsoft.PowerShell.Diagnostics/Microsoft.PowerShell.Diagnostics.psd1 +++ b/src/Microsoft.PowerShell.ConsoleHost/Modules/Microsoft.PowerShell.Diagnostics/Microsoft.PowerShell.Diagnostics.psd1 @@ -10,7 +10,7 @@ AliasesToExport = @() FunctionsToExport = @() CmdletsToExport="Get-WinEvent", "Get-Counter", "Import-Counter", "Export-Counter", "New-WinEvent" NestedModules="Microsoft.PowerShell.Commands.Diagnostics.dll" -TypesToProcess="GetEvent.types.ps1xml" -FormatsToProcess="Event.format.ps1xml","Diagnostics.format.ps1xml" +TypesToProcess="..\..\GetEvent.types.ps1xml" +FormatsToProcess="..\..\Event.format.ps1xml","..\..\Diagnostics.format.ps1xml" HelpInfoURI = 'http://go.microsoft.com/fwlink/?linkid=390783' } diff --git a/src/Microsoft.PowerShell.CoreCLR.AssemblyLoadContext/CoreCLR/CorePsAssemblyLoadContext.cs b/src/Microsoft.PowerShell.CoreCLR.AssemblyLoadContext/CoreCLR/CorePsAssemblyLoadContext.cs index 922565574..c7a51fde0 100644 --- a/src/Microsoft.PowerShell.CoreCLR.AssemblyLoadContext/CoreCLR/CorePsAssemblyLoadContext.cs +++ b/src/Microsoft.PowerShell.CoreCLR.AssemblyLoadContext/CoreCLR/CorePsAssemblyLoadContext.cs @@ -54,6 +54,11 @@ namespace System.Management.Automation internal PowerShellAssemblyLoadContext(string basePaths) { #region Validation + if (string.IsNullOrEmpty(basePaths)) + { + throw new ArgumentNullException("basePaths"); + } + this.basePaths = basePaths.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < this.basePaths.Length; i++) { @@ -184,19 +189,9 @@ namespace System.Management.Automation assemblyName.FullName); } - // Try loading it from the TPA list. All PowerShell dependencies are in the - // TPA list when published with dotnet-cli. - asmLoaded = Assembly.Load(assemblyName); - - // If it wasn't there, try loading from path - if (asmLoaded == null) - { - asmLoaded = asmFilePath.EndsWith(".ni.dll", StringComparison.OrdinalIgnoreCase) - ? LoadFromNativeImagePath(asmFilePath, null) - : LoadFromAssemblyPath(asmFilePath); - } - - // If it loaded, add it to the cache + asmLoaded = asmFilePath.EndsWith(".ni.dll", StringComparison.OrdinalIgnoreCase) + ? LoadFromNativeImagePath(asmFilePath, null) + : LoadFromAssemblyPath(asmFilePath); if (asmLoaded != null) { // Add the loaded assembly to the cache @@ -248,17 +243,10 @@ namespace System.Management.Automation if (TryGetAssemblyFromCache(assemblyName, out asmLoaded)) return asmLoaded; - // Try loading it from the TPA list. All PowerShell dependencies are in the - // TPA list when published with dotnet-cli. - asmLoaded = Assembly.Load(assemblyName); - - if (asmLoaded == null) - { - // Load the assembly through 'LoadFromNativeImagePath' or 'LoadFromAssemblyPath' - asmLoaded = assemblyPath.EndsWith(".ni.dll", StringComparison.OrdinalIgnoreCase) - ? LoadFromNativeImagePath(assemblyPath, null) - : LoadFromAssemblyPath(assemblyPath); - } + // Load the assembly through 'LoadFromNativeImagePath' or 'LoadFromAssemblyPath' + asmLoaded = assemblyPath.EndsWith(".ni.dll", StringComparison.OrdinalIgnoreCase) + ? LoadFromNativeImagePath(assemblyPath, null) + : LoadFromAssemblyPath(assemblyPath); if (asmLoaded != null) { @@ -496,20 +484,16 @@ namespace System.Management.Automation { private static bool IsInitialized = false; - // Porting note: it's much easier to send an LPStr on Linux - private const UnmanagedType stringType = -#if LINUX - UnmanagedType.LPStr -#else - UnmanagedType.LPWStr -#endif - ; - /// /// Set the default Assembly Load Context /// - public static void SetPowerShellAssemblyLoadContext([MarshalAs(stringType)]string basePaths) + public static void SetPowerShellAssemblyLoadContext([MarshalAs(UnmanagedType.LPWStr)]string basePaths) { + if (string.IsNullOrEmpty(basePaths)) + { + throw new ArgumentNullException("basePaths"); + } + if (!IsInitialized) { var psAsmLoadContext = new PowerShellAssemblyLoadContext(basePaths); diff --git a/src/Microsoft.PowerShell.Security/security/CertificateCommands.cs b/src/Microsoft.PowerShell.Security/security/CertificateCommands.cs index 994cb634b..e40496766 100644 --- a/src/Microsoft.PowerShell.Security/security/CertificateCommands.cs +++ b/src/Microsoft.PowerShell.Security/security/CertificateCommands.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -240,5 +239,3 @@ namespace Microsoft.PowerShell.Commands } } - -#endif diff --git a/src/Microsoft.PowerShell.Security/security/CmsCommands.cs b/src/Microsoft.PowerShell.Security/security/CmsCommands.cs index 0fce7622f..48df4fc3c 100644 --- a/src/Microsoft.PowerShell.Security/security/CmsCommands.cs +++ b/src/Microsoft.PowerShell.Security/security/CmsCommands.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -588,5 +587,3 @@ namespace Microsoft.PowerShell.Commands } } - -#endif diff --git a/src/Microsoft.PowerShell.Security/singleshell/installer/MshSecurityMshSnapin.cs b/src/Microsoft.PowerShell.Security/singleshell/installer/MshSecurityMshSnapin.cs index 2721d2d6f..ca07bc89a 100644 --- a/src/Microsoft.PowerShell.Security/singleshell/installer/MshSecurityMshSnapin.cs +++ b/src/Microsoft.PowerShell.Security/singleshell/installer/MshSecurityMshSnapin.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -92,5 +91,3 @@ namespace Microsoft.PowerShell } } } - -#endif diff --git a/src/Modules/Microsoft.PowerShell.Archive/Microsoft.PowerShell.Archive.psm1 b/src/Modules/Microsoft.PowerShell.Archive/Microsoft.PowerShell.Archive.psm1 index b301646d6..31a6e0890 100644 Binary files a/src/Modules/Microsoft.PowerShell.Archive/Microsoft.PowerShell.Archive.psm1 and b/src/Modules/Microsoft.PowerShell.Archive/Microsoft.PowerShell.Archive.psm1 differ diff --git a/src/Modules/Microsoft.WSMan.Management/Microsoft.WSMan.Management.psd1 b/src/Modules/Microsoft.WSMan.Management/Microsoft.WSMan.Management.psd1 index 972d36886..3e05410ba 100644 --- a/src/Modules/Microsoft.WSMan.Management/Microsoft.WSMan.Management.psd1 +++ b/src/Modules/Microsoft.WSMan.Management/Microsoft.WSMan.Management.psd1 @@ -10,6 +10,6 @@ AliasesToExport = @() FunctionsToExport = @() CmdletsToExport="Disable-WSManCredSSP", "Enable-WSManCredSSP", "Get-WSManCredSSP", "Set-WSManQuickConfig", "Test-WSMan", "Invoke-WSManAction", "Connect-WSMan", "Disconnect-WSMan", "Get-WSManInstance", "Set-WSManInstance", "Remove-WSManInstance", "New-WSManInstance", "New-WSManSessionOption" NestedModules="Microsoft.WSMan.Management.dll" -FormatsToProcess="WSMan.format.ps1xml" +FormatsToProcess="..\..\WSMan.format.ps1xml" HelpInfoURI = 'http://go.microsoft.com/fwlink/?linkid=390788' } diff --git a/src/Modules/PSGet/PSGet.Resource.psd1 b/src/Modules/PSGet/PSGet.Resource.psd1 index 5177bec6b..6bc23e1f1 100644 Binary files a/src/Modules/PSGet/PSGet.Resource.psd1 and b/src/Modules/PSGet/PSGet.Resource.psd1 differ diff --git a/src/Modules/PSGet/PSModule.psm1 b/src/Modules/PSGet/PSModule.psm1 index 6ddcc4db7..23207f17a 100644 --- a/src/Modules/PSGet/PSModule.psm1 +++ b/src/Modules/PSGet/PSModule.psm1 @@ -11622,6 +11622,11 @@ function Update-ModuleManifest [System.Reflection.ProcessorArchitecture] $ProcessorArchitecture, + [Parameter()] + [ValidateSet('Desktop','Core')] + [string[]] + $CompatiblePSEditions, + [Parameter()] [ValidateNotNullOrEmpty()] [Version] @@ -11780,20 +11785,27 @@ function Update-ModuleManifest } #Get the original module manifest and migrate all the fields to the new module manifest, including the specified parameter values + $moduleInfo = $null + try { $moduleInfo = Microsoft.PowerShell.Core\Test-ModuleManifest -Path $Path -ErrorAction Stop } catch { - $message = $LocalizedData.TestModuleManifestFail -f ($_.Exception.Message) - ThrowError -ExceptionName "System.ArgumentException" ` - -ExceptionMessage $message ` - -ErrorId "InvalidModuleManifestFile" ` - -ExceptionObject $Path ` - -CallerPSCmdlet $PSCmdlet ` - -ErrorCategory InvalidArgument - return + # Throw an error only if Test-ModuleManifest did not return the PSModuleInfo object. + # This enables the users to use Update-ModuleManifest cmdlet to update the metadata. + if(-not $moduleInfo) + { + $message = $LocalizedData.TestModuleManifestFail -f ($_.Exception.Message) + ThrowError -ExceptionName "System.ArgumentException" ` + -ExceptionMessage $message ` + -ErrorId "InvalidModuleManifestFile" ` + -ExceptionObject $Path ` + -CallerPSCmdlet $PSCmdlet ` + -ErrorCategory InvalidArgument + return + } } #Params to pass to New-ModuleManifest module @@ -12086,6 +12098,31 @@ function Update-ModuleManifest } } + if($CompatiblePSEditions) + { + # CompatiblePSEditions field is not available in PowerShell version lower than 5.1 + # + if (($PSVersionTable.PSVersion -lt [Version]'5.1') -or ($PowerShellVersion -and $PowerShellVersion -lt [Version]'5.1') ` + -or (-not $PowerShellVersion -and $moduleInfo.PowerShellVersion -and $moduleInfo.PowerShellVersion -lt [Version]'5.1') ` + -or (-not $PowerShellVersion -and -not $moduleInfo.PowerShellVersion)) + { + ThrowError -ExceptionName 'System.ArgumentException' ` + -ExceptionMessage $LocalizedData.CompatiblePSEditionsNotSupportedOnLowerPowerShellVersion ` + -ErrorId 'CompatiblePSEditionsNotSupported' ` + -ExceptionObject $CompatiblePSEditions ` + -CallerPSCmdlet $PSCmdlet ` + -ErrorCategory InvalidArgument + return + } + + $params.Add('CompatiblePSEditions', $CompatiblePSEditions) + } + elseif( (Microsoft.PowerShell.Utility\Get-Member -InputObject $moduleInfo -name 'CompatiblePSEditions') -and + $moduleInfo.CompatiblePSEditions) + { + $params.Add('CompatiblePSEditions', $moduleInfo.CompatiblePSEditions) + } + if($HelpInfoUri) { $params.Add("HelpInfoUri",$HelpInfoUri) diff --git a/src/System.Management.Automation/CoreCLR/CorePsExtensions.cs b/src/System.Management.Automation/CoreCLR/CorePsExtensions.cs index ec69e4fa4..fee97847a 100644 --- a/src/System.Management.Automation/CoreCLR/CorePsExtensions.cs +++ b/src/System.Management.Automation/CoreCLR/CorePsExtensions.cs @@ -1,8 +1,9 @@ -#if CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ +#if CORECLR + using System.Globalization; using System.Linq; using System.Reflection; @@ -824,37 +825,7 @@ namespace System.Management.Automation public static string GetEnvironmentVariable(string variable) { - string value = System.Environment.GetEnvironmentVariable(variable); - - // Porting note: if not otherwise defined, map Windows environment - // variables to their corresponding Linux counterparts - if (Platform.IsLinux() && String.IsNullOrEmpty(value)) - { - switch (variable) - { - case "OS": - return "Linux"; - - case "COMPUTERNAME": - return System.Environment.GetEnvironmentVariable("HOSTNAME"); - - case "USERNAME": - return System.Environment.GetEnvironmentVariable("USER"); - - case "HOMEPATH": - case "USERPROFILE": - return System.Environment.GetEnvironmentVariable("HOME"); - - case "TMP": - case "TEMP": - return System.Environment.GetEnvironmentVariable("TMPDIR"); - - default: - break; - } - } - - return value; + return System.Environment.GetEnvironmentVariable(variable); } public static IDictionary GetEnvironmentVariables() @@ -892,13 +863,6 @@ namespace System.Management.Automation { return GetEnvironmentVariables(); } - - if (!Platform.HasRegistrySupport()) - { - // Porting note: Does not throw a PlatformUnsupported because - // GetEnvironmentVariable cannot throw, and we want the same interface. - return null; - } if( target == EnvironmentVariableTarget.Machine) { @@ -956,14 +920,6 @@ namespace System.Management.Automation return System.Environment.GetEnvironmentVariable(variable); } - if (!Platform.HasRegistrySupport()) - { - // Porting note: This cannot throw since it would otherwise throw while - // creating a runspace. Returning null is appropriate to signal that there - // is no value for a registry key with no registry. - return null; - } - if (target == EnvironmentVariableTarget.Machine) { using (RegistryKey environmentKey = @@ -991,31 +947,6 @@ namespace System.Management.Automation #region Property_Extensions - internal static string WinGetUserDomainName() - { - StringBuilder domainName = new StringBuilder(1024); - uint domainNameLen = (uint)domainName.Capacity; - - byte ret = Win32Native.GetUserNameEx(Win32Native.NameSamCompatible, domainName, ref domainNameLen); - if (ret == 1) - { - string samName = domainName.ToString(); - int index = samName.IndexOf('\\'); - if (index != -1) - { - return samName.Substring(0, index); - } - } - else - { - int errorCode = Marshal.GetLastWin32Error(); - throw new InvalidOperationException(Win32Native.GetMessage(errorCode)); - } - - // Cannot use LookupAccountNameW to get DomainName because 'GetUserName' is not available in CSS and thus we cannot get the account. - throw new InvalidOperationException(CoreClrStubResources.CannotGetDomainName); - } - /// /// UserDomainName /// @@ -1023,33 +954,28 @@ namespace System.Management.Automation { get { - if (Platform.IsWindows()) + StringBuilder domainName = new StringBuilder(1024); + uint domainNameLen = (uint)domainName.Capacity; + + byte ret = Win32Native.GetUserNameEx(Win32Native.NameSamCompatible, domainName, ref domainNameLen); + if (ret == 1) { - return WinGetUserDomainName(); + string samName = domainName.ToString(); + int index = samName.IndexOf('\\'); + if (index != -1) + { + return samName.Substring(0, index); + } } else { - return Platform.NonWindowsGetDomainName(); + int errorCode = Marshal.GetLastWin32Error(); + throw new InvalidOperationException(Win32Native.GetMessage(errorCode)); } - } - } - - internal static string WinGetUserName() - { - StringBuilder domainName = new StringBuilder(1024); - uint domainNameLen = (uint)domainName.Capacity; - byte ret = Win32Native.GetUserNameEx(Win32Native.NameSamCompatible, domainName, ref domainNameLen); - if (ret == 1) - { - string samName = domainName.ToString(); - int index = samName.IndexOf('\\'); - if (index != -1) - { - return samName.Substring(index + 1); - } + // Cannot use LookupAccountNameW to get DomainName because 'GetUserName' is not available in CSS and thus we cannot get the account. + throw new InvalidOperationException(CoreClrStubResources.CannotGetDomainName); } - return string.Empty; } /// @@ -1059,26 +985,21 @@ namespace System.Management.Automation { get { - if (Platform.IsWindows()) - { - return WinGetUserName(); - } - else - { - return Platform.NonWindowsGetUserName(); - } - } - } + StringBuilder domainName = new StringBuilder(1024); + uint domainNameLen = (uint)domainName.Capacity; - internal static string WinGetMachineName() - { - // In future release of operating systems, you might be able to rename a machine without - // rebooting. Therefore, don't cache this machine name. - StringBuilder buf = new StringBuilder(MaxMachineNameLength); - int len = MaxMachineNameLength; - if (Win32Native.GetComputerName(buf, ref len) == 0) - throw new InvalidOperationException(CoreClrStubResources.CannotGetComputerName); - return buf.ToString(); + byte ret = Win32Native.GetUserNameEx(Win32Native.NameSamCompatible, domainName, ref domainNameLen); + if (ret == 1) + { + string samName = domainName.ToString(); + int index = samName.IndexOf('\\'); + if (index != -1) + { + return samName.Substring(index + 1); + } + } + return string.Empty; + } } /// @@ -1088,14 +1009,13 @@ namespace System.Management.Automation { get { - if (Platform.IsWindows()) - { - return WinGetMachineName(); - } - else - { - return Platform.NonWindowsGetMachineName(); - } + // In future release of operating systems, you might be able to rename a machine without + // rebooting. Therefore, don't cache this machine name. + StringBuilder buf = new StringBuilder(MaxMachineNameLength); + int len = MaxMachineNameLength; + if (Win32Native.GetComputerName(buf, ref len) == 0) + throw new InvalidOperationException(CoreClrStubResources.CannotGetComputerName); + return buf.ToString(); } } @@ -1108,45 +1028,22 @@ namespace System.Management.Automation { if (m_os == null) { - if (Platform.IsWindows()) + Win32Native.OSVERSIONINFOEX osviex = new Win32Native.OSVERSIONINFOEX(); + osviex.OSVersionInfoSize = Marshal.SizeOf(osviex); + if (!Win32Native.GetVersionEx(ref osviex)) { - m_os = WinOSVersion; + int errorCode = Marshal.GetLastWin32Error(); + throw new Win32Exception(errorCode); } - else - { - // TODO:PSL use P/Invoke to provide proper version - // Porting note: cannot put this in CorePsPlatform since - // System.Management.Automation.Environment only exists in CoreCLR - // builds of monad. - m_os = new Environment.OperatingSystem(new Version(1,0,0,0),""); - } + Version v = new Version(osviex.MajorVersion, osviex.MinorVersion, osviex.BuildNumber, (osviex.ServicePackMajor << 16) | osviex.ServicePackMinor); + m_os = new OperatingSystem(v, osviex.CSDVersion); } return m_os; } } private static volatile OperatingSystem m_os; - /// - /// Windows OSVersion implementation - /// - private static OperatingSystem WinOSVersion - { - get - { - Win32Native.OSVERSIONINFOEX osviex = new Win32Native.OSVERSIONINFOEX(); - osviex.OSVersionInfoSize = Marshal.SizeOf(osviex); - if (!Win32Native.GetVersionEx(ref osviex)) - { - int errorCode = Marshal.GetLastWin32Error(); - throw new Win32Exception(errorCode); - } - - Version v = new Version(osviex.MajorVersion, osviex.MinorVersion, osviex.BuildNumber, (osviex.ServicePackMajor << 16) | osviex.ServicePackMinor); - return new OperatingSystem(v, osviex.CSDVersion); - } - } - //TODO:CORECLR Need to decide what to do with 'requestedClrVersion' and 'requestedDotNetFrameworkVersion' in ModuleCmdletBase.cs [LoadModuleManifest] public static Version Version { @@ -1179,11 +1076,6 @@ namespace System.Management.Automation /// private static string InternalGetFolderPath(SpecialFolder folder) { - if (!Platform.IsWindows()) - { - return Platform.NonWindowsGetFolderPath(folder); - } - // The API 'SHGetFolderPath' is not available on OneCore, so we have to rely on environment variables string folderPath = null; string systemRoot = null; @@ -1264,7 +1156,7 @@ namespace System.Management.Automation /// DllImport uses the ApiSet dll that is available on CSS, since this code /// will only be included when building targeting CoreCLR. /// - internal static class Win32Native + private static class Win32Native { internal const int NameSamCompatible = 2; // EXTENDED_NAME_FORMAT - NameSamCompatible @@ -1331,17 +1223,13 @@ namespace System.Management.Automation #region NestedTypes - // Porting note: MyDocuments does not exist on .NET Core, but Personal does, and - // they both point to your "documents repository," which on linux, is just the - // home directory. - /// /// It only contains the values that get used in powershell /// internal enum SpecialFolder { - Personal = 0x05, - MyDocuments = 0x05, + MyDocuments = 5, + Personal = 5, LocalApplicationData = 0x1c, ProgramFiles = 0x26, ProgramFilesX86 = 0x2a, diff --git a/src/System.Management.Automation/CoreCLR/CorePsStub.cs b/src/System.Management.Automation/CoreCLR/CorePsStub.cs index 319e359ff..0269705b5 100644 --- a/src/System.Management.Automation/CoreCLR/CorePsStub.cs +++ b/src/System.Management.Automation/CoreCLR/CorePsStub.cs @@ -1,4 +1,3 @@ -#if CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -12,6 +11,8 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.Win32; using System.Management.Automation.Remoting; +#if CORECLR + #pragma warning disable 1591, 1572, 1571, 1573, 1587, 1570, 0067 #region CLR_STUBS @@ -631,6 +632,23 @@ namespace System } } +// There is no plan to support DataTable in ProjectK +namespace System.Data +{ + internal class DataTable + { + internal DataRowCollection Rows { get; set; } + } + + internal sealed class DataRowCollection : IEnumerable + { + public IEnumerator GetEnumerator() + { + throw new NotImplementedException("You are calling into the stub for 'DataRowCollection.GetEnumerator()'. It's not implemented."); + } + } +} + namespace System.Net { internal class WebClient //: Component @@ -1408,351 +1426,6 @@ namespace System.Management.Automation.Security } } - -#if NOETW || LINUX - -// Porting note: Tracing is absolutely not available on Linux -namespace System.Management.Automation.Tracing -{ - using System.Management.Automation.Internal; - - /// - /// - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")] - public abstract class EtwActivity - { - /// - /// - /// - /// - /// - public static bool SetActivityId(Guid activityId) - { - return false; - } - - /// - /// - /// - /// - public static Guid CreateActivityId() - { - return Guid.Empty; - } - - /// - /// - /// - /// - public static Guid GetActivityId() - { - return Guid.Empty; - } - } - - internal static class PSEtwLog - { - static internal void LogAnalyticError(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, params object[] args) { } - static internal void LogAnalyticWarning(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, params object[] args) { } - static internal void LogAnalyticVerbose(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, - Int64 objectId, - Int64 fragmentId, - int isStartFragment, - int isEndFragment, - UInt32 fragmentLength, - PSETWBinaryBlob fragmentData) - { } - static internal void LogAnalyticVerbose(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, params object[] args) { } - static internal void SetActivityIdForCurrentThread(Guid newActivityId) { } - static internal void LogOperationalVerbose(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, params object[] args){ } - static internal void LogOperationalWarning(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, params object[] args){ } - static internal void ReplaceActivityIdForCurrentThread(Guid newActivityId, PSEventId eventForOperationalChannel, PSEventId eventForAnalyticChannel, PSKeyword keyword, PSTask task) { } - static internal void LogOperationalError(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, params object[] args) { } - static internal void LogOperationalError(PSEventId id, PSOpcode opcode, PSTask task, LogContext logContext, string payLoad) { } - static internal void LogAnalyticInformational(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, params object[] args){ } - static internal void LogOperationalInformation(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, params object[] args){ } - } - - public enum PowerShellTraceTask - { - /// - /// None - /// - None = 0, - - /// - /// CreateRunspace - /// - CreateRunspace = 1, - - /// - /// ExecuteCommand - /// - ExecuteCommand = 2, - - /// - /// Serialization - /// - Serialization = 3, - - /// - /// PowerShellConsoleStartup - /// - PowerShellConsoleStartup = 4, - } - - /// - /// Defines Keywords. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028")] - [Flags] - public enum PowerShellTraceKeywords : ulong - { - /// - /// None - /// - None = 0, - - /// - /// Runspace - /// - Runspace = 0x1, - - /// - /// Pipeline - /// - Pipeline = 0x2, - - /// - /// Protocol - /// - Protocol = 0x4, - - /// - /// Transport - /// - Transport = 0x8, - - /// - /// Host - /// - Host = 0x10, - - /// - /// Cmdlets - /// - Cmdlets = 0x20, - - /// - /// Serializer - /// - Serializer = 0x40, - - /// - /// Session - /// - Session = 0x80, - - /// - /// ManagedPlugIn - /// - ManagedPlugIn = 0x100, - - /// - /// - /// - UseAlwaysDebug = 0x2000000000000000, - - /// - /// - /// - UseAlwaysOperational = 0x8000000000000000, - - /// - /// - /// - UseAlwaysAnalytic = 0x4000000000000000, - } - - public sealed partial class Tracer : System.Management.Automation.Tracing.EtwActivity - { - static Tracer() {} - - public void EndpointRegistered(string endpointName, string endpointType, string registeredBy) - { - } - - public void EndpointUnregistered(string endpointName, string unregisteredBy) - { - } - - public void EndpointDisabled(string endpointName, string disabledBy) - { - } - - public void EndpointEnabled(string endpointName, string enabledBy) - { - } - - public void EndpointModified(string endpointName, string modifiedBy) - { - } - - public void BeginContainerParentJobExecution(Guid containerParentJobInstanceId) - { - } - - public void BeginProxyJobExecution(Guid proxyJobInstanceId) - { - } - - public void ProxyJobRemoteJobAssociation(Guid proxyJobInstanceId, Guid containerParentJobInstanceId) - { - } - - public void EndProxyJobExecution(Guid proxyJobInstanceId) - { - } - - public void BeginProxyJobEventHandler(Guid proxyJobInstanceId) - { - } - - public void EndProxyJobEventHandler(Guid proxyJobInstanceId) - { - } - - public void BeginProxyChildJobEventHandler(Guid proxyChildJobInstanceId) - { - } - - public void EndContainerParentJobExecution(Guid containerParentJobInstanceId) - { - } - } - - public sealed class PowerShellTraceSource : IDisposable - { - internal PowerShellTraceSource(PowerShellTraceTask task, PowerShellTraceKeywords keywords) - { - } - - public void Dispose() - { - } - - public bool WriteMessage(String message) - { - return false; - } - - /// - /// - /// - /// - /// - /// - public bool WriteMessage(string message1, string message2) - { - return false; - } - - /// - /// - /// - /// - /// - /// - public bool WriteMessage(string message, Guid instanceId) - { - return false; - } - - - /// - /// - /// - /// - /// - /// - /// - /// - /// - public void WriteMessage(string className, string methodName, Guid workflowId, string message, params string[] parameters) - { - return ; - } - - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public void WriteMessage(string className, string methodName, Guid workflowId, Job job, string message, params string[] parameters) - { - return; - } - - public bool TraceException(Exception exception) - { - return false; - } - } - - /// - /// TraceSourceFactory will return an instance of TraceSource every time GetTraceSource method is called. - /// - public static class PowerShellTraceSourceFactory - { - /// - /// Returns an instance of BaseChannelWriter. - /// If the Etw is not supported by the platform it will return NullWriter.Instance - /// - /// A Task and a set of Keywords can be specified in the GetTraceSource method (See overloads). - /// The supplied task and keywords are used to pass to the Etw provider in case they are - /// not defined in the manifest file. - /// - public static PowerShellTraceSource GetTraceSource() - { - return new PowerShellTraceSource(PowerShellTraceTask.None, PowerShellTraceKeywords.None); - } - - /// - /// Returns an instance of BaseChannelWriter. - /// If the Etw is not supported by the platform it will return NullWriter.Instance - /// - /// A Task and a set of Keywords can be specified in the GetTraceSource method (See overloads). - /// The supplied task and keywords are used to pass to the Etw provider in case they are - /// not defined in the manifest file. - /// - public static PowerShellTraceSource GetTraceSource(PowerShellTraceTask task) - { - return new PowerShellTraceSource(task, PowerShellTraceKeywords.None); - } - - /// - /// Returns an instance of BaseChannelWriter. - /// If the Etw is not supported by the platform it will return NullWriter.Instance - /// - /// A Task and a set of Keywords can be specified in the GetTraceSource method (See overloads). - /// The supplied task and keywords are used to pass to the Etw provider in case they are - /// not defined in the manifest file. - /// - public static PowerShellTraceSource GetTraceSource(PowerShellTraceTask task, PowerShellTraceKeywords keywords) - { - return new PowerShellTraceSource(task, keywords); - } - } -} - -#endif - namespace Microsoft.PowerShell.Commands { using System.Management.Automation; diff --git a/src/System.Management.Automation/cimSupport/cmdletization/xml/CoreCLR/cmdlets-over-objects.objectModel.autogen.cs b/src/System.Management.Automation/cimSupport/cmdletization/xml/CoreCLR/cmdlets-over-objects.objectModel.autogen.cs index 1a24c5bac..a32b560d8 100644 --- a/src/System.Management.Automation/cimSupport/cmdletization/xml/CoreCLR/cmdlets-over-objects.objectModel.autogen.cs +++ b/src/System.Management.Automation/cimSupport/cmdletization/xml/CoreCLR/cmdlets-over-objects.objectModel.autogen.cs @@ -1,5 +1,4 @@ -#if CORECLR -// THIS FILE IS MANUALLY CHANGED BASED ON THE GENERATED FILE +// THIS FILE IS MANUALLY CHANGED BASED ON THE GENERATED FILE // // The original file has been generated by admin\monad\src\cimSupport\cmdletization\xml\generate.ps1 // based on the following input file: d:\bluedev\admin\monad\src\cimSupport\cmdletization\xml\cmdlets-over-objects.xsd @@ -1726,5 +1725,3 @@ namespace Microsoft.PowerShell.Cmdletization.Xml { } #endif - -#endif diff --git a/src/System.Management.Automation/cimSupport/cmdletization/xml/CoreCLR/cmdlets-over-objects.xmlSerializer.autogen.cs b/src/System.Management.Automation/cimSupport/cmdletization/xml/CoreCLR/cmdlets-over-objects.xmlSerializer.autogen.cs index fdbae2d56..8e351221b 100644 --- a/src/System.Management.Automation/cimSupport/cmdletization/xml/CoreCLR/cmdlets-over-objects.xmlSerializer.autogen.cs +++ b/src/System.Management.Automation/cimSupport/cmdletization/xml/CoreCLR/cmdlets-over-objects.xmlSerializer.autogen.cs @@ -1,5 +1,4 @@ -#if CORECLR -// THIS FILE IS MANUALLY CHANGED BASED ON THE GENERATED FILE +// THIS FILE IS MANUALLY CHANGED BASED ON THE GENERATED FILE // // The original file has been generated by admin\monad\src\cimSupport\cmdletization\xml\generate.ps1 // based on the following input file: d:\bluedev\admin\monad\src\cimSupport\cmdletization\xml\cmdlets-over-objects.xsd @@ -5290,5 +5289,3 @@ namespace Microsoft.PowerShell.Cmdletization.Xml { } #endif - -#endif diff --git a/src/System.Management.Automation/cimSupport/cmdletization/xml/cmdlets-over-objects.objectModel.autogen.cs b/src/System.Management.Automation/cimSupport/cmdletization/xml/cmdlets-over-objects.objectModel.autogen.cs index 6bf2ee034..e013baef1 100644 --- a/src/System.Management.Automation/cimSupport/cmdletization/xml/cmdlets-over-objects.objectModel.autogen.cs +++ b/src/System.Management.Automation/cimSupport/cmdletization/xml/cmdlets-over-objects.objectModel.autogen.cs @@ -1,5 +1,4 @@ -#if !CORECLR -// PLEASE DO NOT EDIT THIS FILE BY HAND!!! +// PLEASE DO NOT EDIT THIS FILE BY HAND!!! // // This file has been generated // by D:\bluedev\admin\monad\src\cimSupport\cmdletization\xml\generate.ps1 @@ -1796,5 +1795,3 @@ namespace Microsoft.PowerShell.Cmdletization.Xml { } } - -#endif diff --git a/src/System.Management.Automation/cimSupport/cmdletization/xml/cmdlets-over-objects.xmlSerializer.autogen.cs b/src/System.Management.Automation/cimSupport/cmdletization/xml/cmdlets-over-objects.xmlSerializer.autogen.cs index a6c5a5e60..213a12e86 100644 --- a/src/System.Management.Automation/cimSupport/cmdletization/xml/cmdlets-over-objects.xmlSerializer.autogen.cs +++ b/src/System.Management.Automation/cimSupport/cmdletization/xml/cmdlets-over-objects.xmlSerializer.autogen.cs @@ -1,5 +1,4 @@ -#if !CORECLR -// PLEASE DO NOT EDIT THIS FILE BY HAND!!! +// PLEASE DO NOT EDIT THIS FILE BY HAND!!! // // This file has been generated // by D:\bluedev\admin\monad\src\cimSupport\cmdletization\xml\generate.ps1 @@ -7756,5 +7755,3 @@ namespace Microsoft.PowerShell.Cmdletization.Xml { } } - -#endif diff --git a/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/FormatTable.cs b/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/FormatTable.cs index 9109d5237..46f2c8ee4 100644 --- a/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/FormatTable.cs +++ b/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/FormatTable.cs @@ -316,9 +316,23 @@ namespace System.Management.Automation.Runspaces string shellId = Utils.DefaultPowerShellShellID; string psHome = Utils.GetApplicationBase(shellId); List defaultFormatFiles = new List(); + List fileList = new List() + { + "Certificate.Format.ps1xml", + "Event.Format.ps1xml", + "Diagnostics.Format.ps1xml", + "DotNetTypes.Format.ps1xml", + "FileSystem.Format.ps1xml", + "Help.Format.ps1xml", + "HelpV3.Format.ps1xml", + "PowerShellCore.format.ps1xml", + "PowerShellTrace.format.ps1xml", + "Registry.format.ps1xml", + "WSMan.Format.ps1xml" + }; if (!string.IsNullOrEmpty(psHome)) { - defaultFormatFiles.AddRange(Platform.FormatFileNames.Select(file => Path.Combine(psHome, file))); + defaultFormatFiles.AddRange(fileList.Select(file => Path.Combine(psHome, file))); } return new FormatTable(defaultFormatFiles); diff --git a/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/displayResourceManagerCache.cs b/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/displayResourceManagerCache.cs index 3c7295a6f..f2c4b0100 100644 --- a/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/displayResourceManagerCache.cs +++ b/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/displayResourceManagerCache.cs @@ -165,10 +165,6 @@ namespace Microsoft.PowerShell.Commands.Internal.Format retVal = ResolveAssemblyNameInLoadedAssemblies(assemblyName, false); } // NOTE: we cache the result (both for success and failure) - - // Porting note: this won't be hit in normal usage, but can be hit with bad build setup - Diagnostics.Assert(retVal != null, "AssemblyName resolution failed, a resource file might be broken"); - _assemblyReferences.Add(assemblyName, retVal); return retVal; } diff --git a/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs b/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs index f37434522..21952638e 100644 --- a/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs +++ b/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs @@ -1809,8 +1809,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format // optional pre-load and binding verification - // Porting Note: DLL.resources are not currently available on Linux - if (!Platform.IsX() && this.VerifyStringResources) + if (this.VerifyStringResources) { DisplayResourceManagerCache.LoadingResult result; DisplayResourceManagerCache.AssemblyBindingStatus bindingStatus; diff --git a/src/System.Management.Automation/engine/CodeMethods.cs b/src/System.Management.Automation/engine/CodeMethods.cs index 7c6060009..68e29b31e 100644 --- a/src/System.Management.Automation/engine/CodeMethods.cs +++ b/src/System.Management.Automation/engine/CodeMethods.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -132,5 +131,3 @@ namespace Microsoft.PowerShell #endregion } } - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ArgBuilder.cs b/src/System.Management.Automation/engine/ComInterop/ArgBuilder.cs index f259f1cef..548fed6d9 100644 --- a/src/System.Management.Automation/engine/ComInterop/ArgBuilder.cs +++ b/src/System.Management.Automation/engine/ComInterop/ArgBuilder.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -44,5 +43,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/BoolArgBuilder.cs b/src/System.Management.Automation/engine/ComInterop/BoolArgBuilder.cs index 3057cc896..d0939bfe9 100644 --- a/src/System.Management.Automation/engine/ComInterop/BoolArgBuilder.cs +++ b/src/System.Management.Automation/engine/ComInterop/BoolArgBuilder.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -47,5 +46,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/BoundDispEvent.cs b/src/System.Management.Automation/engine/ComInterop/BoundDispEvent.cs index 535dd0fb6..b36efe37f 100644 --- a/src/System.Management.Automation/engine/ComInterop/BoundDispEvent.cs +++ b/src/System.Management.Automation/engine/ComInterop/BoundDispEvent.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -100,5 +99,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/CollectionExtensions.cs b/src/System.Management.Automation/engine/ComInterop/CollectionExtensions.cs index 13f6aca2e..1be7f3a41 100644 --- a/src/System.Management.Automation/engine/ComInterop/CollectionExtensions.cs +++ b/src/System.Management.Automation/engine/ComInterop/CollectionExtensions.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -39,5 +38,3 @@ namespace System.Management.Automation.ComInterop { } } - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComBinder.cs b/src/System.Management.Automation/engine/ComInterop/ComBinder.cs index 0ab529f53..adedd7928 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComBinder.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComBinder.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -374,5 +373,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComBinderHelpers.cs b/src/System.Management.Automation/engine/ComInterop/ComBinderHelpers.cs index 19d736281..f5a1ca3ae 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComBinderHelpers.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComBinderHelpers.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -132,5 +131,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComClassMetaObject.cs b/src/System.Management.Automation/engine/ComInterop/ComClassMetaObject.cs index 939358b2c..86849c11d 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComClassMetaObject.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComClassMetaObject.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -39,5 +38,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComDispIds.cs b/src/System.Management.Automation/engine/ComInterop/ComDispIds.cs index 55825e0be..c1332c0e7 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComDispIds.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComDispIds.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -15,5 +14,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComEventDesc.cs b/src/System.Management.Automation/engine/ComInterop/ComEventDesc.cs index 7f8653ca4..3c1238e06 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComEventDesc.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComEventDesc.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -16,5 +15,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComEventSink.cs b/src/System.Management.Automation/engine/ComInterop/ComEventSink.cs index d5ddcb533..5e2eb2530 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComEventSink.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComEventSink.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -319,5 +318,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComEventSinkProxy.cs b/src/System.Management.Automation/engine/ComInterop/ComEventSinkProxy.cs index c5c515422..93e433ee2 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComEventSinkProxy.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComEventSinkProxy.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -117,5 +116,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComEventSinksContainer.cs b/src/System.Management.Automation/engine/ComInterop/ComEventSinksContainer.cs index 4a4ea0ecc..ee74a3a6c 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComEventSinksContainer.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComEventSinksContainer.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -70,5 +69,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComFallbackMetaObject.cs b/src/System.Management.Automation/engine/ComInterop/ComFallbackMetaObject.cs index 437c5332b..1e2b0f41e 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComFallbackMetaObject.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComFallbackMetaObject.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -70,5 +69,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComHresults.cs b/src/System.Management.Automation/engine/ComInterop/ComHresults.cs index 1ca681678..951364f03 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComHresults.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComHresults.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -37,5 +36,3 @@ namespace System.Management.Automation.ComInterop { } #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComInterop.cs b/src/System.Management.Automation/engine/ComInterop/ComInterop.cs index ff5ee3ce3..2d5b445a5 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComInterop.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComInterop.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -83,5 +82,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComInvokeAction.cs b/src/System.Management.Automation/engine/ComInterop/ComInvokeAction.cs index 884ab803e..2e9ad0143 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComInvokeAction.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComInvokeAction.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -95,5 +94,3 @@ namespace System.Management.Automation.ComInterop { } #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComInvokeBinder.cs b/src/System.Management.Automation/engine/ComInterop/ComInvokeBinder.cs index 27fda6001..f5588edb6 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComInvokeBinder.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComInvokeBinder.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -529,5 +528,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComMetaObject.cs b/src/System.Management.Automation/engine/ComInterop/ComMetaObject.cs index 1e29f549c..09be6a229 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComMetaObject.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComMetaObject.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -64,5 +63,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComMethodDesc.cs b/src/System.Management.Automation/engine/ComInterop/ComMethodDesc.cs index 731e806c6..3433e3a82 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComMethodDesc.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComMethodDesc.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -122,5 +121,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComObject.cs b/src/System.Management.Automation/engine/ComInterop/ComObject.cs index fda5efb0f..72feba2a6 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComObject.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComObject.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -126,5 +125,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComParamDesc.cs b/src/System.Management.Automation/engine/ComInterop/ComParamDesc.cs index 13b57ec1a..097ab7c1e 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComParamDesc.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComParamDesc.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -155,5 +154,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComRuntimeHelpers.cs b/src/System.Management.Automation/engine/ComInterop/ComRuntimeHelpers.cs index 59c2b0dbe..c43e5fe94 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComRuntimeHelpers.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComRuntimeHelpers.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -766,5 +765,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComType.cs b/src/System.Management.Automation/engine/ComInterop/ComType.cs index bd6bb75de..916e59373 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComType.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComType.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -16,5 +15,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComTypeClassDesc.cs b/src/System.Management.Automation/engine/ComInterop/ComTypeClassDesc.cs index 9f30a3de9..62e56f7a2 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComTypeClassDesc.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComTypeClassDesc.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -83,5 +82,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComTypeDesc.cs b/src/System.Management.Automation/engine/ComInterop/ComTypeDesc.cs index 8928119fa..a76b00180 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComTypeDesc.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComTypeDesc.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -221,5 +220,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComTypeEnumDesc.cs b/src/System.Management.Automation/engine/ComInterop/ComTypeEnumDesc.cs index d14290050..a2db280bd 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComTypeEnumDesc.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComTypeEnumDesc.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -92,5 +91,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComTypeLibDesc.cs b/src/System.Management.Automation/engine/ComInterop/ComTypeLibDesc.cs index d56a0d430..8313529a3 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComTypeLibDesc.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComTypeLibDesc.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -226,5 +225,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComTypeLibInfo.cs b/src/System.Management.Automation/engine/ComInterop/ComTypeLibInfo.cs index d43893de2..39ea1e7b7 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComTypeLibInfo.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComTypeLibInfo.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -56,5 +55,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ComTypeLibMemberDesc.cs b/src/System.Management.Automation/engine/ComInterop/ComTypeLibMemberDesc.cs index 5fff34b71..5bca5cbb7 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComTypeLibMemberDesc.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComTypeLibMemberDesc.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -23,5 +22,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ConversionArgBuilder.cs b/src/System.Management.Automation/engine/ComInterop/ConversionArgBuilder.cs index 59cd849db..e40f25476 100644 --- a/src/System.Management.Automation/engine/ComInterop/ConversionArgBuilder.cs +++ b/src/System.Management.Automation/engine/ComInterop/ConversionArgBuilder.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -40,5 +39,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ConvertArgBuilder.cs b/src/System.Management.Automation/engine/ComInterop/ConvertArgBuilder.cs index 180d956c9..7a881108e 100644 --- a/src/System.Management.Automation/engine/ComInterop/ConvertArgBuilder.cs +++ b/src/System.Management.Automation/engine/ComInterop/ConvertArgBuilder.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -35,5 +34,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ConvertibleArgBuilder.cs b/src/System.Management.Automation/engine/ComInterop/ConvertibleArgBuilder.cs index 0ccac5030..351610caa 100644 --- a/src/System.Management.Automation/engine/ComInterop/ConvertibleArgBuilder.cs +++ b/src/System.Management.Automation/engine/ComInterop/ConvertibleArgBuilder.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -35,5 +34,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/CurrencyArgBuilder.cs b/src/System.Management.Automation/engine/ComInterop/CurrencyArgBuilder.cs index 54deed6d2..f3ecb9f5f 100644 --- a/src/System.Management.Automation/engine/ComInterop/CurrencyArgBuilder.cs +++ b/src/System.Management.Automation/engine/ComInterop/CurrencyArgBuilder.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -54,5 +53,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/DateTimeArgBuilder.cs b/src/System.Management.Automation/engine/ComInterop/DateTimeArgBuilder.cs index 392b328c3..e36b60db5 100644 --- a/src/System.Management.Automation/engine/ComInterop/DateTimeArgBuilder.cs +++ b/src/System.Management.Automation/engine/ComInterop/DateTimeArgBuilder.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -45,5 +44,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/DispCallable.cs b/src/System.Management.Automation/engine/ComInterop/DispCallable.cs index 729a0e6a0..dfe8e615f 100644 --- a/src/System.Management.Automation/engine/ComInterop/DispCallable.cs +++ b/src/System.Management.Automation/engine/ComInterop/DispCallable.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -68,5 +67,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/DispCallableMetaObject.cs b/src/System.Management.Automation/engine/ComInterop/DispCallableMetaObject.cs index 0bc092256..f2280c79c 100644 --- a/src/System.Management.Automation/engine/ComInterop/DispCallableMetaObject.cs +++ b/src/System.Management.Automation/engine/ComInterop/DispCallableMetaObject.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -139,5 +138,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/DispatchArgBuilder.cs b/src/System.Management.Automation/engine/ComInterop/DispatchArgBuilder.cs index de8eae0ea..ae543f809 100644 --- a/src/System.Management.Automation/engine/ComInterop/DispatchArgBuilder.cs +++ b/src/System.Management.Automation/engine/ComInterop/DispatchArgBuilder.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -80,5 +79,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ErrorArgBuilder.cs b/src/System.Management.Automation/engine/ComInterop/ErrorArgBuilder.cs index 92231dec8..fdcf32f9c 100644 --- a/src/System.Management.Automation/engine/ComInterop/ErrorArgBuilder.cs +++ b/src/System.Management.Automation/engine/ComInterop/ErrorArgBuilder.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -46,5 +45,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/Errors.cs b/src/System.Management.Automation/engine/ComInterop/Errors.cs index 93346edf9..072311322 100644 --- a/src/System.Management.Automation/engine/ComInterop/Errors.cs +++ b/src/System.Management.Automation/engine/ComInterop/Errors.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -242,5 +241,3 @@ namespace System.Management.Automation.ComInterop { } - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/ExcepInfo.cs b/src/System.Management.Automation/engine/ComInterop/ExcepInfo.cs index 81d0744e1..4a7f97ad3 100644 --- a/src/System.Management.Automation/engine/ComInterop/ExcepInfo.cs +++ b/src/System.Management.Automation/engine/ComInterop/ExcepInfo.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -101,5 +100,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/Helpers.cs b/src/System.Management.Automation/engine/ComInterop/Helpers.cs index 462ce1169..20d903ef3 100644 --- a/src/System.Management.Automation/engine/ComInterop/Helpers.cs +++ b/src/System.Management.Automation/engine/ComInterop/Helpers.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -25,5 +24,3 @@ namespace System.Management.Automation.ComInterop { } } - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/IDispatchComObject.cs b/src/System.Management.Automation/engine/ComInterop/IDispatchComObject.cs index 9bfc8b4da..7b41bfc59 100644 --- a/src/System.Management.Automation/engine/ComInterop/IDispatchComObject.cs +++ b/src/System.Management.Automation/engine/ComInterop/IDispatchComObject.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -630,5 +629,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/IDispatchMetaObject.cs b/src/System.Management.Automation/engine/ComInterop/IDispatchMetaObject.cs index 8f1df754d..3aef3cb4f 100644 --- a/src/System.Management.Automation/engine/ComInterop/IDispatchMetaObject.cs +++ b/src/System.Management.Automation/engine/ComInterop/IDispatchMetaObject.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -319,5 +318,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/IPseudoComObject.cs b/src/System.Management.Automation/engine/ComInterop/IPseudoComObject.cs index 294b01b42..be7cce088 100644 --- a/src/System.Management.Automation/engine/ComInterop/IPseudoComObject.cs +++ b/src/System.Management.Automation/engine/ComInterop/IPseudoComObject.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -18,5 +17,3 @@ namespace System.Management.Automation.ComInterop { } } - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/NullArgBuilder.cs b/src/System.Management.Automation/engine/ComInterop/NullArgBuilder.cs index e4ecf2088..08d7771e1 100644 --- a/src/System.Management.Automation/engine/ComInterop/NullArgBuilder.cs +++ b/src/System.Management.Automation/engine/ComInterop/NullArgBuilder.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -29,5 +28,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/SimpleArgBuilder.cs b/src/System.Management.Automation/engine/ComInterop/SimpleArgBuilder.cs index f86b9b729..065dcce1d 100644 --- a/src/System.Management.Automation/engine/ComInterop/SimpleArgBuilder.cs +++ b/src/System.Management.Automation/engine/ComInterop/SimpleArgBuilder.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -45,5 +44,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/SplatCallSite.cs b/src/System.Management.Automation/engine/ComInterop/SplatCallSite.cs index c34a6c8af..1b28e7fe8 100644 --- a/src/System.Management.Automation/engine/ComInterop/SplatCallSite.cs +++ b/src/System.Management.Automation/engine/ComInterop/SplatCallSite.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -51,5 +50,3 @@ namespace System.Management.Automation.ComInterop { } #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/StringArgBuilder.cs b/src/System.Management.Automation/engine/ComInterop/StringArgBuilder.cs index 51e9630ca..b42e04213 100644 --- a/src/System.Management.Automation/engine/ComInterop/StringArgBuilder.cs +++ b/src/System.Management.Automation/engine/ComInterop/StringArgBuilder.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -79,5 +78,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/TypeEnumMetaObject.cs b/src/System.Management.Automation/engine/ComInterop/TypeEnumMetaObject.cs index 85ab23159..08b485e62 100644 --- a/src/System.Management.Automation/engine/ComInterop/TypeEnumMetaObject.cs +++ b/src/System.Management.Automation/engine/ComInterop/TypeEnumMetaObject.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -75,5 +74,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/TypeLibInfoMetaObject.cs b/src/System.Management.Automation/engine/ComInterop/TypeLibInfoMetaObject.cs index b75f50fb4..74fcd7c82 100644 --- a/src/System.Management.Automation/engine/ComInterop/TypeLibInfoMetaObject.cs +++ b/src/System.Management.Automation/engine/ComInterop/TypeLibInfoMetaObject.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -63,5 +62,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/TypeLibMetaObject.cs b/src/System.Management.Automation/engine/ComInterop/TypeLibMetaObject.cs index 39a10f83f..0c976abb8 100644 --- a/src/System.Management.Automation/engine/ComInterop/TypeLibMetaObject.cs +++ b/src/System.Management.Automation/engine/ComInterop/TypeLibMetaObject.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -76,5 +75,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/TypeUtils.cs b/src/System.Management.Automation/engine/ComInterop/TypeUtils.cs index b24f896da..374c48dd9 100644 --- a/src/System.Management.Automation/engine/ComInterop/TypeUtils.cs +++ b/src/System.Management.Automation/engine/ComInterop/TypeUtils.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -245,5 +244,3 @@ namespace System.Management.Automation.ComInterop { } } - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/UnknownArgBuilder.cs b/src/System.Management.Automation/engine/ComInterop/UnknownArgBuilder.cs index 66295226a..6b429462f 100644 --- a/src/System.Management.Automation/engine/ComInterop/UnknownArgBuilder.cs +++ b/src/System.Management.Automation/engine/ComInterop/UnknownArgBuilder.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -80,5 +79,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/VarEnumSelector.cs b/src/System.Management.Automation/engine/ComInterop/VarEnumSelector.cs index 88c4feb43..9f727d4a0 100644 --- a/src/System.Management.Automation/engine/ComInterop/VarEnumSelector.cs +++ b/src/System.Management.Automation/engine/ComInterop/VarEnumSelector.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -516,5 +515,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/Variant.cs b/src/System.Management.Automation/engine/ComInterop/Variant.cs index 4791083e4..586bdfc3e 100644 --- a/src/System.Management.Automation/engine/ComInterop/Variant.cs +++ b/src/System.Management.Automation/engine/ComInterop/Variant.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -842,5 +841,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/VariantArgBuilder.cs b/src/System.Management.Automation/engine/ComInterop/VariantArgBuilder.cs index 6dae9f984..69ab54d8c 100644 --- a/src/System.Management.Automation/engine/ComInterop/VariantArgBuilder.cs +++ b/src/System.Management.Automation/engine/ComInterop/VariantArgBuilder.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -71,5 +70,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/VariantArray.cs b/src/System.Management.Automation/engine/ComInterop/VariantArray.cs index 02cd757bd..63e593475 100644 --- a/src/System.Management.Automation/engine/ComInterop/VariantArray.cs +++ b/src/System.Management.Automation/engine/ComInterop/VariantArray.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -98,5 +97,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/ComInterop/VariantBuilder.cs b/src/System.Management.Automation/engine/ComInterop/VariantBuilder.cs index eb7df589b..9a5cadef1 100644 --- a/src/System.Management.Automation/engine/ComInterop/VariantBuilder.cs +++ b/src/System.Management.Automation/engine/ComInterop/VariantBuilder.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -162,5 +161,3 @@ namespace System.Management.Automation.ComInterop { #endif - -#endif diff --git a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs index 9b6b1735a..05465a111 100644 --- a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs +++ b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs @@ -4309,9 +4309,8 @@ namespace System.Management.Automation { var sessionStateInternal = executionContext.EngineSessionState; completionText = sessionStateInternal.NormalizeRelativePath(path, sessionStateInternal.CurrentLocation.ProviderPath); - string parentDirectory = ".." + Path.DirectorySeparatorChar; - if (!completionText.StartsWith(parentDirectory, StringComparison.Ordinal)) - completionText = Path.Combine(".", completionText); + if (!completionText.StartsWith("..\\", StringComparison.Ordinal)) + completionText = ".\\" + completionText; } catch (Exception e) { @@ -4449,12 +4448,6 @@ namespace System.Management.Automation internal static List GetFileShares(string machine, bool ignoreHidden) { - // Platform notes: don't throw an exception since this is being used in auto-completion - if (!Platform.HasFileShares()) - { - return new List(); - } - IntPtr shBuf; uint numEntries; uint totalEntries; diff --git a/src/System.Management.Automation/engine/CommandDiscovery.cs b/src/System.Management.Automation/engine/CommandDiscovery.cs index 2d57504b8..0370bfd58 100644 --- a/src/System.Management.Automation/engine/CommandDiscovery.cs +++ b/src/System.Management.Automation/engine/CommandDiscovery.cs @@ -1322,8 +1322,7 @@ namespace System.Management.Automation } // Close the progress pane that may have popped up from analyzing UNC paths. - // Porting note: we don't like this message - if (!Platform.IsX() && context.CurrentCommandProcessor != null) + if (context.CurrentCommandProcessor != null) { ProgressRecord analysisProgress = new ProgressRecord(0, Modules.ScriptAnalysisPreparing, " "); analysisProgress.RecordType = ProgressRecordType.Completed; @@ -1516,7 +1515,8 @@ namespace System.Management.Automation /// /// /// - /// The contents of the PATH environment variable split on System.IO.Path.PathSeparator. + /// The contents of the PATH environment variable split using a semi-colon + /// as a delimiter. /// /// /// @@ -1549,7 +1549,7 @@ namespace System.Management.Automation if (pathCacheKey != null) { - string[] tokenizedPath = pathCacheKey.Split(new char[] { System.IO.Path.PathSeparator }, StringSplitOptions.RemoveEmptyEntries); + string[] tokenizedPath = pathCacheKey.Split(Utils.Separators.Semicolon, StringSplitOptions.RemoveEmptyEntries); cachedPath = new Collection(); foreach (string directory in tokenizedPath) @@ -1640,7 +1640,7 @@ namespace System.Management.Automation lock (lockObject) { cachedPathExtCollection = pathExt != null - ? pathExt.Split(new char[] { System.IO.Path.PathSeparator }, StringSplitOptions.RemoveEmptyEntries) + ? pathExt.Split(Utils.Separators.Semicolon, StringSplitOptions.RemoveEmptyEntries) : Utils.EmptyArray(); cachedPathExtCollectionWithPs1 = new string[cachedPathExtCollection.Length + 1]; cachedPathExtCollectionWithPs1[0] = StringLiterals.PowerShellScriptFileExtension; @@ -1903,11 +1903,6 @@ namespace System.Management.Automation /// internal static string GetShellPathFromRegistry(string shellID) { - if (!Platform.HasRegistrySupport()) - { - return null; - } - string result = null; try diff --git a/src/System.Management.Automation/engine/CommandPathSearch.cs b/src/System.Management.Automation/engine/CommandPathSearch.cs index 0c4edaf8f..7e6302cd2 100644 --- a/src/System.Management.Automation/engine/CommandPathSearch.cs +++ b/src/System.Management.Automation/engine/CommandPathSearch.cs @@ -55,11 +55,7 @@ namespace System.Management.Automation // The name passed in is not a pattern. To minimize enumerating the file system, we // turn the command name into a pattern and then match against extensions in PATHEXT. // The old code would enumerate the file system many more times, once per possible extension. - // Porting note: this is wrong on Linux, where we don't depend on extensions - if (Platform.IsWindows()) - { - commandName = commandName + ".*"; - } + commandName = commandName + ".*"; this.postProcessEnumeratedFiles = CheckAgainstAcceptableCommandNames; this.acceptableCommandNames = acceptableCommandNames; } @@ -465,10 +461,8 @@ namespace System.Management.Automation { var baseNames = fileNames.Select(Path.GetFileName).ToArray(); - // Result must be ordered by PATHEXT order of precedence. - // acceptableCommandNames is in this order, so - - // Porting note: allow files with executable bit on non-Windows platforms + // Result must be ordered by PATHEXT order of precdence. + // accpetableCommandNames is in this order, so Collection result = null; if (baseNames.Length > 0) @@ -477,8 +471,7 @@ namespace System.Management.Automation { for (int i = 0; i < baseNames.Length; i++) { - if (name.Equals(baseNames[i], StringComparison.OrdinalIgnoreCase) - || (!Platform.IsWindows() && Platform.NonWindowsIsExecutable(name))) + if (name.Equals(baseNames[i], StringComparison.OrdinalIgnoreCase)) { if (result == null) result = new Collection(); @@ -494,18 +487,14 @@ namespace System.Management.Automation private IEnumerable JustCheckExtensions(string[] fileNames) { - // Warning: pretty duplicated code - // Result must be ordered by PATHEXT order of precedence. - - // Porting note: allow files with executable bit on non-Windows platforms + // Result must be ordered by PATHEXT order of precdence. Collection result = null; foreach (var allowedExt in orderedPathExt) { foreach (var fileName in fileNames) { - if (fileName.EndsWith(allowedExt, StringComparison.OrdinalIgnoreCase) - || (!Platform.IsWindows() && Platform.NonWindowsIsExecutable(fileName))) + if (fileName.EndsWith(allowedExt, StringComparison.OrdinalIgnoreCase)) { if (result == null) result = new Collection(); diff --git a/src/System.Management.Automation/engine/DataStoreAdapter.cs b/src/System.Management.Automation/engine/DataStoreAdapter.cs index e6f926e2c..4c796937b 100644 --- a/src/System.Management.Automation/engine/DataStoreAdapter.cs +++ b/src/System.Management.Automation/engine/DataStoreAdapter.cs @@ -299,58 +299,6 @@ namespace System.Management.Automation } private string displayRoot = null; - /// - /// Gets or sets if the drive-root relative paths on this drive are separated by a - /// colon or not. - /// - /// This is true for all PSDrives on all platforms, except for filesystems on - /// non-Windows platforms. - /// - /// This is not a path separator in the sense of separating paths in a single - /// string. - /// - /// The biggest difference in filesystem handling between PS internally, and Unix - /// style systems is, that paths on Windows separate the drive letter from the - /// actual path by a colon. The second difference is, that a path that starts with - /// a \ or / on Windows is considered to be a relative path (drive-relative in - /// that case) where a similar path on a Unix style filesystem would be - /// root-relative, which is basically drive-relative for the filesystem, as there - /// is only one filesystem drive. - /// - /// This property indicates, that a path can be checked for that drive-relativity - /// by checking for a colon. The main reason for this can be seen in all the - /// places that use this property, where PowerShell's code checks/splits/string - /// manipulates paths according to the colon character. This happens in many - /// places. - /// - /// The idea here was to introduce a property that allows a code to query if a - /// PSDrive expects colon to be such a separator or not. I talked to Jim back then - /// about the problem, and this seemed to be a reasonable solution, given that - /// there is no other way to know for a PSDrive if paths can be qualified only in - /// a certain windows way on all platforms, or need special treatment on platforms - /// where colon does not exist as drive separator (regular filesystems on Unix - /// platforms are the only exception). - /// - /// Globally this property can also be only true for one single PSDrive, because - /// if there is no drive separator, there is also no drive, and because there is - /// no drive there is no way to match against multiple such drives. - /// - /// Additional data: - /// It seems that on single rooted filesystems, only the default - /// drive of "/" needs to set this VolumeSeparatedByColon to false - /// otherwise, creating new drives from the filesystem should actually - /// have this set to true as all the drives will have : except - /// for "/" - /// - /// - public bool VolumeSeparatedByColon - { - get { return _volumeSeparatedByColon; } - internal set { _volumeSeparatedByColon = value; } - } - private bool _volumeSeparatedByColon = true; - - #region ctor /// diff --git a/src/System.Management.Automation/engine/DataStoreAdapterProvider.cs b/src/System.Management.Automation/engine/DataStoreAdapterProvider.cs index 12d63374d..74e9115ba 100644 --- a/src/System.Management.Automation/engine/DataStoreAdapterProvider.cs +++ b/src/System.Management.Automation/engine/DataStoreAdapterProvider.cs @@ -301,20 +301,6 @@ namespace System.Management.Automation Thread.AllocateDataSlot(); #endif - /// - /// Gets or sets if the drive-root relative paths on drives of this provider - /// are separated by a colon or not. - /// - /// This is true for all PSDrives on all platforms, except for filesystems on - /// non-windows platforms - /// - public bool VolumeSeparatedByColon - { - get { return volumeSeparatedByColon; } - internal set { volumeSeparatedByColon = value; } - } - private bool volumeSeparatedByColon = true; - /// /// Constructs an instance of the class using an existing reference /// as a template. @@ -350,7 +336,6 @@ namespace System.Management.Automation this.helpFile = providerInfo.helpFile; this.pssnapin = providerInfo.pssnapin; this.sessionState = providerInfo.sessionState; - this.volumeSeparatedByColon = providerInfo.volumeSeparatedByColon; } /// @@ -496,13 +481,6 @@ namespace System.Management.Automation null); hiddenDrive.Hidden = true; - - // TODO:PSL - // this is probably not right here - if (implementingType == typeof(Microsoft.PowerShell.Commands.FileSystemProvider) && !Platform.IsWindows()) - { - volumeSeparatedByColon = false; - } } #if SUPPORTS_CMDLETPROVIDER_FILE diff --git a/src/System.Management.Automation/engine/ExecutionContext.cs b/src/System.Management.Automation/engine/ExecutionContext.cs index c0db81346..5920cad06 100644 --- a/src/System.Management.Automation/engine/ExecutionContext.cs +++ b/src/System.Management.Automation/engine/ExecutionContext.cs @@ -1559,7 +1559,7 @@ namespace System.Management.Automation try { - loadedAssembly = ClrFacade.Load(new AssemblyName(assemblyString)); + loadedAssembly = Assembly.Load(new AssemblyName(assemblyString)); } catch (FileNotFoundException fileNotFound) { diff --git a/src/System.Management.Automation/engine/ExtraAdapter.cs b/src/System.Management.Automation/engine/ExtraAdapter.cs index 0982ff8ad..cf84d41de 100644 --- a/src/System.Management.Automation/engine/ExtraAdapter.cs +++ b/src/System.Management.Automation/engine/ExtraAdapter.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -597,5 +596,3 @@ namespace System.Management.Automation #endregion method } } - -#endif diff --git a/src/System.Management.Automation/engine/InformationRecord.cs b/src/System.Management.Automation/engine/InformationRecord.cs index b698501db..e3e373a16 100644 --- a/src/System.Management.Automation/engine/InformationRecord.cs +++ b/src/System.Management.Automation/engine/InformationRecord.cs @@ -38,15 +38,7 @@ namespace System.Management.Automation this.TimeGenerated = DateTime.Now; this.Tags = new List(); - if (Platform.IsWindows()) - { - this.User = System.Security.Principal.WindowsIdentity.GetCurrent().Name; - } - else - { - this.User = Platform.NonWindowsGetUserName(); - } - // Porting note: PsUtils.GetHostName() already handles platform specifics + this.User = System.Security.Principal.WindowsIdentity.GetCurrent().Name; this.Computer = PsUtils.GetHostName(); this.ProcessId = (uint) System.Diagnostics.Process.GetCurrentProcess().Id; this.NativeThreadId = PsUtils.GetNativeThreadId(); @@ -233,4 +225,4 @@ namespace System.Management.Automation return Message; } } -} +} \ No newline at end of file diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs index dc0e68bd3..b418a28ad 100644 --- a/src/System.Management.Automation/engine/InitialSessionState.cs +++ b/src/System.Management.Automation/engine/InitialSessionState.cs @@ -1673,9 +1673,19 @@ namespace System.Management.Automation.Runspaces return iss; } - // Porting note: moved to Platform so we have one list to maintain - private static string[] PSCoreFormatFileNames = Platform.FormatFileNames.ToArray(); - + private static string[] PSCoreFormatFileNames = { + "Certificate.format.ps1xml", + "Diagnostics.Format.ps1xml", + "DotNetTypes.format.ps1xml", + "Event.Format.ps1xml", + "FileSystem.format.ps1xml", + "Help.format.ps1xml", + "HelpV3.format.ps1xml", + "PowerShellCore.format.ps1xml", + "PowerShellTrace.format.ps1xml", + "Registry.format.ps1xml", + "WSMan.Format.ps1xml" + }; private static void IncludePowerShellCoreFormats(InitialSessionState iss) { string psHome = Utils.GetApplicationBase(Utils.DefaultPowerShellShellID); @@ -1775,14 +1785,25 @@ namespace System.Management.Automation.Runspaces } } - // Porting note: copy so it can be modified - List allowedFormats = new List(Platform.FormatFileNames); + List allowedFormats = new List + { + "Certificate.Format.ps1xml", + "Event.format.ps1xml", + "Diagnostics.format.ps1xml", + "DotNetTypes.Format.ps1xml", + "FileSystem.Format.ps1xml", + "Help.Format.ps1xml", + "HelpV3.format.ps1xml", + "PowerShellCore.format.ps1xml", + "PowerShellTrace.format.ps1xml", + "Registry.format.ps1xml", + "WSMan.format.ps1xml" + }; RemoveDisallowedEntries( iss.Formats, allowedFormats, formatEntry => IO.Path.GetFileName(formatEntry.FileName)); - // Porting note: type files were deprecated List allowedTypes = new List(); allowedTypes.AddRange(DefaultTypeFiles); RemoveDisallowedEntries( @@ -1850,14 +1871,25 @@ namespace System.Management.Automation.Runspaces } } - // Porting note: copy so it can be modified - List allowedFormats = new List(Platform.FormatFileNames); + List allowedFormats = new List + { + "Certificate.Format.ps1xml", + "Event.format.ps1xml", + "Diagnostics.format.ps1xml", + "DotNetTypes.Format.ps1xml", + "FileSystem.Format.ps1xml", + "Help.Format.ps1xml", + "HelpV3.format.ps1xml", + "PowerShellCore.format.ps1xml", + "PowerShellTrace.format.ps1xml", + "Registry.format.ps1xml", + "WSMan.format.ps1xml" + }; RemoveDisallowedEntries( iss.Formats, allowedFormats, formatEntry => IO.Path.GetFileName(formatEntry.FileName)); - // Porting note: type files were deprecated List allowedTypes = new List(); allowedTypes.AddRange(DefaultTypeFiles); RemoveDisallowedEntries( @@ -4256,7 +4288,6 @@ namespace System.Management.Automation.Runspaces return coreSnapin; } - // WARNING: THIS CODE IS COMPLETELY DUPLICATED IN RunspaceConfigForSingleShell internal PSSnapInInfo ImportPSSnapIn(PSSnapInInfo psSnapInInfo, out PSSnapInException warning) { // See if the snapin is already loaded. If has been then there will be an entry in the @@ -4718,32 +4749,6 @@ End /// private static string ImportSystemModulesText = @""; - /// - /// This is the default function to use for clear-host. On Windows it rewrites the - /// host, and on Linux, it delegates to the native binary, 'clear'. - /// - internal static string GetClearHostFunctionText() - { - if (Platform.IsWindows()) - { - return @" -$RawUI = $Host.UI.RawUI -$RawUI.CursorPosition = @{X=0;Y=0} -$RawUI.SetBufferContents( - @{Top = -1; Bottom = -1; Right = -1; Left = -1}, - @{Character = ' '; ForegroundColor = $rawui.ForegroundColor; BackgroundColor = $rawui.BackgroundColor}) -# .Link -# http://go.microsoft.com/fwlink/?LinkID=225747 -# .ExternalHelp System.Management.Automation.dll-help.xml -"; - } - else - { - // Porting note: non-Windows platforms use `clear` - return "& (Get-Command -CommandType Application clear).Definition | Select-Object -First 1"; - } - } - /// /// This is the default function to use for man/help. It uses /// splatting to pass in the parameters. @@ -5437,18 +5442,28 @@ end # .Link # http://go.microsoft.com/fwlink/?LinkID=225750 # .ExternalHelp System.Management.Automation.dll-help.xml +"; + + internal const string DefaultClearHostFunctionText = @" +$RawUI = $Host.UI.RawUI +$RawUI.CursorPosition = @{X=0;Y=0} +$RawUI.SetBufferContents( + @{Top = -1; Bottom = -1; Right = -1; Left = -1}, + @{Character = ' '; ForegroundColor = $rawui.ForegroundColor; BackgroundColor = $rawui.BackgroundColor}) +# .Link +# http://go.microsoft.com/fwlink/?LinkID=225747 +# .ExternalHelp System.Management.Automation.dll-help.xml "; internal const string DefaultMoreFunctionText = @" param([string[]]$paths) $OutputEncoding = [System.Console]::OutputEncoding -$moreCommand = (Get-Command -CommandType Application more).Definition | Select-Object -First 1 if($paths) { foreach ($file in $paths) { - Get-Content $file | & $moreCommand + Get-Content $file | more.com } -} else { $input | & $moreCommand } +} else { $input | more.com } "; internal const string DefaultSetDriveFunctionText = "Set-Location $MyInvocation.MyCommand.Name"; @@ -5457,9 +5472,10 @@ if($paths) { internal static SessionStateFunctionEntry[] BuiltInFunctions = new SessionStateFunctionEntry[] { // Functions. Only the name and definitions are used + SessionStateFunctionEntry.GetDelayParsedFunctionEntry("prompt", DefaultPromptFunctionText), SessionStateFunctionEntry.GetDelayParsedFunctionEntry("TabExpansion2", TabExpansionFunctionText), - SessionStateFunctionEntry.GetDelayParsedFunctionEntry("Clear-Host", GetClearHostFunctionText()), + SessionStateFunctionEntry.GetDelayParsedFunctionEntry("Clear-Host", DefaultClearHostFunctionText), SessionStateFunctionEntry.GetDelayParsedFunctionEntry("more", DefaultMoreFunctionText), SessionStateFunctionEntry.GetDelayParsedFunctionEntry("help", GetHelpPagingFunctionText()), SessionStateFunctionEntry.GetDelayParsedFunctionEntry("mkdir", GetMkdirFunctionText()), @@ -5620,8 +5636,7 @@ if($paths) { try { - // WARNING: DUPLICATE CODE see RunspaceConfigForSingleShell - assembly = ClrFacade.Load(new AssemblyName(psSnapInInfo.AssemblyName)); + assembly = Assembly.Load(new AssemblyName(psSnapInInfo.AssemblyName)); } catch (BadImageFormatException e) { @@ -5644,12 +5659,7 @@ if($paths) { try { AssemblyName assemblyName = ClrFacade.GetAssemblyName(psSnapInInfo.AbsoluteModulePath); - - // Porting note: the snapins still require 'ProcessorArchitecture=MSIL' in - // the strong name, which is not in the strong name of assemblies created - // by dotnet-cli - if (!Platform.IsX() && - !string.Equals(assemblyName.FullName, psSnapInInfo.AssemblyName, StringComparison.OrdinalIgnoreCase)) + if (!string.Equals(assemblyName.FullName, psSnapInInfo.AssemblyName, StringComparison.OrdinalIgnoreCase)) { string message = StringUtil.Format(ConsoleInfoErrorStrings.PSSnapInAssemblyNameMismatch, psSnapInInfo.AbsoluteModulePath, psSnapInInfo.AssemblyName); _PSSnapInTracer.TraceError(message); diff --git a/src/System.Management.Automation/engine/LanguagePrimitives.cs b/src/System.Management.Automation/engine/LanguagePrimitives.cs index dcb967760..4aaa79022 100644 --- a/src/System.Management.Automation/engine/LanguagePrimitives.cs +++ b/src/System.Management.Automation/engine/LanguagePrimitives.cs @@ -481,13 +481,10 @@ namespace System.Management.Automation return null; } -#if !CORECLR - // .NET Core does not have a full DataTable type static IEnumerable DataTableEnumerable(object obj) { return (((DataTable)obj).Rows); } -#endif static IEnumerable TypicalEnumerable(object obj) { @@ -525,13 +522,10 @@ namespace System.Management.Automation static GetEnumerableDelegate CalculateGetEnumerable(Type objectType) { -#if !CORECLR - // .NET Core does not have a full DataTable type if (typeof(DataTable).IsAssignableFrom(objectType)) { return LanguagePrimitives.DataTableEnumerable; } -#endif // Don't treat IDictionary or XmlNode as enumerable... if (typeof(IEnumerable).IsAssignableFrom(objectType) diff --git a/src/System.Management.Automation/engine/ManagementObjectAdapter.cs b/src/System.Management.Automation/engine/ManagementObjectAdapter.cs index 5b24ac797..7f4284b54 100644 --- a/src/System.Management.Automation/engine/ManagementObjectAdapter.cs +++ b/src/System.Management.Automation/engine/ManagementObjectAdapter.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -1249,5 +1248,3 @@ namespace System.Management.Automation } } } - -#endif diff --git a/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs b/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs index ca0afb099..727b56ea9 100644 --- a/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs +++ b/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs @@ -531,9 +531,7 @@ namespace System.Management.Automation } /// - /// Gets the personal module path - /// (i.e. C:\Users\lukasza\Documents\WindowsPowerShell\modules, or - /// ~/.powershell/Modules on Linux) + /// Gets the personal module path (i.e. C:\Users\lukasza\Documents\WindowsPowerShell\modules) /// /// personal module path internal static string GetPersonalModulePath() @@ -580,12 +578,7 @@ namespace System.Management.Automation // Because of this, the module that is getting loaded during startup (through LocalRunspace) // is using "SysWow64" in the key. Later, when Import-Module is called, it loads the // module using ""System32" in the key. - - // Porting note: psHome cannot be lower-cased on case sensitive file systems - if (Platform.IsWindows()) - { - psHome = psHome.ToLowerInvariant().Replace("\\syswow64\\", "\\system32\\"); - } + psHome = psHome.ToLowerInvariant().Replace("\\syswow64\\", "\\system32\\"); Interlocked.CompareExchange(ref SystemWideModulePath, Path.Combine(psHome, Utils.ModuleDirectory), null); } @@ -600,11 +593,6 @@ namespace System.Management.Automation /// internal static string GetDscModulePath() { - if (!Platform.IsWindows()) - { - return string.Empty; - } - string dscModulePath = null; string programFilesPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); if (!string.IsNullOrEmpty(programFilesPath)) @@ -738,7 +726,7 @@ namespace System.Management.Automation if (currentProcessModulePath == null) // EVT.Process does Not exist - really corner case { // Handle the default case... - if (String.IsNullOrEmpty(hkcuUserModulePath)) // EVT.User does Not exist -> set to location + if (hkcuUserModulePath == null) // EVT.User does Not exist -> set to location { currentProcessModulePath = GetPersonalModulePath(); // = SpecialFolder.MyDocuments + Utils.ProductNameForDirectory + Utils.ModuleDirectory } @@ -748,7 +736,7 @@ namespace System.Management.Automation } currentProcessModulePath += ';'; - if (String.IsNullOrEmpty(hklmMachineModulePath)) // EVT.Machine does Not exist + if (hklmMachineModulePath == null) // EVT.Machine does Not exist { currentProcessModulePath += CombineSystemModulePaths(); // += (DscModulePath + $PSHome\Modules) } @@ -761,13 +749,6 @@ namespace System.Management.Automation { // Now handle the case where the environment variable is already set. - // Porting note: Open PowerShell has a Modules folder in the the application base path which contains the built-in modules - // It must be in the front of the path no matter what. - if (Platform.IsX()) - { - currentProcessModulePath = AddToPath(currentProcessModulePath, GetSystemwideModulePath(), 0); - } - // If there is no personal path key, then if the env variable doesn't match the system variable, // the user modified it somewhere, else prepend the default personel module path if (hklmMachineModulePath != null) // EVT.Machine exists @@ -877,11 +858,11 @@ namespace System.Management.Automation string newModulePathString = GetModulePath(currentModulePath, systemWideModulePath, personalModulePath); - if(!string.IsNullOrEmpty(newModulePathString)) - { - // Set the environment variable... + if(!string.IsNullOrEmpty(newModulePathString)) + { + // Set the environment variable... Environment.SetEnvironmentVariable("PSMODULEPATH", newModulePathString); - } + } return newModulePathString; } @@ -966,8 +947,7 @@ namespace System.Management.Automation catch (NotSupportedException) { // silently skip invalid path - // NotSupportedException is thrown if path contains a colon (":") that is not part of a - // volume identifier (for example, "c:\" is Supported but not "c:\temp\Z:\invalidPath") + // NotSupportedException is thrown if path contains a colon (":") that is not part of a volume identifier (for example, "c:\" is Supported but not "c:\temp\Z:\invalidPath") } if (provider != null && resolvedPaths != null && provider.NameEquals(context.ProviderNames.FileSystem)) diff --git a/src/System.Management.Automation/engine/MshObjectTypeDescriptor.cs b/src/System.Management.Automation/engine/MshObjectTypeDescriptor.cs index 9ee08e260..4415995ee 100644 --- a/src/System.Management.Automation/engine/MshObjectTypeDescriptor.cs +++ b/src/System.Management.Automation/engine/MshObjectTypeDescriptor.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -777,5 +776,3 @@ namespace System.Management.Automation } - -#endif diff --git a/src/System.Management.Automation/engine/NativeCommandParameterBinder.cs b/src/System.Management.Automation/engine/NativeCommandParameterBinder.cs index b9636c6a0..067a55caf 100644 --- a/src/System.Management.Automation/engine/NativeCommandParameterBinder.cs +++ b/src/System.Management.Automation/engine/NativeCommandParameterBinder.cs @@ -131,7 +131,7 @@ namespace System.Management.Automation { var rawArgs = arguments.ToString(); - if (tracer.IsEnabled && Platform.IsWindows()) + if (tracer.IsEnabled) { // This tracing really shouldn't be in the property getter... tracer.WriteLine("Raw argument string: {0}", rawArgs); diff --git a/src/System.Management.Automation/engine/NativeCommandProcessor.cs b/src/System.Management.Automation/engine/NativeCommandProcessor.cs index 9fc15982d..a2385aac0 100644 --- a/src/System.Management.Automation/engine/NativeCommandProcessor.cs +++ b/src/System.Management.Automation/engine/NativeCommandProcessor.cs @@ -1024,10 +1024,8 @@ namespace System.Management.Automation ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = this.Path; - // On Windows, check the extension list and see if we should try to execute this directly. - // Otherwise, use the platform library to check executability - if ((Platform.IsWindows() && ValidateExtension(this.Path)) - || (!Platform.IsWindows() && Platform.NonWindowsIsExecutable(this.Path))) + // Check the extension list and see if we should try to execute this directly. + if (ValidateExtension(this.Path)) { startInfo.UseShellExecute = false; if (redirectInput) diff --git a/src/System.Management.Automation/engine/PSMI/PSNegotiationData.cs b/src/System.Management.Automation/engine/PSMI/PSNegotiationData.cs index b5058a6ae..23899138e 100644 --- a/src/System.Management.Automation/engine/PSMI/PSNegotiationData.cs +++ b/src/System.Management.Automation/engine/PSMI/PSNegotiationData.cs @@ -1,5 +1,4 @@ -#if !CORECLR -using System.Collections.Generic; +using System.Collections.Generic; using System.Runtime.InteropServices; using Microsoft.Management.Infrastructure; @@ -25,5 +24,4 @@ namespace System.Management.Automation return c; } } -} -#endif +} \ No newline at end of file diff --git a/src/System.Management.Automation/engine/PSMI/PSPowerShellPipeline.cs b/src/System.Management.Automation/engine/PSMI/PSPowerShellPipeline.cs index 8194fd372..21b8a12f3 100644 --- a/src/System.Management.Automation/engine/PSMI/PSPowerShellPipeline.cs +++ b/src/System.Management.Automation/engine/PSMI/PSPowerShellPipeline.cs @@ -1,5 +1,4 @@ -#if !CORECLR -using System.Collections.Generic; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -60,5 +59,4 @@ namespace System.Management.Automation [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] internal IntPtr Value; } -} -#endif +} \ No newline at end of file diff --git a/src/System.Management.Automation/engine/PSMI/Serialization/InternalMISerializer.cs b/src/System.Management.Automation/engine/PSMI/Serialization/InternalMISerializer.cs index 8d9919e1f..8d35a9838 100644 --- a/src/System.Management.Automation/engine/PSMI/Serialization/InternalMISerializer.cs +++ b/src/System.Management.Automation/engine/PSMI/Serialization/InternalMISerializer.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -908,5 +907,4 @@ namespace System.Management.Automation #endregion } -} -#endif +} \ No newline at end of file diff --git a/src/System.Management.Automation/engine/PSMI/Serialization/KnownMITypes.cs b/src/System.Management.Automation/engine/PSMI/Serialization/KnownMITypes.cs index 50b9ea2f0..7f1401d4f 100644 --- a/src/System.Management.Automation/engine/PSMI/Serialization/KnownMITypes.cs +++ b/src/System.Management.Automation/engine/PSMI/Serialization/KnownMITypes.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -160,5 +159,4 @@ namespace System.Management.Automation #endregion private_fields } -} -#endif +} \ No newline at end of file diff --git a/src/System.Management.Automation/engine/PSMI/Serialization/MISerializer.cs b/src/System.Management.Automation/engine/PSMI/Serialization/MISerializer.cs index 110ade4f3..5b954fd2f 100644 --- a/src/System.Management.Automation/engine/PSMI/Serialization/MISerializer.cs +++ b/src/System.Management.Automation/engine/PSMI/Serialization/MISerializer.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -41,5 +40,4 @@ namespace System.Management.Automation return internalSerializer.Serialize(source); } } -} -#endif +} \ No newline at end of file diff --git a/src/System.Management.Automation/engine/PSMI/Serialization/MITypeSerializationInfo.cs b/src/System.Management.Automation/engine/PSMI/Serialization/MITypeSerializationInfo.cs index 5d1a460d5..b80fa6e09 100644 --- a/src/System.Management.Automation/engine/PSMI/Serialization/MITypeSerializationInfo.cs +++ b/src/System.Management.Automation/engine/PSMI/Serialization/MITypeSerializationInfo.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -128,5 +127,4 @@ namespace System.Management.Automation #endregion private } -} -#endif +} \ No newline at end of file diff --git a/src/System.Management.Automation/engine/PSMI/Serialization/PSMISerializer.cs b/src/System.Management.Automation/engine/PSMI/Serialization/PSMISerializer.cs index d8c0be05a..48c21674f 100644 --- a/src/System.Management.Automation/engine/PSMI/Serialization/PSMISerializer.cs +++ b/src/System.Management.Automation/engine/PSMI/Serialization/PSMISerializer.cs @@ -1,5 +1,4 @@ -#if !CORECLR -using System.IO; +using System.IO; using System.Linq; using System.Management.Automation.Internal; using System.Management.Automation.Language; @@ -56,5 +55,4 @@ namespace System.Management.Automation return serializer.Serialize(source); } } -} -#endif +} \ No newline at end of file diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index d8c8f9b2a..619b7f2d4 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -76,7 +76,7 @@ namespace System.Management.Automation static internal Version GetBuildVersion() { - string assemblyPath = typeof(PSVersionInfo).GetTypeInfo().Assembly.Location; + string assemblyPath = ClrFacade.GetAssemblyLocation(typeof(PSVersionInfo).GetTypeInfo().Assembly); string buildVersion = FileVersionInfo.GetVersionInfo(assemblyPath).FileVersion; return new Version(buildVersion); } @@ -86,11 +86,6 @@ namespace System.Management.Automation // Gets the current WSMan stack version from the registry. private static Version GetWSManStackVersion() { - if (!Platform.HasRegistrySupport()) - { - return new Version(1, 0); - } - Version version = null; try diff --git a/src/System.Management.Automation/engine/SecurityManagerBase.cs b/src/System.Management.Automation/engine/SecurityManagerBase.cs index 8d89b859b..0f594a7ff 100644 --- a/src/System.Management.Automation/engine/SecurityManagerBase.cs +++ b/src/System.Management.Automation/engine/SecurityManagerBase.cs @@ -87,15 +87,6 @@ namespace System.Management.Automation CommandOrigin origin, PSHost host) { - // TODO:PSL this is a workaround since the exception below - // hides the internal issue of what's going on in terms of - // execution policy. - if (Platform.IsX()) - { - return; - } - - #if DEBUG // If we are debugging, let the unit tests swap the file from beneath us if(commandInfo.CommandType == CommandTypes.ExternalScript) diff --git a/src/System.Management.Automation/engine/SessionStateDriveAPIs.cs b/src/System.Management.Automation/engine/SessionStateDriveAPIs.cs index d7e0f8e38..f25090481 100644 --- a/src/System.Management.Automation/engine/SessionStateDriveAPIs.cs +++ b/src/System.Management.Automation/engine/SessionStateDriveAPIs.cs @@ -1469,8 +1469,7 @@ namespace System.Management.Automation bool driveIsValid = true; // If the drive is auto-mounted, ensure that it still exists, or remove the drive. - // note: not all platforms support drive auto-mounting - if (Platform.HasDriveAutoMounting() && (drive.IsAutoMounted || IsAStaleVhdMountedDrive(drive))) + if (drive.IsAutoMounted || IsAStaleVhdMountedDrive(drive)) { driveIsValid = ValidateOrRemoveAutoMountedDrive(drive, lookupScope); } diff --git a/src/System.Management.Automation/engine/SessionStateNavigation.cs b/src/System.Management.Automation/engine/SessionStateNavigation.cs index c6a51d0f5..78ea6401c 100644 --- a/src/System.Management.Automation/engine/SessionStateNavigation.cs +++ b/src/System.Management.Automation/engine/SessionStateNavigation.cs @@ -197,13 +197,13 @@ namespace System.Management.Automation bool isProviderQualified = false; bool isDriveQualified = false; string qualifier = null; - string pathNoQualifier = RemoveQualifier(path, provider, out qualifier, out isProviderQualified, out isDriveQualified); + string pathNoQualifier = RemoveQualifier(path, out qualifier, out isProviderQualified, out isDriveQualified); string result = GetParentPath(provider, pathNoQualifier, root, context); if (!String.IsNullOrEmpty(qualifier) && !String.IsNullOrEmpty(result)) { - result = AddQualifier(result, provider, qualifier, isProviderQualified, isDriveQualified); + result = AddQualifier(result, qualifier, isProviderQualified, isDriveQualified); } return result; @@ -214,7 +214,7 @@ namespace System.Management.Automation } } // GetParentPath - private string AddQualifier(string path, ProviderInfo provider, string qualifier, bool isProviderQualified, bool isDriveQualified) + private string AddQualifier(string path, string qualifier, bool isProviderQualified, bool isDriveQualified) { string result = path; @@ -225,15 +225,7 @@ namespace System.Management.Automation } else if (isDriveQualified) { - // Porting note: on non-windows filesystem paths, there should be no colon in the path - if (provider.VolumeSeparatedByColon) - { - formatString = "{0}:{1}"; - } - else - { - formatString = "{0}{1}"; - } + formatString = "{0}:{1}"; } result = @@ -254,10 +246,6 @@ namespace System.Management.Automation /// The path to strip the provider qualifier from. /// /// - /// - /// The provider that should handle the RemoveQualifier call. - /// - /// /// /// Returns the qualifier of the path. /// @@ -274,7 +262,7 @@ namespace System.Management.Automation /// The path without the qualifier. /// /// - private string RemoveQualifier(string path, ProviderInfo provider, out string qualifier, out bool isProviderQualified, out bool isDriveQualified) + private string RemoveQualifier(string path, out string qualifier, out bool isProviderQualified, out bool isDriveQualified) { Dbg.Diagnostics.Assert( path != null, @@ -303,17 +291,9 @@ namespace System.Management.Automation { isDriveQualified = true; - // Remove the drive name and colon, or just the drive name + // Remove the drive name and colon - // Porting note: on non-windows there is no colon for qualified paths - if (provider.VolumeSeparatedByColon) - { - result = path.Substring(qualifier.Length + 1); - } - else - { - result = path.Substring(qualifier.Length); - } + result = path.Substring(qualifier.Length + 1); } } diff --git a/src/System.Management.Automation/engine/SessionStateStrings.cs b/src/System.Management.Automation/engine/SessionStateStrings.cs index e932264be..8f6bd46fd 100644 --- a/src/System.Management.Automation/engine/SessionStateStrings.cs +++ b/src/System.Management.Automation/engine/SessionStateStrings.cs @@ -28,15 +28,15 @@ namespace System.Management.Automation /// The default path separator used by the base implementation of the providers. /// /// - internal static readonly char DefaultPathSeparator = System.IO.Path.DirectorySeparatorChar; - internal static readonly string DefaultPathSeparatorString = DefaultPathSeparator.ToString(); + internal const char DefaultPathSeparator = '\\'; + internal const string DefaultPathSeparatorString = "\\"; /// /// The alternate path separator used by the base implementation of the providers. /// /// - internal static readonly char AlternatePathSeparator = System.IO.Path.AltDirectorySeparatorChar; - internal static readonly string AlternatePathSeparatorString = AlternatePathSeparator.ToString(); + internal const char AlternatePathSeparator = '/'; + internal const string AlternatePathSeparatorString = "/"; /// /// The default path prefix for remote paths. This is to mimic diff --git a/src/System.Management.Automation/engine/TransactedString.cs b/src/System.Management.Automation/engine/TransactedString.cs index fd30e601d..ba4021e8e 100644 --- a/src/System.Management.Automation/engine/TransactedString.cs +++ b/src/System.Management.Automation/engine/TransactedString.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -206,5 +205,3 @@ namespace Microsoft.PowerShell.Commands.Management } } // namespace Microsoft.Test.Management.Automation - -#endif diff --git a/src/System.Management.Automation/engine/TransactionManager.cs b/src/System.Management.Automation/engine/TransactionManager.cs index 731175dc6..87288e653 100644 --- a/src/System.Management.Automation/engine/TransactionManager.cs +++ b/src/System.Management.Automation/engine/TransactionManager.cs @@ -1,4 +1,3 @@ -#if !CORECLR #pragma warning disable 1634, 1691 /********************************************************************++ @@ -762,5 +761,3 @@ namespace System.Management.Automation.Internal } - -#endif diff --git a/src/System.Management.Automation/engine/Utils.cs b/src/System.Management.Automation/engine/Utils.cs index d32c79f4d..3c5acaf1d 100644 --- a/src/System.Management.Automation/engine/Utils.cs +++ b/src/System.Management.Automation/engine/Utils.cs @@ -62,15 +62,6 @@ namespace System.Management.Automation return CombineHashCodes(CombineHashCodes(h1, h2, h3, h4), CombineHashCodes(h5, h6, h7, h8)); } - /// - /// IsWinPEHost indicates if the machine on which PowerShell is hosted is WinPE or not. - /// This is a helper variable used to kep track if the IsWinPE() helper method has - /// already checked for the WinPE specific registry key or not. - /// If the WinPE specific registry key has not yet been checked even - /// once then this variable will point to null. - /// - internal static bool? isWinPEHost = null; - /// /// The existence of the following registry confirms that the host machine is a WinPE /// HKLM\System\CurrentControlSet\Control\MiniNT @@ -205,7 +196,16 @@ namespace System.Management.Automation private static string _pshome = null; - internal static string GetApplicationBaseFromRegistry(string shellId) + /// + /// Gets the application base for current monad version + /// + /// + /// applicationbase path for current monad version installation + /// + /// + /// if caller doesn't have permission to read the key + /// + internal static string GetApplicationBase(string shellId) { bool wantPsHome = (object) shellId == (object) DefaultPowerShellShellID; if (wantPsHome && _pshome != null) @@ -226,30 +226,6 @@ namespace System.Management.Automation } } - return null; - } - - /// - /// Gets the application base for current monad version - /// - /// - /// applicationbase path for current monad version installation - /// - /// - /// if caller doesn't have permission to read the key - /// - internal static string GetApplicationBase(string shellId) - { - if (!Platform.IsX()) - { - // try to get the path from the registry first - string result = GetApplicationBaseFromRegistry(shellId); - if (result != null) - { - return result; - } - } - #if CORECLR // Use the location of SMA.dll as the application base // Assembly.GetEntryAssembly is not in CoreCLR. GAC is not in CoreCLR. Assembly assembly = typeof(PSObject).GetTypeInfo().Assembly; @@ -304,16 +280,7 @@ namespace System.Management.Automation } // And built-in modules - string progFileDir; - if (Platform.IsX()) - { - progFileDir = Path.Combine(appBase, "Modules"); - } - else - { - progFileDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "WindowsPowerShell", "Modules"); - } - + string progFileDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "WindowsPowerShell", "Modules"); if (!string.IsNullOrEmpty(progFileDir)) { baseDirectories.Add(Path.Combine(progFileDir, "PackageManagement")); @@ -368,59 +335,31 @@ namespace System.Management.Automation /// Checks if host machine is WinPE /// internal static bool IsWinPEHost() - { - if (Platform.HasRegistrySupport()) - { - return WinIsWinPEHost(); - } - else - { - return false; - } - } - - internal static bool WinIsWinPEHost() { RegistryKey winPEKey = null; - if (!isWinPEHost.HasValue) + try { - try - { - // The existence of the following registry confirms that the host machine is a WinPE - // HKLM\System\CurrentControlSet\Control\MiniNT - winPEKey = Registry.LocalMachine.OpenSubKey(WinPEIdentificationRegKey); + // The existence of the following registry confirms that the host machine is a WinPE + // HKLM\System\CurrentControlSet\Control\MiniNT + winPEKey = Registry.LocalMachine.OpenSubKey(WinPEIdentificationRegKey); - if (null != winPEKey) - { - isWinPEHost = true; - } - else - { - isWinPEHost = false; - } - } - catch (ArgumentException) { } - catch (SecurityException) { } - catch (ObjectDisposedException) { } - finally + return winPEKey != null; + } + catch (ArgumentException) { } + catch (SecurityException) { } + catch (ObjectDisposedException) { } + finally + { + if (winPEKey != null) { - if (winPEKey != null) - { - winPEKey.Dispose(); - } + winPEKey.Dispose(); } } - if (isWinPEHost.HasValue) - { - return (bool)isWinPEHost; - } - else - { - return false; - } - } + return false; + } + #region Versioning related methods @@ -606,8 +545,7 @@ namespace System.Management.Automation /// /// Profile uses this to control profile loading. /// - internal static string ProductNameForDirectory = - Platform.IsWindows() ? "WindowsPowerShell" : Platform.ProductNameForDirectory; + internal static string ProductNameForDirectory = "WindowsPowerShell"; /// /// The name of the subdirectory that contains packages. @@ -617,7 +555,7 @@ namespace System.Management.Automation /// /// The partial path to the DSC module directory /// - internal static string DscModuleDirectory = Path.Combine("WindowsPowerShell", "Modules"); + internal static string DscModuleDirectory = "WindowsPowerShell\\Modules"; internal static string GetRegistryConfigurationPrefix() { @@ -647,18 +585,8 @@ namespace System.Management.Automation return GetGroupPolicySetting(groupPolicyBase, settingName, preferenceOrder); } - // We use a static to avoid creating "extra garbage." - private static Dictionary _emptyDictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); - internal static Dictionary GetGroupPolicySetting(string groupPolicyBase, string settingName, RegistryKey[] preferenceOrder) { - if (!Platform.HasGroupPolicySupport()) - { - // Porting note: No group policy support means we have an empty set of - // policies. - return _emptyDictionary; - } - lock (cachedGroupPolicySettings) { // Return cached information, if we have it @@ -960,21 +888,10 @@ namespace System.Management.Automation internal static bool IsAdministrator() { - // Porting note: only Windows supports the - // SecurityPrincipal API of .net for now assume Linux - // users have no concept of "Administrator" for now and - // specifically do not map to a check for root user - if (Platform.IsWindows()) - { - System.Security.Principal.WindowsIdentity currentIdentity = System.Security.Principal.WindowsIdentity.GetCurrent(); - System.Security.Principal.WindowsPrincipal principal = new System.Security.Principal.WindowsPrincipal(currentIdentity); + System.Security.Principal.WindowsIdentity currentIdentity = System.Security.Principal.WindowsIdentity.GetCurrent(); + System.Security.Principal.WindowsPrincipal principal = new System.Security.Principal.WindowsPrincipal(currentIdentity); - return principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator); - } - else - { - return false; - } + return principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator); } internal static bool NativeItemExists(string path) @@ -985,38 +902,9 @@ namespace System.Management.Automation return NativeItemExists(path, out unusedIsDirectory, out unusedException); } + // This is done through P/Invoke since File.Exists and Directory.Exists pay 13% performance degradation + // through the CAS checks, and are terribly slow for network paths. internal static bool NativeItemExists(string path, out bool isDirectory, out Exception exception) - { - if (Platform.UseDotNetToQueryFileAttributes()) - { - // TODO:PSL replace by System.IO.File.GetAttributes - exception = null; - if (NativeDirectoryExists(path)) - { - isDirectory = true; - return true; - } - else if (NativeFileExists(path)) - { - isDirectory = false; - return true; - } - else - { - isDirectory = false; - return false; - } - } - else - { - // This is done through P/Invoke since File.Exists and Directory.Exists - // pay 13% performance degradation through the CAS checks, and are - // terribly slow for network paths. - return WinNativeItemExists(path,out isDirectory,out exception); - } - } - - internal static bool WinNativeItemExists(string path, out bool isDirectory, out Exception exception) { exception = null; @@ -1060,21 +948,9 @@ namespace System.Management.Automation return true; } + // This is done through P/Invoke since we pay 13% performance degradation + // through the CAS checks required by File.Exists and Directory.Exists internal static bool NativeFileExists(string path) - { - if (Platform.UseDotNetToQueryFileAttributes()) - { - return System.IO.File.Exists(path); - } - else - { - // This is done through P/Invoke since we pay 13% performance degradation - // through the CAS checks required by File.Exists and Directory.Exists - return WinNativeFileExists(path); - } - } - - internal static bool WinNativeFileExists(string path) { bool isDirectory; Exception ioException; @@ -1091,18 +967,6 @@ namespace System.Management.Automation // This is done through P/Invoke since we pay 13% performance degradation // through the CAS checks required by File.Exists and Directory.Exists internal static bool NativeDirectoryExists(string path) - { - if (Platform.UseDotNetToQueryFileAttributes()) - { - return System.IO.Directory.Exists(path); - } - else - { - return WinNativeDirectoryExists(path); - } - } - - internal static bool WinNativeDirectoryExists(string path) { bool isDirectory; Exception ioException; @@ -1117,31 +981,6 @@ namespace System.Management.Automation } internal static void NativeEnumerateDirectory(string directory, out List directories, out List files) - { - if (Platform.UseDotNetToQueryFileAttributes()) - { - IEnumerable fileEnum = System.IO.Directory.EnumerateFiles(directory); - IEnumerable dirEnum = System.IO.Directory.EnumerateDirectories(directory); - - files = new List(); - directories = new List(); - - foreach (string entry in fileEnum) - { - files.Add(directory + "/" + entry); - } - foreach (string entry in dirEnum) - { - directories.Add(directory + "/" + entry); - } - } - else - { - WinNativeEnumerateDirectory(directory, out directories, out files); - } - } - - internal static void WinNativeEnumerateDirectory(string directory, out List directories, out List files) { IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1); NativeMethods.WIN32_FIND_DATA findData; @@ -1206,10 +1045,6 @@ namespace System.Management.Automation internal static bool PathIsUnc(string path) { - if (!Platform.HasUNCSupport()) - { - return false; - } Uri uri; return !string.IsNullOrEmpty(path) && Uri.TryCreate(path, UriKind.Absolute, out uri) && uri.IsUnc; } @@ -1263,25 +1098,8 @@ namespace System.Management.Automation public static extern bool FindClose(IntPtr hFindFile); } - // Porting note: PublicKeyToken must be null if code signed - // assemblies aren't supported - private static string strongNamePublicKeyToken - { - get - { - if (Platform.UsesCodeSignedAssemblies()) - { - return "31bf3856ad364e35"; - } - else - { - return "null"; - } - } - } - internal static readonly string PowerShellAssemblyStrongNameFormat = - "{0}, Version=3.0.0.0, Culture=neutral, PublicKeyToken={1}"; + "{0}, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"; internal static readonly HashSet PowerShellAssemblies = new HashSet(StringComparer.OrdinalIgnoreCase) @@ -1338,8 +1156,7 @@ namespace System.Management.Automation if ((fixedName != null) && PowerShellAssemblies.Contains(fixedName)) { - return string.Format(CultureInfo.InvariantCulture, PowerShellAssemblyStrongNameFormat, - fixedName, strongNamePublicKeyToken); + return string.Format(CultureInfo.InvariantCulture, PowerShellAssemblyStrongNameFormat, fixedName); } } diff --git a/src/System.Management.Automation/engine/hostifaces/History.cs b/src/System.Management.Automation/engine/hostifaces/History.cs index dfeccead5..167381725 100644 --- a/src/System.Management.Automation/engine/hostifaces/History.cs +++ b/src/System.Management.Automation/engine/hostifaces/History.cs @@ -1212,11 +1212,38 @@ namespace Microsoft.PowerShell.Commands { ps.AddScript(commandToInvoke); - ps.AddCommand("out-default"); - ps.Commands.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output); + EventHandler debugAdded = delegate(Object sender, DataAddedEventArgs e) { DebugRecord record = (DebugRecord)((PSDataCollection)sender)[e.Index]; WriteDebug(record.Message); }; + EventHandler errorAdded = delegate(Object sender, DataAddedEventArgs e) { ErrorRecord record = (ErrorRecord)((PSDataCollection)sender)[e.Index]; WriteError(record); }; + EventHandler informationAdded = delegate(Object sender, DataAddedEventArgs e) { InformationRecord record = (InformationRecord)((PSDataCollection)sender)[e.Index]; WriteInformation(record); }; + EventHandler progressAdded = delegate(Object sender, DataAddedEventArgs e) { ProgressRecord record = (ProgressRecord)((PSDataCollection)sender)[e.Index]; WriteProgress(record); }; + EventHandler verboseAdded = delegate(Object sender, DataAddedEventArgs e) { VerboseRecord record = (VerboseRecord)((PSDataCollection)sender)[e.Index]; WriteVerbose(record.Message); }; + EventHandler warningAdded = delegate(Object sender, DataAddedEventArgs e) { WarningRecord record = (WarningRecord)((PSDataCollection)sender)[e.Index]; WriteWarning(record.Message); }; - ps.Invoke(); - pipeline.RemoveFromInvokeHistoryEntryList(entry); + ps.Streams.Debug.DataAdded += debugAdded; + ps.Streams.Error.DataAdded += errorAdded; + ps.Streams.Information.DataAdded += informationAdded; + ps.Streams.Progress.DataAdded += progressAdded; + ps.Streams.Verbose.DataAdded += verboseAdded; + ps.Streams.Warning.DataAdded += warningAdded; + + try + { + Collection results = ps.Invoke(); + if (results.Count > 0) + { + WriteObject(results, true); + } + pipeline.RemoveFromInvokeHistoryEntryList(entry); + } + finally + { + ps.Streams.Debug.DataAdded -= debugAdded; + ps.Streams.Error.DataAdded -= errorAdded; + ps.Streams.Information.DataAdded -= informationAdded; + ps.Streams.Progress.DataAdded -= progressAdded; + ps.Streams.Verbose.DataAdded -= verboseAdded; + ps.Streams.Warning.DataAdded -= warningAdded; + } } } diff --git a/src/System.Management.Automation/engine/hostifaces/NativeCultureResolver.cs b/src/System.Management.Automation/engine/hostifaces/NativeCultureResolver.cs index 1fea216fd..74b4f0519 100644 --- a/src/System.Management.Automation/engine/hostifaces/NativeCultureResolver.cs +++ b/src/System.Management.Automation/engine/hostifaces/NativeCultureResolver.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. @@ -495,5 +494,4 @@ namespace Microsoft.PowerShell #endregion } -} -#endif +} \ No newline at end of file diff --git a/src/System.Management.Automation/engine/hostifaces/RunspaceInvoke.cs b/src/System.Management.Automation/engine/hostifaces/RunspaceInvoke.cs index 1e4b2f2bf..f0d6d4c77 100644 --- a/src/System.Management.Automation/engine/hostifaces/RunspaceInvoke.cs +++ b/src/System.Management.Automation/engine/hostifaces/RunspaceInvoke.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -219,5 +218,3 @@ namespace System.Management.Automation - -#endif diff --git a/src/System.Management.Automation/engine/remoting/commands/remotingcommandutil.cs b/src/System.Management.Automation/engine/remoting/commands/remotingcommandutil.cs index 2f0fa35d5..5d0c392bb 100644 --- a/src/System.Management.Automation/engine/remoting/commands/remotingcommandutil.cs +++ b/src/System.Management.Automation/engine/remoting/commands/remotingcommandutil.cs @@ -46,6 +46,15 @@ namespace Microsoft.PowerShell.Commands /// internal static string WinPEIdentificationRegKey = @"System\CurrentControlSet\Control\MiniNT"; + /// + /// IsWinPEHost indicates if the machine on which PowerShell is hosted is WinPE or not. + /// This is a helper variable used to kep track if the IsWinPE() helper method has + /// already checked for the WinPE specific registry key or not. + /// If the WinPE specific registry key has not yet been checked even + /// once then this variable will point to null. + /// + internal static bool? isWinPEHost = null; + internal static bool HasRepeatingRunspaces(PSSession[] runspaceInfos) { if (runspaceInfos == null) @@ -96,15 +105,9 @@ namespace Microsoft.PowerShell.Commands /// internal static void CheckRemotingCmdletPrerequisites() { - //If the operating system (ie Linux) does not support the registry, simply return to avoid calls to the Windows registry. - if (!Platform.HasRegistrySupport()) - { - return; - } - bool notSupported = true; String WSManKeyPath = "Software\\Microsoft\\Windows\\CurrentVersion\\WSMAN\\"; - + CheckHostRemotingPrerequisites(); try @@ -157,6 +160,46 @@ namespace Microsoft.PowerShell.Commands } } + /// + /// IsWinPEHost is a helper method used to identify if the + /// PowerShell is hosted on a WinPE machine. + /// + internal static bool IsWinPEHost() + { + RegistryKey wsManKey = null; + + if (isWinPEHost == null) + { + try + { + // The existence of the following registry confirms that the host machine is a WinPE + // HKLM\System\CurrentControlSet\Control\MiniNT + wsManKey = Registry.LocalMachine.OpenSubKey(WinPEIdentificationRegKey); + + if (null != wsManKey) + { + isWinPEHost = true; + } + else + { + isWinPEHost = false; + } + } + catch (ArgumentException) { } + catch (System.Security.SecurityException) { } + catch (ObjectDisposedException) { } + finally + { + if (wsManKey != null) + { + wsManKey.Dispose(); + } + } + } + + return isWinPEHost== true? true: false; + } + /// /// Facilitates to check if remoting is supported on the host machine. /// PowerShell remoting is supported on all Windows SQU's except WinPE. @@ -170,7 +213,7 @@ namespace Microsoft.PowerShell.Commands { // A registry key indicates if the SKU is WINPE. If this turns out to be true, // then an InValidOperation exception is thrown. - bool isWinPEHost = Utils.IsWinPEHost(); + bool isWinPEHost = IsWinPEHost(); if (isWinPEHost) { // WSMan is not supported on this platform diff --git a/src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs b/src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs index 0c6aaa43e..659a47d0b 100644 --- a/src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs +++ b/src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs @@ -533,12 +533,8 @@ namespace System.Management.Automation.Remoting SyncObject = new object(); // All PowerShell instances will start with the named pipe - // and listner created and running. - if (Platform.IsWindows()) - { - IPCNamedPipeServerEnabled = true; - } - + // and listener created and running. + IPCNamedPipeServerEnabled = true; CreateIPCNamedPipeServerSingleton(); #if !CORECLR // There is only one AppDomain per application in CoreCLR, which would be the default CreateAppDomainUnloadHandler(); diff --git a/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs b/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs index 886483780..ec004948d 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs @@ -662,7 +662,7 @@ namespace System.Management.Automation.Remoting { try { - result = ClrFacade.Load(new AssemblyName(assemblyName)); + result = Assembly.Load(new AssemblyName(assemblyName)); } catch (FileLoadException e) { diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs index 4e0ac2d1e..2ee10a2a7 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs @@ -2301,11 +2301,7 @@ namespace System.Management.Automation.Remoting.Client #region DllImports ClientAPI -#if !LINUX internal const string WSManApiDll = @"WsmSvc.dll"; -#else - internal const string WSManApiDll = @"libpsrpomiprov"; -#endif /// /// This API is used to initialize the WinRM client; @@ -2545,7 +2541,6 @@ namespace System.Management.Automation.Remoting.Client IntPtr asyncCallback, [In, Out] ref IntPtr shellOperationHandle); - /// /// /// @@ -2904,8 +2899,7 @@ namespace System.Management.Automation.Remoting.Client int flags, int errorCode, [MarshalAs(UnmanagedType.LPWStr)] string extendedInformation); - - + internal enum WSManFlagReceive : int { /// @@ -2969,20 +2963,7 @@ namespace System.Management.Automation.Remoting.Client IntPtr requestDetails, int flags, IntPtr context); -#if LINUX - /// - /// Registers the shutdown callback. - /// - /// Specifies the resource URI, options, locale, shutdown flag, and handle for the request. - /// Callback to be executed on shutdown - /// - /// - [DllImport(WSManNativeApi.WSManApiDll, SetLastError = false, CharSet = CharSet.Unicode)] - internal static extern void WSManPluginRegisterShutdownCallback( - IntPtr requestDetails, - IntPtr shutdownCallback, - IntPtr shutdownContext); -#endif + #endregion } @@ -3018,11 +2999,6 @@ namespace System.Management.Automation.Remoting.Client IntPtr requestDetails, int flags, IntPtr context); - - void WSManPluginRegisterShutdownCallback( - IntPtr requestDetails, - IntPtr shutdownCallback, - IntPtr shutdownContext); } /// @@ -3065,15 +3041,5 @@ namespace System.Management.Automation.Remoting.Client { return WSManNativeApi.WSManPluginReportContext(requestDetails, flags, context); } - - void IWSManNativeApiFacade.WSManPluginRegisterShutdownCallback( - IntPtr requestDetails, - IntPtr shutdownCallback, - IntPtr shutdownContext) - { -#if LINUX - WSManNativeApi.WSManPluginRegisterShutdownCallback(requestDetails, shutdownCallback, shutdownContext); -#endif - } } } diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs index c9fdc61a2..35199fad2 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs @@ -170,14 +170,14 @@ namespace System.Management.Automation.Remoting #if !CORECLR // Register our remoting handler for crashes AppDomain currentDomain = AppDomain.CurrentDomain; - currentDomain.UnhandledException += + currentDomain.UnhandledException += new UnhandledExceptionEventHandler(WSManPluginInstance.UnhandledExceptionHandler); // Register our Watson handler for crash reports in server mode System.Management.Automation.WindowsErrorReporting.RegisterWindowsErrorReporting(true); #endif } - + #endregion /// @@ -278,20 +278,10 @@ namespace System.Management.Automation.Remoting try { PSSenderInfo senderInfo = GetPSSenderInfo(requestDetails.senderDetails); - + // inbound shell information is already verified by pwrshplugin.dll.. so no need // to verify here. - WSManPluginServerTransportManager serverTransportMgr; - - if (Platform.IsWindows()) - { - serverTransportMgr = new WSManPluginServerTransportManager(BaseTransportManager.DefaultFragmentSize, new PSRemotingCryptoHelperServer()); - } - - else - { - serverTransportMgr = new WSManPluginServerTransportManager(BaseTransportManager.DefaultFragmentSize, null); - } + WSManPluginServerTransportManager serverTransportMgr = new WSManPluginServerTransportManager(BaseTransportManager.DefaultFragmentSize, new PSRemotingCryptoHelperServer()); PSEtwLog.LogAnalyticInformational(PSEventId.ServerCreateRemoteSession, PSOpcode.Connect, PSTask.None, @@ -315,7 +305,7 @@ namespace System.Management.Automation.Remoting { ReportOperationComplete(requestDetails, WSManPluginErrorCodes.OutOfMemory); return; - } + } // Create a shell session wrapper to track and service future interacations. mgdShellSession = new WSManPluginShellSession(requestDetails, serverTransportMgr, remoteShellSession, context); @@ -381,53 +371,34 @@ namespace System.Management.Automation.Remoting } bool isRegisterWaitForSingleObjectSucceeded = true; - - //always synchronize calls to OperationComplete once notification handle is registered.. else duplicate OperationComplete calls are bound to happen - lock (mgdShellSession.shellSyncObject) - { + + //always synchronize calls to OperationComplete once notification handle is registered.. else duplicate OperationComplete calls are bound to happen + lock (mgdShellSession.shellSyncObject) + { mgdShellSession.registeredShutdownNotification = 1; // Wrap the provided handle so it can be passed to the registration function + SafeWaitHandle safeWaitHandle = new SafeWaitHandle(requestDetails.shutdownNotificationHandle, false); // Owned by WinRM EventWaitHandle eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset); - - if (Platform.IsWindows()) - { - SafeWaitHandle safeWaitHandle = new SafeWaitHandle(requestDetails.shutdownNotificationHandle, false); // Owned by WinRM - ClrFacade.SetSafeWaitHandle(eventWaitHandle, safeWaitHandle); - } - else - { - //On non-windows platforms the shutdown notification is done through a callback instead of a windows event handle. - //Register the callback and this will then signal the event. Note, the gch object is deleted in the shell shutdown - //notification that will always come in to shut down the operation. - - GCHandle gch = GCHandle.Alloc(eventWaitHandle); - IntPtr p = GCHandle.ToIntPtr(gch); - - wsmanPinvokeStatic.WSManPluginRegisterShutdownCallback( - requestDetails.unmanagedHandle, - WSManPluginManagedEntryWrapper.workerPtrs.UnmanagedStruct.wsManPluginShutdownCallbackNative, - p); - } - + ClrFacade.SetSafeWaitHandle(eventWaitHandle, safeWaitHandle); mgdShellSession.registeredShutDownWaitHandle = ThreadPool.RegisterWaitForSingleObject( - eventWaitHandle, - new WaitOrTimerCallback(WSManPluginManagedEntryWrapper.PSPluginOperationShutdownCallback), - context, - -1, // INFINITE - true); // TODO: Do I need to worry not being able to set missing WT_TRANSFER_IMPERSONATION? + eventWaitHandle, + new WaitOrTimerCallback(WSManPluginManagedEntryWrapper.PSPluginOperationShutdownCallback), + context, + -1, // INFINITE + true); // TODO: Do I need to worry not being able to set missing WT_TRANSFER_IMPERSONATION? if (null == mgdShellSession.registeredShutDownWaitHandle) { isRegisterWaitForSingleObjectSucceeded = false; } } - + if (!isRegisterWaitForSingleObjectSucceeded) { mgdShellSession.registeredShutdownNotification = 0; WSManPluginInstance.ReportWSManOperationComplete( - requestDetails, + requestDetails, WSManPluginErrorCodes.ShutdownRegistrationFailed); DeleteFromActiveShellSessions(requestDetails.unmanagedHandle); return; @@ -439,7 +410,6 @@ namespace System.Management.Automation.Remoting { mgdShellSession.SendOneItemToSessionHelper(convertedBase64, WSManPluginConstants.SupportedInputStream); } - } catch(System.Exception e) { @@ -470,12 +440,12 @@ namespace System.Management.Automation.Remoting /// internal void CloseShellOperation( WSManPluginOperationShutdownContext context) - { + { PSEtwLog.LogAnalyticInformational(PSEventId.ServerCloseOperation, PSOpcode.Disconnect, PSTask.None, PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic, - ((IntPtr)context.shellContext).ToString(), - ((IntPtr)context.commandContext).ToString(), + ((IntPtr)context.shellContext).ToString(), + ((IntPtr)context.commandContext).ToString(), context.isReceiveOperation.ToString()); WSManPluginShellSession mgdShellSession = GetFromActiveShellSessions(context.shellContext); diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginFacade.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginFacade.cs index cf55c288c..9e057da46 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginFacade.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginFacade.cs @@ -97,13 +97,6 @@ namespace System.Management.Automation.Remoting [MarshalAs(UnmanagedType.LPWStr)] string commandLine, IntPtr arguments); - /// - /// Delegate that is passed to native layer for callback on operation shutdown notifications - /// - /// IntPtr - delegate void WSMPluginOperationShutdownDelegate( - IntPtr shutdownContext); - /// /// /// @@ -178,27 +171,27 @@ namespace System.Management.Automation.Remoting bool timedOut); /// - /// + /// /// /// PVOID delegate void WSMShutdownPluginDelegate( IntPtr pluginContext); /// - /// + /// /// internal sealed class WSManPluginEntryDelegates : IDisposable { #region Private Members - // Holds the delegate pointers in a structure that has identical layout to the native structure. + // Holds the delegate pointers in a structure that has identical layout to the native structure. private WSManPluginEntryDelegatesInternal unmanagedStruct = new WSManPluginEntryDelegatesInternal(); internal WSManPluginEntryDelegatesInternal UnmanagedStruct { get { return unmanagedStruct; } } - // Flag: Has Dispose already been called? + // Flag: Has Dispose already been called? private bool disposed = false; /// @@ -213,7 +206,6 @@ namespace System.Management.Automation.Remoting private GCHandle pluginSignalGCHandle; private GCHandle pluginConnectGCHandle; private GCHandle shutdownPluginGCHandle; - private GCHandle WSMPluginOperationShutdownGCHandle; #endregion @@ -326,16 +318,10 @@ namespace System.Management.Automation.Remoting this.shutdownPluginGCHandle = GCHandle.Alloc(shutdownPlugin); unmanagedStruct.wsManPluginShutdownPluginCallbackNative = Marshal.GetFunctionPointerForDelegate(shutdownPlugin); } - if(!Platform.IsWindows()) - { - WSMPluginOperationShutdownDelegate pluginShutDownDelegate = new WSMPluginOperationShutdownDelegate(WSManPluginManagedEntryWrapper.WSManPSShutdown); - this.WSMPluginOperationShutdownGCHandle = GCHandle.Alloc(pluginShutDownDelegate); - unmanagedStruct.wsManPluginShutdownCallbackNative = Marshal.GetFunctionPointerForDelegate(pluginShutDownDelegate); - } } /// - /// + /// /// private void CleanUpDelegates() { @@ -351,10 +337,6 @@ namespace System.Management.Automation.Remoting this.pluginSignalGCHandle.Free(); this.pluginConnectGCHandle.Free(); this.shutdownPluginGCHandle.Free(); - if(!Platform.IsWindows()) - { - this.WSMPluginOperationShutdownGCHandle.Free(); - } } } @@ -414,18 +396,11 @@ namespace System.Management.Automation.Remoting internal IntPtr wsManPluginSignalCallbackNative; /// - /// WSManPluginConnectCallbackNative + /// WSManPluginConnectCallbackNative /// [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] internal IntPtr wsManPluginConnectCallbackNative; - - /// - /// WSManPluginCommandCallbackNative - /// - [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] - internal IntPtr wsManPluginShutdownCallbackNative; - - } + } } /// @@ -442,7 +417,7 @@ namespace System.Management.Automation.Remoting /// /// Immutable container that holds the delegates and their unmanaged pointers. /// - internal static WSManPluginEntryDelegates workerPtrs = new WSManPluginEntryDelegates(); + private static WSManPluginEntryDelegates workerPtrs = new WSManPluginEntryDelegates(); #region Managed Entry Points @@ -603,19 +578,6 @@ namespace System.Management.Automation.Remoting WSManPluginInstance.PerformWSManPluginCommand(pluginContext, requestDetails, flags, shellContext, commandLine, arguments); } - /// - /// Operation shutdown notification that was registered with the native layer for each of the shellCreate operations. - /// - /// IntPtr - public static void WSManPSShutdown( - IntPtr shutdownContext) - { - GCHandle gch = GCHandle.FromIntPtr(shutdownContext); - EventWaitHandle eventHandle = (EventWaitHandle) gch.Target; - eventHandle.Set(); - gch.Free(); - } - /// /// /// @@ -731,9 +693,9 @@ namespace System.Management.Automation.Remoting WSManPluginInstance.PerformWSManPluginSignal(pluginContext, requestDetails, flags, shellContext, commandContext, code); } - + /// - /// Callback used to register with thread pool to notify when a plugin operation shuts down. + /// Callback used to register with thread pool to notify when a plugin operation shutsdown. /// Conforms to: /// public delegate void WaitOrTimerCallback( Object state, bool timedOut ) /// @@ -754,7 +716,7 @@ namespace System.Management.Automation.Remoting WSManPluginInstance.PerformCloseOperation(context); } - + #endregion } diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs index b311c2f39..8a21e1adf 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs @@ -265,7 +265,7 @@ namespace System.Management.Automation.Remoting //RACE TO BE FIXED - As soon as this API is called, WinRM service will send CommandResponse back and Signal is expected anytime // If Signal comes and executes before registering the notification handle, cleanup will be messed result = WSManNativeApi.WSManPluginReportContext(creationRequestDetails.unmanagedHandle, 0, creationRequestDetails.unmanagedHandle); - if (Platform.IsWindows() && (WSManPluginConstants.ExitCodeSuccess == result)) + if (WSManPluginConstants.ExitCodeSuccess == result) { registeredShutdownNotification = 1; diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginTransportManager.cs index 9db15cbf3..757d774a5 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginTransportManager.cs @@ -332,24 +332,22 @@ namespace System.Management.Automation.Remoting isRequestPending = true; this.requestDetails = requestDetails; - if (Platform.IsWindows()) - { - // Wrap the provided handle so it can be passed to the registration function - SafeWaitHandle safeWaitHandle = new SafeWaitHandle(requestDetails.shutdownNotificationHandle, false); // Owned by WinRM - EventWaitHandle eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset); - ClrFacade.SetSafeWaitHandle(eventWaitHandle, safeWaitHandle); + // Wrap the provided handle so it can be passed to the registration function + SafeWaitHandle safeWaitHandle = new SafeWaitHandle(requestDetails.shutdownNotificationHandle, false); // Owned by WinRM + EventWaitHandle eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset); + ClrFacade.SetSafeWaitHandle(eventWaitHandle, safeWaitHandle); - this.registeredShutDownWaitHandle = ThreadPool.RegisterWaitForSingleObject( - eventWaitHandle, - new WaitOrTimerCallback(WSManPluginManagedEntryWrapper.PSPluginOperationShutdownCallback), - shutDownContext, - -1, // INFINITE - true); // TODO: Do I need to worry not being able to set missing WT_TRANSFER_IMPERSONATION? - if (null == this.registeredShutDownWaitHandle) - { - isRegisterWaitForSingleObjectSucceeded = false; - } + this.registeredShutDownWaitHandle = ThreadPool.RegisterWaitForSingleObject( + eventWaitHandle, + new WaitOrTimerCallback(WSManPluginManagedEntryWrapper.PSPluginOperationShutdownCallback), + shutDownContext, + -1, // INFINITE + true); // TODO: Do I need to worry not being able to set missing WT_TRANSFER_IMPERSONATION? + if (null == this.registeredShutDownWaitHandle) + { + isRegisterWaitForSingleObjectSucceeded = false; } + // release thread waiting to send data to the client. waitHandle.Set(); } diff --git a/src/System.Management.Automation/engine/remoting/server/ServerPowerShellDriver.cs b/src/System.Management.Automation/engine/remoting/server/ServerPowerShellDriver.cs index 692aeaf80..efc2c3658 100644 --- a/src/System.Management.Automation/engine/remoting/server/ServerPowerShellDriver.cs +++ b/src/System.Management.Automation/engine/remoting/server/ServerPowerShellDriver.cs @@ -336,24 +336,17 @@ namespace System.Management.Automation // Flow the impersonation policy to pipeline execution thread // only if the current thread is impersonated (Delegation is // also a kind of impersonation). - if (Platform.IsWindows()) + WindowsIdentity currentThreadIdentity = WindowsIdentity.GetCurrent(); + switch (currentThreadIdentity.ImpersonationLevel) { - WindowsIdentity currentThreadIdentity = WindowsIdentity.GetCurrent(); - switch (currentThreadIdentity.ImpersonationLevel) - { - case TokenImpersonationLevel.Impersonation: - case TokenImpersonationLevel.Delegation: - settings.FlowImpersonationPolicy = true; - break; - default: - settings.FlowImpersonationPolicy = false; - break; - } - } - else - { - settings.FlowImpersonationPolicy = false; + case TokenImpersonationLevel.Impersonation: + case TokenImpersonationLevel.Delegation: + settings.FlowImpersonationPolicy = true; + break; + default: + settings.FlowImpersonationPolicy = false; + break; } settings.AddToHistory = addToHistory; diff --git a/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs b/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs index d1e7d7c41..7f9a1e2ff 100644 --- a/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs +++ b/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs @@ -170,11 +170,8 @@ namespace System.Management.Automation.Remoting _senderInfo = senderInfo; _configProviderId = configurationProviderId; _initParameters = initializationParameters; - if (Platform.IsWindows()) - { - _cryptoHelper = (PSRemotingCryptoHelperServer)transportManager.CryptoHelper; - _cryptoHelper.Session = this; - } + _cryptoHelper = (PSRemotingCryptoHelperServer)transportManager.CryptoHelper; + _cryptoHelper.Session = this; _context = new ServerRemoteSessionContext(); _sessionDSHandler = new ServerRemoteSessionDSHandlerlImpl(this, transportManager); diff --git a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs index 9a9ef31e8..a8e84bc47 100644 --- a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs +++ b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs @@ -555,8 +555,6 @@ namespace System.Management.Automation.Language return (errorSuggestion ?? NullResult(target)).WriteToDebugLog(this); } -#if !CORECLR - // .NET Core does not have a full DataTable type if (targetValue is DataTable) { // Generate: @@ -583,7 +581,6 @@ namespace System.Management.Automation.Language target), GetRestrictions(target))).WriteToDebugLog(this); } -#endif if (IsComObject(targetValue)) { @@ -670,26 +667,12 @@ namespace System.Management.Automation.Language return (result == DynamicMetaObjectExtensions.FakeError) ? null : result; } - // This is to reduce the runtime overhead of the feature query - private static readonly TypeInfo ComObjectTypeInfo = GetComObjectType(); - - private static TypeInfo GetComObjectType() - { - if (Platform.HasCom()) - { - return typeof(object).GetTypeInfo().Assembly.GetType("System.__ComObject").GetTypeInfo(); - } - else - { - return null; - } - } + private static readonly TypeInfo ComObjectTypeInfo = typeof(object).GetTypeInfo().Assembly.GetType("System.__ComObject").GetTypeInfo(); internal static bool IsComObject(object obj) { - // Platform notes: We can't use System.Runtime.InteropServices.Marshal.IsComObject(obj) - // since it doesn't work in partial trust - return obj != null && ComObjectTypeInfo != null && ComObjectTypeInfo.IsAssignableFrom(obj.GetType().GetTypeInfo()); + // we can't use System.Runtime.InteropServices.Marshal.IsComObject(obj) since it doesn't work in partial trust + return obj != null && ComObjectTypeInfo.IsAssignableFrom(obj.GetType().GetTypeInfo()); } private static IEnumerator AutomationNullRule(CallSite site, object obj) diff --git a/src/System.Management.Automation/help/HelpSystem.cs b/src/System.Management.Automation/help/HelpSystem.cs index 84801679e..ca87f9c15 100644 --- a/src/System.Management.Automation/help/HelpSystem.cs +++ b/src/System.Management.Automation/help/HelpSystem.cs @@ -667,7 +667,7 @@ namespace System.Management.Automation } else { - providerAssembly = ClrFacade.Load(providerInfo.AssemblyName); + providerAssembly = Assembly.Load(providerInfo.AssemblyName); } try diff --git a/src/System.Management.Automation/logging/MshLog.cs b/src/System.Management.Automation/logging/MshLog.cs index e380c51a3..cd2c5c1f2 100644 --- a/src/System.Management.Automation/logging/MshLog.cs +++ b/src/System.Management.Automation/logging/MshLog.cs @@ -171,8 +171,6 @@ namespace System.Management.Automation } #endif Collection providers = new Collection(); - // Porting note: Linux does not support ETW -#if !NOETW && !LINUX try { #if !CORECLR //TODO:CORECLR EventLogLogProvider not handled yet @@ -197,7 +195,7 @@ namespace System.Management.Automation // when running as non-admin user. In that case, we will default // to dummy log. } -#endif + providers.Add(new DummyLogProvider()); return providers; } diff --git a/src/System.Management.Automation/logging/eventlog/EventLogLogProvider.cs b/src/System.Management.Automation/logging/eventlog/EventLogLogProvider.cs index 378a46741..ccd27ac50 100644 --- a/src/System.Management.Automation/logging/eventlog/EventLogLogProvider.cs +++ b/src/System.Management.Automation/logging/eventlog/EventLogLogProvider.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -41,7 +40,7 @@ namespace System.Management.Automation _eventLog = new EventLog(); _eventLog.Source = source; - _resourceManager = new ResourceManager("System.Management.Automation.resources.Logging", System.Reflection.Assembly.GetExecutingAssembly()); + _resourceManager = new ResourceManager("Logging", System.Reflection.Assembly.GetExecutingAssembly()); } internal string SetupEventSource(string shellId) @@ -691,5 +690,3 @@ namespace System.Management.Automation #endregion Event Message } } - -#endif diff --git a/src/System.Management.Automation/namespaces/FileSystemContentStream.cs b/src/System.Management.Automation/namespaces/FileSystemContentStream.cs index 15df54f65..97cf6ddb1 100644 --- a/src/System.Management.Automation/namespaces/FileSystemContentStream.cs +++ b/src/System.Management.Automation/namespaces/FileSystemContentStream.cs @@ -1192,10 +1192,8 @@ namespace Microsoft.PowerShell.Commands if (_singleByteCharSet != null) return (bool)_singleByteCharSet; - // Porting note: only UTF-8 is supported on Linux, which is not an SBCS - if ((_currentEncoding.Equals(_oemEncoding) || - _currentEncoding.Equals(_defaultAnsiEncoding)) - && !Platform.IsLinux()) + if (_currentEncoding.Equals(_oemEncoding) || + _currentEncoding.Equals(_defaultAnsiEncoding)) { NativeMethods.CPINFO cpInfo; if (NativeMethods.GetCPInfo((uint)_currentEncoding.CodePage, out cpInfo) && diff --git a/src/System.Management.Automation/namespaces/FileSystemProvider.cs b/src/System.Management.Automation/namespaces/FileSystemProvider.cs index 50bd189a0..91b6ccf54 100644 --- a/src/System.Management.Automation/namespaces/FileSystemProvider.cs +++ b/src/System.Management.Automation/namespaces/FileSystemProvider.cs @@ -405,7 +405,7 @@ namespace Microsoft.PowerShell.Commands } // -Persist switch parameter is supported only for Network paths. - if (drive.Persist && !PathIsNetworkPath(drive.Root)) + if (drive.Persist && !NativeMethods.PathIsNetworkPath(drive.Root)) { ErrorRecord er = new ErrorRecord(new NotSupportedException(FileSystemProviderStrings.PersistNotSupported), "DriveRootNotNetworkPath", ErrorCategory.InvalidArgument, drive); ThrowTerminatingError(er); @@ -488,19 +488,6 @@ namespace Microsoft.PowerShell.Commands /// /// The PSDrive infor that would be used to create a new PS drive. private void MapNetworkDrive(PSDriveInfo drive) - { - // Porting note: mapped network drives are only supported on Windows - if (Platform.IsWindows()) - { - WinMapNetworkDrive(drive); - } - else - { - throw new Platform.PlatformNotSupportedException(); - } - } - - private void WinMapNetworkDrive(PSDriveInfo drive) { if (drive != null && !string.IsNullOrEmpty(drive.Root)) { @@ -591,7 +578,7 @@ namespace Microsoft.PowerShell.Commands /// private bool IsNetworkMappedDrive(PSDriveInfo drive) { - bool shouldMapNetworkDrive = (drive != null && !string.IsNullOrEmpty(drive.Root) && PathIsNetworkPath(drive.Root)) && + bool shouldMapNetworkDrive = (drive != null && !string.IsNullOrEmpty(drive.Root) && NativeMethods.PathIsNetworkPath(drive.Root)) && (drive.Persist || (drive.Credential != null && !drive.Credential.Equals(PSCredential.Empty))); return shouldMapNetworkDrive; @@ -606,19 +593,6 @@ namespace Microsoft.PowerShell.Commands /// PSDrive info. /// protected override PSDriveInfo RemoveDrive(PSDriveInfo drive) - { - // if removing the drive is not supported, just return the drive - if (Platform.SupportsRemoveDrive()) - { - return WinRemoveDrive(drive); - } - else - { - return drive; - } - } - - private PSDriveInfo WinRemoveDrive(PSDriveInfo drive) { if (IsNetworkMappedDrive(drive)) { @@ -684,19 +658,6 @@ namespace Microsoft.PowerShell.Commands /// /// internal static string GetUNCForNetworkDrive(string driveName) - { - // Porting note: on systems that do not support UNC paths, the UNC equivalent is the path itself - if (Platform.HasUNCSupport()) - { - return WinGetUNCForNetworkDrive(driveName); - } - else - { - return driveName; - } - } - - private static string WinGetUNCForNetworkDrive(string driveName) { string uncPath = null; if (!string.IsNullOrEmpty(driveName) && driveName.Length == 1) @@ -746,18 +707,6 @@ namespace Microsoft.PowerShell.Commands /// /// internal static string GetSubstitutedPathForNetworkDosDevice(string driveName) - { - if (Platform.HasNetworkDriveSupport()) - { - return WinGetSubstitutedPathForNetworkDosDevice(driveName); - } - else - { - throw new Platform.PlatformNotSupportedException(); - } - } - - private static string WinGetSubstitutedPathForNetworkDosDevice(string driveName) { string associatedPath = null; if (!string.IsNullOrEmpty(driveName) && driveName.Length == 1) @@ -893,50 +842,39 @@ namespace Microsoft.PowerShell.Commands break; } - // cover everything by the try-catch block, because some of the - // DriveInfo properties may throw exceptions + string newDriveName = newDrive.Name.Substring(0, 1); + + string description = String.Empty; + string root = newDrive.Name; + string displayRoot = null; + + if (newDrive.DriveType == DriveType.Fixed) + { + try + { + description = newDrive.VolumeLabel; + } + // trying to read the volume label may cause an + // IOException or SecurityException. Just default + // to an empty description. + catch (IOException) + { + } + catch (System.Security.SecurityException) + { + } + catch (System.UnauthorizedAccessException) + { + } + } + + if (newDrive.DriveType == DriveType.Network) + { + displayRoot = GetRootPathForNetworkDriveOrDosDevice(newDrive); + } + try { - string newDriveName = newDrive.Name.Substring(0, 1); - - string description = String.Empty; - string root = newDrive.Name; - string displayRoot = null; - - if (newDrive.DriveType == DriveType.Fixed) - { - try - { - description = newDrive.VolumeLabel; - } - // trying to read the volume label may cause an - // IOException or SecurityException. Just default - // to an empty description. - catch (IOException) - { - } - catch (System.Security.SecurityException) - { - } - catch (System.UnauthorizedAccessException) - { - } - } - - if (newDrive.DriveType == DriveType.Network) - { - // Platform notes: This is important because certain mount - // points on non-Windows are enumerated as drives by .net, but - // 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 (!Platform.HasNetworkDriveSupport()) - { - continue; - } - displayRoot = GetRootPathForNetworkDriveOrDosDevice(newDrive); - } - if (newDrive.DriveType == DriveType.Fixed) { if (!newDrive.RootDirectory.Exists) @@ -947,27 +885,6 @@ namespace Microsoft.PowerShell.Commands root = newDrive.RootDirectory.FullName; } - // 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 - // is no : available to separate the filesystems from each other - if (Platform.HasSingleRootFilesystem() && root != "/") - continue; - - // Porting notes: On non-windows platforms .net can report two - // drives with the same root, make sure to only add one of those - bool skipDuplicate = false; - foreach (PSDriveInfo driveInfo in results) - { - if (driveInfo.Root == root) - { - skipDuplicate = true; - break; - } - } - if (skipDuplicate) - continue; - // Create a new VirtualDrive for each logical drive PSDriveInfo newPSDriveInfo = new PSDriveInfo( @@ -989,18 +906,9 @@ namespace Microsoft.PowerShell.Commands { newPSDriveInfo.IsAutoMounted = true; } - - // Porting notes: on the non-Windows platforms, the drive never - // uses : as a separator between drive and path - if (!Platform.IsWindows()) - { - newPSDriveInfo.VolumeSeparatedByColon = false; - } - results.Add(newPSDriveInfo); } - // If there are issues accessing properties of the DriveInfo, do - // not add the drive + // If we can't access the root itself, don't add the drive catch (IOException) { } @@ -1505,13 +1413,6 @@ namespace Microsoft.PowerShell.Commands { DirectoryInfo directory = new DirectoryInfo(path); - if (!Platform.IsWindows() && Platform.NonWindowsIsSymLink(directory)) - { - // For Linux, treat symlink to directories like a file - WriteItemObject(directory, path, false); - return; - } - // Enumerate the directory Dir(directory, recurse, depth, nameOnly, returnContainers); } @@ -1639,10 +1540,7 @@ namespace Microsoft.PowerShell.Commands // Write out the items foreach (IEnumerable childList in target) { - // On some systems, this is already sorted. For consistency, always sort again. - IEnumerable sortedChildList = childList.OrderBy(c => c.Name, StringComparer.CurrentCultureIgnoreCase); - - foreach(FileSystemInfo filesystemInfo in sortedChildList) + foreach(FileSystemInfo filesystemInfo in childList) { // Making sure to obey the StopProcessing. if (Stopping) @@ -1825,10 +1723,7 @@ namespace Microsoft.PowerShell.Commands mode[3] = (fileInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden ? 'h' : '-'; mode[4] = (fileInfo.Attributes & FileAttributes.System) == FileAttributes.System ? 's' : '-'; // Mark the last bit as a "l" if it's a reparsepoint (symbolic link or junction) - // Porting note: these need to be handled specially - bool isReparsePoint = InternalSymbolicLinkLinkCodeMethods.IsReparsePoint(fileInfo); - bool isHardLink = InternalSymbolicLinkLinkCodeMethods.IsHardLink(fileInfo); - mode[5] = isReparsePoint || isHardLink ? 'l' : '-'; + mode[5] = (fileInfo.Attributes & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint ? 'l' : '-'; return new string(mode); } @@ -2210,25 +2105,12 @@ namespace Microsoft.PowerShell.Commands if(itemType == ItemType.SymbolicLink) { - if (Platform.IsWindows()) - { - success = WinCreateSymbolicLink(path,strTargetPath,isDirectory); - } - else - { - success = Platform.NonWindowsCreateSymbolicLink(path,strTargetPath,isDirectory); - } + int created = NativeMethods.CreateSymbolicLink(path, strTargetPath, (isDirectory ? 1 : 0)); + success = (created == 1) ? true : false; } else if(itemType == ItemType.HardLink) { - if (Platform.IsWindows()) - { - success = WinCreateHardLink(path,strTargetPath); - } - else - { - success = Platform.NonWindowsCreateHardLink(path,strTargetPath); - } + success = NativeMethods.CreateHardLink(path, strTargetPath, IntPtr.Zero); } if (!success) @@ -2371,7 +2253,7 @@ namespace Microsoft.PowerShell.Commands try { - bool junctionCreated = WinCreateJunction(path, strTargetPath); + bool junctionCreated = InternalSymbolicLinkLinkCodeMethods.CreateJunction(path, strTargetPath); if (junctionCreated) { @@ -2417,25 +2299,6 @@ namespace Microsoft.PowerShell.Commands } } // NewItem - private static bool WinCreateSymbolicLink(string path, string strTargetPath, bool isDirectory) - { - int created = NativeMethods.CreateSymbolicLink(path, strTargetPath, (isDirectory ? 1 : 0)); - bool success = (created == 1) ? true : false; - return success; - } - - private static bool WinCreateHardLink(string path, string strTargetPath) - { - bool success = NativeMethods.CreateHardLink(path, strTargetPath, IntPtr.Zero); - return success; - } - - private static bool WinCreateJunction(string path, string strTargetPath) - { - bool junctionCreated = InternalSymbolicLinkLinkCodeMethods.CreateJunction(path, strTargetPath); - return junctionCreated; - } - /// /// Checks if the item exists and throws exception on access. /// @@ -4679,12 +4542,6 @@ namespace Microsoft.PowerShell.Commands { bool result = false; - // this needs to be done differently on single root filesystems - if (Platform.HasSingleRootFilesystem() && path.StartsWith("/")) - { - return true; - } - // Find the drive separator int index = path.IndexOf(':'); @@ -5149,18 +5006,15 @@ namespace Microsoft.PowerShell.Commands private string RemoveRelativeTokens(string path) { - string sep = System.IO.Path.DirectorySeparatorChar.ToString(); - string altSep = System.IO.Path.AltDirectorySeparatorChar.ToString(); - - string testPath = path.Replace(altSep,sep); + string testPath = path.Replace('/', '\\'); if ( - (testPath.IndexOf(sep, StringComparison.OrdinalIgnoreCase) < 0) || - testPath.StartsWith("." + sep, StringComparison.OrdinalIgnoreCase) || - testPath.StartsWith(".." + sep, StringComparison.OrdinalIgnoreCase) || - testPath.EndsWith(sep + ".", StringComparison.OrdinalIgnoreCase) || - testPath.EndsWith(sep + "..", StringComparison.OrdinalIgnoreCase) || - (testPath.IndexOf(sep + "." + sep, StringComparison.OrdinalIgnoreCase) > 0) || - (testPath.IndexOf(sep + ".." + sep, StringComparison.OrdinalIgnoreCase) > 0)) + (testPath.IndexOf("\\", StringComparison.OrdinalIgnoreCase) < 0) || + testPath.StartsWith(".\\", StringComparison.OrdinalIgnoreCase) || + testPath.StartsWith("..\\", StringComparison.OrdinalIgnoreCase) || + testPath.EndsWith("\\.", StringComparison.OrdinalIgnoreCase) || + testPath.EndsWith("\\..", StringComparison.OrdinalIgnoreCase) || + (testPath.IndexOf("\\.\\", StringComparison.OrdinalIgnoreCase) > 0) || + (testPath.IndexOf("\\..\\", StringComparison.OrdinalIgnoreCase) > 0)) { try { @@ -6875,52 +6729,6 @@ namespace Microsoft.PowerShell.Commands #endregion IContentCmdletProvider internal static int SafeGetFileAttributes(string path) - { - if (Platform.UseDotNetToQueryFileAttributes()) - { - System.IO.FileAttributes attr = System.IO.File.GetAttributes(path); - - int result = 0; - if ((attr & FileAttributes.Archive) == FileAttributes.Archive) - result |= 0x20; - if ((attr & FileAttributes.Compressed) == FileAttributes.Compressed) - result |= 0x800; - if ((attr & FileAttributes.Device) == FileAttributes.Device) - result |= 0x40; - if ((attr & FileAttributes.Directory) == FileAttributes.Directory) - result |= 0x10; - if ((attr & FileAttributes.Encrypted) == FileAttributes.Encrypted) - result |= 0x4000; - if ((attr & FileAttributes.Hidden) == FileAttributes.Hidden) - result |= 0x2; - if ((attr & FileAttributes.IntegrityStream) == FileAttributes.IntegrityStream) - result |= 0x8000; - if ((attr & FileAttributes.Normal) == FileAttributes.Normal) - result |= 0x80; - if ((attr & FileAttributes.NoScrubData) == FileAttributes.NoScrubData) - result |= 0x20000; - if ((attr & FileAttributes.NotContentIndexed) == FileAttributes.NotContentIndexed) - result |= 0x2000; - if ((attr & FileAttributes.Offline) == FileAttributes.Offline) - result |= 0x1000; - if ((attr & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) - result |= 0x1; - if ((attr & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint) - result |= 0x400; - if ((attr & FileAttributes.SparseFile) == FileAttributes.SparseFile) - result |= 0x200; - if ((attr & FileAttributes.System) == FileAttributes.System) - result |= 0x4; - if ((attr & FileAttributes.Temporary) == FileAttributes.Temporary) - result |= 0x100; - - return result; - } - else - return WinSafeGetFileAttributes(path); - } - - internal static int WinSafeGetFileAttributes(string path) { int result = Utils.NativeMethods.GetFileAttributes(path); if (result == -1) @@ -6971,26 +6779,6 @@ namespace Microsoft.PowerShell.Commands } } - /// - /// The API 'PathIsNetworkPath' is not available in CoreSystem. - /// This implementation is based on the 'PathIsNetworkPath' API. - /// - /// - /// - internal static bool PathIsNetworkPath(string path) - { - // no other logic possible for now on linux - if (Platform.HasNetworkDriveSupport()) - return WinPathIsNetworkPath(path); - else - return false; - } - - internal static bool WinPathIsNetworkPath(string path) - { - return NativeMethods.PathIsNetworkPath(path); // call the native method - } - static class NativeMethods { /// @@ -7981,17 +7769,15 @@ namespace Microsoft.PowerShell.Commands if (fileSysInfo != null) { - if (Platform.IsWindows()) + using (SafeFileHandle handle = OpenReparsePoint(fileSysInfo.FullName, FileDesiredAccess.GenericRead)) { - using (SafeFileHandle handle = OpenReparsePoint(fileSysInfo.FullName, FileDesiredAccess.GenericRead)) - { - string linkTarget = InternalGetTarget(handle); + string linkTarget = InternalGetTarget(handle); - if (linkTarget != null) - return (new string[] { linkTarget }); - } + if (linkTarget != null) + return (new string[] { linkTarget }); } + //return InternalGetTarget(fileSysInfo.FullName).ToArray(); return InternalGetTarget(fileSysInfo.FullName); } else @@ -8009,7 +7795,7 @@ namespace Microsoft.PowerShell.Commands if (fileSysInfo != null) { - return InternalGetLinkType(fileSysInfo); + return InternalGetLinkType(fileSysInfo.FullName); } else return null; @@ -8018,15 +7804,6 @@ namespace Microsoft.PowerShell.Commands private static List InternalGetTarget(string filePath) { var links = new List(); - if (!Platform.IsWindows()) - { - string link = Platform.NonWindowsInternalGetTarget(filePath); - if (!String.IsNullOrEmpty(link)) - { - links.Add(link); - } - return links; - } #if !CORECLR //FindFirstFileName, FindNextFileName and FindClose are not available on Core Clr UInt32 linkStringLength = 0; @@ -8090,26 +7867,9 @@ namespace Microsoft.PowerShell.Commands return links; } - private static string InternalGetLinkType(FileSystemInfo fileInfo) - { - if (Platform.IsWindows()) - { - return WinInternalGetLinkType(fileInfo.FullName); - } - else - { - return Platform.NonWindowsInternalGetLinkType(fileInfo); - } - } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods")] - private static string WinInternalGetLinkType(string filePath) + private static string InternalGetLinkType(string filePath) { - if (Platform.IsLinux()) - { - throw new Platform.PlatformNotSupportedException(); - } - using (SafeFileHandle handle = OpenReparsePoint(filePath, FileDesiredAccess.GenericRead)) { int outBufferSize = ClrFacade.SizeOf(); @@ -8167,75 +7927,8 @@ namespace Microsoft.PowerShell.Commands } } - internal static bool IsHardLink(FileSystemInfo fileInfo) - { - if (Platform.IsWindows()) - return WinIsHardLink(fileInfo); - else - return Platform.NonWindowsIsHardLink(fileInfo); - } - - internal static bool IsReparsePoint(FileSystemInfo fileInfo) - { - if (Platform.IsWindows()) - { - // Note that this class also has a enum called FileAttributes, so use fully qualified name - return (fileInfo.Attributes & System.IO.FileAttributes.ReparsePoint) - == System.IO.FileAttributes.ReparsePoint; - } - else - { - return Platform.NonWindowsIsSymLink(fileInfo); - } - } - - internal static bool WinIsHardLink(FileSystemInfo fileInfo) - { - bool isHardLink = false; - - // only check for hard link if the item is not directory - if (!((fileInfo.Attributes & System.IO.FileAttributes.Directory) == System.IO.FileAttributes.Directory)) - { - IntPtr nativeHandle = InternalSymbolicLinkLinkCodeMethods.CreateFile( - fileInfo.FullName, - InternalSymbolicLinkLinkCodeMethods.FileDesiredAccess.GenericRead, - InternalSymbolicLinkLinkCodeMethods.FileShareMode.Read, - IntPtr.Zero, - InternalSymbolicLinkLinkCodeMethods.FileCreationDisposition.OpenExisting, - InternalSymbolicLinkLinkCodeMethods.FileAttributes.Normal, - IntPtr.Zero); - - using (SafeFileHandle handle = new SafeFileHandle(nativeHandle, true)) - { - bool success = false; - - try - { - handle.DangerousAddRef(ref success); - IntPtr dangerousHandle = handle.DangerousGetHandle(); - isHardLink = InternalSymbolicLinkLinkCodeMethods.IsHardLink(ref dangerousHandle); - } - finally - { - if (success) - handle.DangerousRelease(); - } - } - } - - return isHardLink; - } - - internal static bool IsHardLink(ref IntPtr handle) - { - if (Platform.IsWindows()) - return WinIsHardLink(ref handle); - else - return Platform.NonWindowsIsHardLink(ref handle); - } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods")] - internal static bool WinIsHardLink(ref IntPtr handle) + internal static bool IsHardLink(ref IntPtr handle) { BY_HANDLE_FILE_INFORMATION handleInfo; bool succeeded = InternalSymbolicLinkLinkCodeMethods.GetFileInformationByHandle(handle, out handleInfo); @@ -8254,20 +7947,8 @@ namespace Microsoft.PowerShell.Commands return false; } - private static string InternalGetTarget(SafeFileHandle handle) - { - if (Platform.IsWindows()) - { - return WinInternalGetTarget(handle); - } - else - { - return Platform.NonWindowsInternalGetTarget(handle); - } - } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods")] - private static string WinInternalGetTarget(SafeFileHandle handle) + private static string InternalGetTarget(SafeFileHandle handle) { int outBufferSize = ClrFacade.SizeOf(); @@ -8332,22 +8013,8 @@ namespace Microsoft.PowerShell.Commands } } - internal static bool CreateJunction(string path, string target) - { - // this is a purely Windows specific feature, no feature flag - // used for that reason - if (Platform.IsWindows()) - { - return WinCreateJunction(path,target); - } - else - { - return false; - } - } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods")] - private static bool WinCreateJunction(string path, string target) + internal static bool CreateJunction(string path, string target) { if (!String.IsNullOrEmpty(path)) { @@ -8420,20 +8087,6 @@ namespace Microsoft.PowerShell.Commands if (!String.IsNullOrEmpty(junctionPath)) { - if (!Platform.IsWindows()) - { - // For non-Windows platform, treat it as a file. Just delete it. - try - { - File.Delete(junctionPath); - return true; - } - catch - { - return false; - } - } - using (SafeHandle handle = OpenReparsePoint(junctionPath, FileDesiredAccess.GenericWrite)) { bool success = false; @@ -8485,18 +8138,6 @@ namespace Microsoft.PowerShell.Commands } private static SafeFileHandle OpenReparsePoint(string reparsePoint, FileDesiredAccess accessMode) - { - if (Platform.SupportsReparsePoints()) - { - return WinOpenReparsePoint(reparsePoint,accessMode); - } - else - { - throw new Platform.PlatformNotSupportedException(); - } - } - - private static SafeFileHandle WinOpenReparsePoint(string reparsePoint, FileDesiredAccess accessMode) { IntPtr nativeHandle = CreateFile(reparsePoint, accessMode, FileShareMode.Read | FileShareMode.Write | FileShareMode.Delete, diff --git a/src/System.Management.Automation/namespaces/LocationGlobber.cs b/src/System.Management.Automation/namespaces/LocationGlobber.cs index 4b5441c29..5e3ba3591 100644 --- a/src/System.Management.Automation/namespaces/LocationGlobber.cs +++ b/src/System.Management.Automation/namespaces/LocationGlobber.cs @@ -1607,9 +1607,7 @@ namespace System.Management.Automation break; } - // compare both to \ and / here - if (path.StartsWith(@".\", StringComparison.Ordinal) || - path.StartsWith(@"./", StringComparison.Ordinal)) + if (path.StartsWith(@".\", StringComparison.Ordinal)) { // The .\ prefix basically escapes anything that follows // so treat it as a relative path no matter what comes @@ -1619,16 +1617,6 @@ namespace System.Management.Automation break; } - // non-windows porting notes: - // this needs to be handled differently on non-windows, paths starting with / are always absolute - // -> still continue with other isAbsolute processing, colons can still happen in drives - // of other providers - if (Platform.HasSingleRootFilesystem() && path.StartsWith("/",StringComparison.Ordinal)) - { - result = true; - break; - } - int index = path.IndexOf(":", StringComparison.Ordinal); if (index == -1) @@ -1716,17 +1704,6 @@ namespace System.Management.Automation break; } - // non-windows porting notes: - // this needs to be handled differently on non-windows, paths starting with / are always absolute - // -> still continue with other isAbsolute processing, colons can still happen in drives - // of other providers - if (Platform.HasSingleRootFilesystem() && path.StartsWith("/",StringComparison.Ordinal)) - { - driveName = "/"; - result = true; - break; - } - int index = path.IndexOf(":", StringComparison.CurrentCulture); if (index == -1) @@ -2039,20 +2016,7 @@ namespace System.Management.Automation // Now hack off the drive component of the path if (!isPathForCurrentDrive) { - // This functionality needs to respect if a drive uses a colon to separate the path - // - // what happens here is this: - // - path is assumed to be drive root relative, so on Windows it would start with a - // \ - // - on Linux, there is no difference between drive root relative, and absolute, they - // are both the same, so we have to preserve the drive here in order to make - // sure the path will continue being drive root relative - if (workingDriveForPath.VolumeSeparatedByColon) - { - // this is the default behavior for all windows drives, and all non-filesystem - // drives on non-windows - path = path.Substring(driveName.Length + 1); - } + path = path.Substring(driveName.Length + 1); } } else @@ -2260,13 +2224,10 @@ namespace System.Management.Automation { // The root relative path was given so empty the current working path. - // Porting notes: This can happen on non-Windows, because the assumption - // is that for file paths a path that is already relative to the drive - // root is the same thing as an absolute path (both start with /). - driveRootRelativeWorkingPath = String.Empty; - // Remove the \ or / from the drive relative path + // Remove the \ or / from the drive relative + // path path = path.Substring(1); @@ -2442,41 +2403,18 @@ namespace System.Management.Automation private bool HasRelativePathTokens(string path) { - if (System.IO.Path.DirectorySeparatorChar == '/') - { - string comparePath = path; + string comparePath = path.Replace('/', '\\'); - // the next line will only replace something, if the directory separators - // are different on the platform - if (System.IO.Path.DirectorySeparatorChar != System.IO.Path.AltDirectorySeparatorChar) - comparePath = path.Replace(System.IO.Path.AltDirectorySeparatorChar,System.IO.Path.DirectorySeparatorChar); - - return ( - comparePath.Equals(".", StringComparison.OrdinalIgnoreCase) || - comparePath.Equals("..", StringComparison.OrdinalIgnoreCase) || - comparePath.Contains("/./") || - comparePath.Contains("/../") || - comparePath.EndsWith("/..", StringComparison.OrdinalIgnoreCase) || - comparePath.EndsWith("/.", StringComparison.OrdinalIgnoreCase) || - comparePath.StartsWith("../", StringComparison.OrdinalIgnoreCase) || - comparePath.StartsWith("./", StringComparison.OrdinalIgnoreCase) || - comparePath.StartsWith("~", StringComparison.OrdinalIgnoreCase)); - } - else - { - string comparePath = path.Replace('/', '\\'); - - return ( - comparePath.Equals(".", StringComparison.OrdinalIgnoreCase) || - comparePath.Equals("..", StringComparison.OrdinalIgnoreCase) || - comparePath.Contains("\\.\\") || - comparePath.Contains("\\..\\") || - comparePath.EndsWith("\\..", StringComparison.OrdinalIgnoreCase) || - comparePath.EndsWith("\\.", StringComparison.OrdinalIgnoreCase) || - comparePath.StartsWith("..\\", StringComparison.OrdinalIgnoreCase) || - comparePath.StartsWith(".\\", StringComparison.OrdinalIgnoreCase) || - comparePath.StartsWith("~", StringComparison.OrdinalIgnoreCase)); - } + return ( + comparePath.Equals(".", StringComparison.OrdinalIgnoreCase) || + comparePath.Equals("..", StringComparison.OrdinalIgnoreCase) || + comparePath.Contains("\\.\\") || + comparePath.Contains("\\..\\") || + comparePath.EndsWith("\\..", StringComparison.OrdinalIgnoreCase) || + comparePath.EndsWith("\\.", StringComparison.OrdinalIgnoreCase) || + comparePath.StartsWith("..\\", StringComparison.OrdinalIgnoreCase) || + comparePath.StartsWith(".\\", StringComparison.OrdinalIgnoreCase) || + comparePath.StartsWith("~", StringComparison.OrdinalIgnoreCase)); } /// @@ -3130,50 +3068,37 @@ namespace System.Management.Automation } else { - // Platform note: - // this needs to be done differently on non-windows platforms - string unescapedPath = context.SuppressWildcardExpansion ? path : RemoveGlobEscaping(path); - // this is the output of the platform specific code right below - string resolvedPath; + string formatString = "{0}:" + StringLiterals.DefaultPathSeparator + "{1}"; - if (drive.VolumeSeparatedByColon) + // Check to see if its a hidden provider drive. + if (drive.Hidden) { - string formatString = "{0}:" + StringLiterals.DefaultPathSeparator + "{1}"; - - // Check to see if its a hidden provider drive. - if (drive.Hidden) + if (IsProviderDirectPath(unescapedPath)) { - if (IsProviderDirectPath(unescapedPath)) - { - formatString = "{1}"; - } - else - { - formatString = "{0}::{1}"; - } + formatString = "{1}"; } else { - if (path.StartsWith(StringLiterals.DefaultPathSeparator.ToString(), StringComparison.Ordinal)) - { - formatString = "{0}:{1}"; - } + formatString = "{0}::{1}"; } - - resolvedPath = - String.Format( - System.Globalization.CultureInfo.InvariantCulture, - formatString, - drive.Name, - unescapedPath); } else { - resolvedPath = drive.Name + unescapedPath; + if (path.StartsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal)) + { + formatString = "{0}:{1}"; + } } + string resolvedPath = + String.Format( + System.Globalization.CultureInfo.InvariantCulture, + formatString, + drive.Name, + unescapedPath); + // Since we didn't do globbing, be sure the path exists if (allowNonexistingPaths || provider.ItemExists(GetProviderPath(resolvedPath, context), context)) @@ -3332,59 +3257,45 @@ namespace System.Management.Automation } string result = path; + bool treatAsRelative = true; - // platform notes: - // this needs to be implemented differently depending if the drive uses colon to separate paths - if (drive.VolumeSeparatedByColon) + // Ensure the drive name is the same as the portion of the path before + // :. If not add the drive name and colon as if it was a relative path + + int index = path.IndexOf(':'); + + if (index != -1) { - bool treatAsRelative = true; - - // Ensure the drive name is the same as the portion of the path before - // :. If not add the drive name and colon as if it was a relative path - - int index = path.IndexOf(':'); - - if (index != -1) + if (drive.Hidden) { - if (drive.Hidden) + treatAsRelative = false; + } + else + { + string possibleDriveName = path.Substring(0, index); + if (String.Equals(possibleDriveName, drive.Name, StringComparison.OrdinalIgnoreCase)) { treatAsRelative = false; } - else - { - string possibleDriveName = path.Substring(0, index); - if (String.Equals(possibleDriveName, drive.Name, StringComparison.OrdinalIgnoreCase)) - { - treatAsRelative = false; - } - } - } - - if (treatAsRelative) - { - string formatString = "{0}:" + StringLiterals.DefaultPathSeparator + "{1}"; - - if (path.StartsWith(StringLiterals.DefaultPathSeparator.ToString(), StringComparison.Ordinal)) - { - formatString = "{0}:{1}"; - } - result = - String.Format( - System.Globalization.CultureInfo.InvariantCulture, - formatString, - drive.Name, - path); } } - else + + if (treatAsRelative) { - if (path.StartsWith(drive.Name)) - result = path; - else - result = drive.Name + path; + string formatString = "{0}:" + StringLiterals.DefaultPathSeparator + "{1}"; + + if (path.StartsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal)) + { + formatString = "{0}:{1}"; + } + result = + String.Format( + System.Globalization.CultureInfo.InvariantCulture, + formatString, + drive.Name, + path); } - tracer.WriteLine("result = {0}", result); return result; } // GetDriveQualifiedPath @@ -5093,4 +5004,4 @@ namespace System.Management.Automation #endregion internal methods } // class LocationGlobber -} // namespace System.Management.Automation +} // namespace System.Management.Automation \ No newline at end of file diff --git a/src/System.Management.Automation/namespaces/RegistryProvider.cs b/src/System.Management.Automation/namespaces/RegistryProvider.cs index e33492c8f..8b3a75847 100644 --- a/src/System.Management.Automation/namespaces/RegistryProvider.cs +++ b/src/System.Management.Automation/namespaces/RegistryProvider.cs @@ -135,12 +135,6 @@ namespace Microsoft.PowerShell.Commands protected override Collection InitializeDefaultDrives() { Collection drives = new Collection(); - - if (!Platform.HasRegistrySupport()) - { - return drives; - } - drives.Add( new PSDriveInfo( "HKLM", diff --git a/src/System.Management.Automation/namespaces/SafeRegistryHandle.cs b/src/System.Management.Automation/namespaces/SafeRegistryHandle.cs index 1e817966b..119cf9724 100644 --- a/src/System.Management.Automation/namespaces/SafeRegistryHandle.cs +++ b/src/System.Management.Automation/namespaces/SafeRegistryHandle.cs @@ -58,10 +58,6 @@ namespace Microsoft.PowerShell.Commands.Internal override protected bool ReleaseHandle() { - if (!Platform.HasRegistrySupport()) - { - return true; - } // Returns a Win32 error code, 0 for success int r = RegCloseKey(handle); return r == 0; diff --git a/src/System.Management.Automation/namespaces/SafeTransactionHandle.cs b/src/System.Management.Automation/namespaces/SafeTransactionHandle.cs index db5ca3c85..ad5af91bd 100644 --- a/src/System.Management.Automation/namespaces/SafeTransactionHandle.cs +++ b/src/System.Management.Automation/namespaces/SafeTransactionHandle.cs @@ -1,4 +1,3 @@ -#if !CORECLR // // Copyright (C) Microsoft. All rights reserved. // @@ -45,8 +44,8 @@ namespace Microsoft.PowerShell.Commands.Internal // CommitableTransaction will use DTC APIs under the covers to get KTM transaction manager interface. // KTM is kernel Transaction Manager to handle file, registry etc and MSDTC provides an integration support // with KTM to handle transaction across kernel resources and MSDTC resources like SQL, MSMQ etc. - // We need KTMRM service as well. WinPE doesn?t have these services installed - if (Utils.IsWinPEHost() || PsUtils.IsRunningOnProcessorArchitectureARM()) + // We need KTMRM service as well. WinPE doesn’t have these services installed + if (RemotingCommandUtil.IsWinPEHost() || PsUtils.IsRunningOnProcessorArchitectureARM()) { throw new NotSupportedException(RegistryProviderStrings.NotSupported_KernelTransactions); } @@ -81,5 +80,3 @@ namespace Microsoft.PowerShell.Commands.Internal } } } - -#endif diff --git a/src/System.Management.Automation/namespaces/TransactedRegistry.cs b/src/System.Management.Automation/namespaces/TransactedRegistry.cs index b2f7e19b5..87896a7de 100644 --- a/src/System.Management.Automation/namespaces/TransactedRegistry.cs +++ b/src/System.Management.Automation/namespaces/TransactedRegistry.cs @@ -1,4 +1,3 @@ -#if !CORECLR // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. @@ -133,5 +132,3 @@ namespace Microsoft.PowerShell.Commands.Internal internal static readonly TransactedRegistryKey CurrentConfig = TransactedRegistryKey.GetBaseKey(BaseRegistryKeys.HKEY_CURRENT_CONFIG); } } - -#endif diff --git a/src/System.Management.Automation/namespaces/TransactedRegistryKey.cs b/src/System.Management.Automation/namespaces/TransactedRegistryKey.cs index 9f1c3edda..11e7de70e 100644 --- a/src/System.Management.Automation/namespaces/TransactedRegistryKey.cs +++ b/src/System.Management.Automation/namespaces/TransactedRegistryKey.cs @@ -1,4 +1,3 @@ -#if !CORECLR // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. @@ -192,14 +191,7 @@ namespace Microsoft.PowerShell.Commands.Internal { SafeRegistryHandle nonTxKey = null; SafeRegistryHandle txKey = null; - if (!Platform.HasRegistrySupport()) - { - error = 1; - } - else - { - error = Win32Native.RegOpenKeyEx(hkey, lpSubKey, ulOptions, samDesired, out nonTxKey); - } + error = Win32Native.RegOpenKeyEx(hkey, lpSubKey, ulOptions, samDesired, out nonTxKey); // If we got some error on this open, just ignore it and continue on with the handle // we got on the original RegOpenKeyTransacted. if (Win32Native.ERROR_SUCCESS == error) @@ -1969,5 +1961,3 @@ namespace Microsoft.PowerShell.Commands.Internal } } - -#endif diff --git a/src/System.Management.Automation/namespaces/TransactedRegistrySecurity.cs b/src/System.Management.Automation/namespaces/TransactedRegistrySecurity.cs index 584c3aea2..bcb4c4c38 100644 --- a/src/System.Management.Automation/namespaces/TransactedRegistrySecurity.cs +++ b/src/System.Management.Automation/namespaces/TransactedRegistrySecurity.cs @@ -1,4 +1,3 @@ -#if !CORECLR // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. @@ -467,5 +466,3 @@ namespace Microsoft.PowerShell.Commands.Internal } } } - -#endif diff --git a/src/System.Management.Automation/security/SecurityManager.cs b/src/System.Management.Automation/security/SecurityManager.cs index 80446a297..7dd6d46f2 100644 --- a/src/System.Management.Automation/security/SecurityManager.cs +++ b/src/System.Management.Automation/security/SecurityManager.cs @@ -117,13 +117,12 @@ namespace Microsoft.PowerShell string path = script.Path; string reasonMessage; - // path is assumed to be fully qualified here - if (path.IndexOf(System.IO.Path.DirectorySeparatorChar) < 0) + if (path.IndexOf('\\') < 0) { throw PSTraceSource.NewArgumentException("path"); } - if (path.LastIndexOf(System.IO.Path.DirectorySeparatorChar) == (path.Length - 1)) + if (path.LastIndexOf('\\') == (path.Length - 1)) { throw PSTraceSource.NewArgumentException("path"); } diff --git a/src/System.Management.Automation/security/SecuritySupport.cs b/src/System.Management.Automation/security/SecuritySupport.cs index 1a6b0ff4f..8d4dd2afb 100644 --- a/src/System.Management.Automation/security/SecuritySupport.cs +++ b/src/System.Management.Automation/security/SecuritySupport.cs @@ -138,11 +138,6 @@ namespace System.Management.Automation internal static void SetExecutionPolicy(ExecutionPolicyScope scope, ExecutionPolicy policy, string shellId) { - if (!Platform.HasExecutionPolicy()) - { - throw new PlatformNotSupportedException(); - } - string executionPolicy = "Restricted"; string preferenceKey = Utils.GetRegistryConfigurationPath(shellId); const string PolicyKeyValueName = "ExecutionPolicy"; @@ -283,11 +278,6 @@ namespace System.Management.Automation internal static ExecutionPolicy GetExecutionPolicy(string shellId, ExecutionPolicyScope scope) { - if (!Platform.HasExecutionPolicy()) - { - throw new PlatformNotSupportedException(); - } - switch (scope) { case ExecutionPolicyScope.Process: @@ -431,13 +421,6 @@ namespace System.Management.Automation return false; } - // There is no signature support on non-Windows platforms (yet), when - // execution reaches here, we are sure the file is under product folder - if (Platform.IsX()) - { - return true; - } - // Check the file signature Signature fileSignature = SignatureHelper.GetSignature(file, null); if ((fileSignature != null) && (fileSignature.IsOSBinary)) @@ -1633,18 +1616,6 @@ namespace System.Management.Automation /// Information about the source (filename, etc.) /// AMSI_RESULT_DETECTED if malware was detected in the sample. internal static AmsiNativeMethods.AMSI_RESULT ScanContent(string content, string sourceMetadata) - { - if (Platform.HasAmsi()) - { - return WinScanContent(content,sourceMetadata); - } - else - { - return AmsiNativeMethods.AMSI_RESULT.AMSI_RESULT_NOT_DETECTED; - } - } - - internal static AmsiNativeMethods.AMSI_RESULT WinScanContent(string content, string sourceMetadata) { if (String.IsNullOrEmpty(sourceMetadata)) { @@ -1729,16 +1700,9 @@ namespace System.Management.Automation } } - internal static void CurrentDomain_ProcessExit(object sender, EventArgs e) + static void CurrentDomain_ProcessExit(object sender, EventArgs e) { - if (Platform.HasAmsi()) - { - VerifyAmsiUninitializeCalled(); - } - else - { - throw new PlatformNotSupportedException(); - } + VerifyAmsiUninitializeCalled(); } [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] @@ -1753,20 +1717,6 @@ namespace System.Management.Automation /// Reset the AMSI session (used to track related script invocations) /// internal static void CloseSession() - { - if (Platform.HasAmsi()) - { - WinCloseSession(); - } - else - { - // Porting note: cannot throw here because this is called whether or not - // AMSI was initialized in the first place - return; - } - } - - internal static void WinCloseSession() { if (!amsiInitFailed) { @@ -1789,20 +1739,6 @@ namespace System.Management.Automation /// Uninitialize the AMSI interface /// internal static void Uninitialize() - { - if (Platform.HasAmsi()) - { - WinUninitialize(); - } - else - { - // Porting note: cannot throw here because this is called whether or not - // AMSI was initialized in the first place - return; - } - } - - internal static void WinUninitialize() { AmsiUninitializeCalled = true; if (!amsiInitFailed) diff --git a/src/System.Management.Automation/security/wldpNativeMethods.cs b/src/System.Management.Automation/security/wldpNativeMethods.cs index 801498709..bbb88befd 100644 --- a/src/System.Management.Automation/security/wldpNativeMethods.cs +++ b/src/System.Management.Automation/security/wldpNativeMethods.cs @@ -1,4 +1,3 @@ -#if !CORECLR using System; using System.Management.Automation; using System.Management.Automation.Internal; @@ -575,5 +574,4 @@ namespace System.Management.Automation.Security out IntPtr pszPath); } } -} -#endif +} \ No newline at end of file diff --git a/src/System.Management.Automation/singleshell/Commands/ConsoleCommands.cs b/src/System.Management.Automation/singleshell/Commands/ConsoleCommands.cs index c20a84ef2..92be0ceb8 100644 --- a/src/System.Management.Automation/singleshell/Commands/ConsoleCommands.cs +++ b/src/System.Management.Automation/singleshell/Commands/ConsoleCommands.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -605,5 +604,3 @@ namespace Microsoft.PowerShell.Commands #endregion } - -#endif diff --git a/src/System.Management.Automation/singleshell/Commands/MshSnapinCommands.cs b/src/System.Management.Automation/singleshell/Commands/MshSnapinCommands.cs index eb41b43b3..cfe5c7721 100644 --- a/src/System.Management.Automation/singleshell/Commands/MshSnapinCommands.cs +++ b/src/System.Management.Automation/singleshell/Commands/MshSnapinCommands.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -858,5 +857,3 @@ namespace Microsoft.PowerShell.Commands #endregion } - -#endif diff --git a/src/System.Management.Automation/singleshell/config/MshSnapinInfo.cs b/src/System.Management.Automation/singleshell/config/MshSnapinInfo.cs index 7fa604ded..0efd0ab7a 100644 --- a/src/System.Management.Automation/singleshell/config/MshSnapinInfo.cs +++ b/src/System.Management.Automation/singleshell/config/MshSnapinInfo.cs @@ -994,7 +994,7 @@ namespace System.Management.Automation return v; } - internal static void ReadRegistryInfo(out Version assemblyVersion, out string publicKeyToken, out string culture, out string architecture, out string applicationBase, out Version psVersion) + private static void ReadRegistryInfo(out Version assemblyVersion, out string publicKeyToken, out string culture, out string architecture, out string applicationBase, out Version psVersion) { applicationBase = Utils.GetApplicationBase(Utils.DefaultPowerShellShellID); Dbg.Assert(!string.IsNullOrEmpty(applicationBase), @@ -1018,21 +1018,9 @@ namespace System.Management.Automation byte[] publicTokens = currentAssembly.GetName().GetPublicKeyToken(); if (publicTokens.Length == 0) { - if (Platform.UsesCodeSignedAssemblies()) - { - throw PSTraceSource.NewArgumentException("PublicKeyToken", MshSnapinInfo.PublicKeyTokenAccessFailed); - } - else - { - // Platform note: set this to null when code signed assemblies are - // unsupported (rather than blank) - publicKeyToken = "null"; - } - } - else - { - publicKeyToken = ConvertByteArrayToString(publicTokens); + throw PSTraceSource.NewArgumentException("PublicKeyToken", MshSnapinInfo.PublicKeyTokenAccessFailed); } + publicKeyToken = ConvertByteArrayToString(publicTokens); // save some cpu cycles by hardcoding the culture to neutral // assembly should never be targeted to a particular culture culture = "neutral"; @@ -1083,12 +1071,6 @@ namespace System.Management.Automation "Help.format.ps1xml","HelpV3.format.ps1xml","PowerShellCore.format.ps1xml","PowerShellTrace.format.ps1xml", "Registry.format.ps1xml"}); - // If code signing is not supported, the token must be set to "null" - if (!Platform.UsesCodeSignedAssemblies()) - { - publicKeyToken = "null"; - } - string strongName = string.Format(CultureInfo.InvariantCulture, "{0}, Version={1}, Culture={2}, PublicKeyToken={3}, ProcessorArchitecture={4}", CoreSnapin.AssemblyName, assemblyVersion, culture, publicKeyToken, architecture); @@ -1148,7 +1130,7 @@ namespace System.Management.Automation StringComparison.OrdinalIgnoreCase)) { types = new Collection(new string[] { "GetEvent.types.ps1xml" }); - formats = new Collection(new string[] { "Event.format.ps1xml","Diagnostics.format.ps1xml" }); + formats = new Collection(new string[] { "Event.Format.ps1xml","Diagnostics.Format.ps1xml" }); } else if (defaultMshSnapinInfo.AssemblyName.Equals("Microsoft.WSMan.Management", StringComparison.OrdinalIgnoreCase)) { @@ -1428,7 +1410,7 @@ namespace System.Management.Automation }; #if !CORECLR //TODO:CORECLR - The 'Microsoft.WSMan.Management' module will be available on OneCore soon - if (!Utils.IsWinPEHost()) + if (!RemotingCommandUtil.IsWinPEHost()) { defaultMshSnapins.Add(new DefaultPSSnapInInformation("Microsoft.WSMan.Management", "Microsoft.WSMan.Management", null, "WsManResources,Description", "WsManResources,Vendor")); diff --git a/src/System.Management.Automation/singleshell/config/RegistryStringResourceIndirect.cs b/src/System.Management.Automation/singleshell/config/RegistryStringResourceIndirect.cs index 59fc89475..0b836a84e 100644 --- a/src/System.Management.Automation/singleshell/config/RegistryStringResourceIndirect.cs +++ b/src/System.Management.Automation/singleshell/config/RegistryStringResourceIndirect.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -616,5 +615,3 @@ namespace System.Management.Automation } - -#endif diff --git a/src/System.Management.Automation/singleshell/config/RunspaceConfigForSingleShell.cs b/src/System.Management.Automation/singleshell/config/RunspaceConfigForSingleShell.cs index 6a05afde1..3a8404f24 100644 --- a/src/System.Management.Automation/singleshell/config/RunspaceConfigForSingleShell.cs +++ b/src/System.Management.Automation/singleshell/config/RunspaceConfigForSingleShell.cs @@ -617,8 +617,7 @@ namespace System.Management.Automation.Runspaces try { - // WARNING: DUPLICATE CODE see InitialSessionState - assembly = ClrFacade.Load(new AssemblyName(mshsnapinInfo.AssemblyName)); + assembly = Assembly.Load(new AssemblyName(mshsnapinInfo.AssemblyName)); } catch (FileLoadException e) { diff --git a/src/System.Management.Automation/singleshell/installer/CustomMshSnapin.cs b/src/System.Management.Automation/singleshell/installer/CustomMshSnapin.cs index 7561274ff..4ca1b6730 100644 --- a/src/System.Management.Automation/singleshell/installer/CustomMshSnapin.cs +++ b/src/System.Management.Automation/singleshell/installer/CustomMshSnapin.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -153,5 +152,3 @@ namespace System.Management.Automation } } } - -#endif diff --git a/src/System.Management.Automation/singleshell/installer/MshCoreMshSnapin.cs b/src/System.Management.Automation/singleshell/installer/MshCoreMshSnapin.cs index 1505647a4..ec52d59e3 100644 --- a/src/System.Management.Automation/singleshell/installer/MshCoreMshSnapin.cs +++ b/src/System.Management.Automation/singleshell/installer/MshCoreMshSnapin.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -128,5 +127,3 @@ namespace Microsoft.PowerShell } } } - -#endif diff --git a/src/System.Management.Automation/singleshell/installer/MshInstaller.cs b/src/System.Management.Automation/singleshell/installer/MshInstaller.cs index 029a4afa5..a20d362b2 100644 --- a/src/System.Management.Automation/singleshell/installer/MshInstaller.cs +++ b/src/System.Management.Automation/singleshell/installer/MshInstaller.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -219,5 +218,3 @@ namespace System.Management.Automation } } } - -#endif diff --git a/src/System.Management.Automation/singleshell/installer/MshSnapin.cs b/src/System.Management.Automation/singleshell/installer/MshSnapin.cs index 1a8c227ce..0b80f4318 100644 --- a/src/System.Management.Automation/singleshell/installer/MshSnapin.cs +++ b/src/System.Management.Automation/singleshell/installer/MshSnapin.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -87,5 +86,3 @@ namespace System.Management.Automation } } } - -#endif diff --git a/src/System.Management.Automation/singleshell/installer/MshSnapinInstaller.cs b/src/System.Management.Automation/singleshell/installer/MshSnapinInstaller.cs index e70cb5641..94c0185e4 100644 --- a/src/System.Management.Automation/singleshell/installer/MshSnapinInstaller.cs +++ b/src/System.Management.Automation/singleshell/installer/MshSnapinInstaller.cs @@ -1,4 +1,3 @@ -#if !CORECLR /********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -164,5 +163,3 @@ namespace System.Management.Automation } } } - -#endif diff --git a/src/System.Management.Automation/utils/BackgroundDispatcher.cs b/src/System.Management.Automation/utils/BackgroundDispatcher.cs index 4beef2907..00a28e885 100644 --- a/src/System.Management.Automation/utils/BackgroundDispatcher.cs +++ b/src/System.Management.Automation/utils/BackgroundDispatcher.cs @@ -1,5 +1,4 @@ -#if !CORECLR -//----------------------------------------------------------------------- +//----------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // @@ -139,5 +138,3 @@ namespace System.Management.Automation #endregion } } - -#endif diff --git a/src/System.Management.Automation/utils/ClrFacade.cs b/src/System.Management.Automation/utils/ClrFacade.cs index 141fe20e6..bbf4c9805 100644 --- a/src/System.Management.Automation/utils/ClrFacade.cs +++ b/src/System.Management.Automation/utils/ClrFacade.cs @@ -240,8 +240,37 @@ namespace System.Management.Automation [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static string GetAssemblyLocation(Assembly assembly) { - // Porting note: Asembly.Location is in recent CoreCLR +#if CORECLR // Assembly.Location is not in CoreCLR; Use Assembly.ManifestModule.FullyQualifiedName to substitute it. + // According to MSDN: + // 1. Assembly.Location returns the location of the loaded file that contains the manifest. + // 2. Assembly.ManifestModule returns the module that contains the manifest for the assembly. + // 3. Module.FullyQualifiedName returns a string representing the fully qualified name and path to this module. + // + // When the actual assembly is .ni.dll, 'ManifestModule.FullyQualifiedName' still returns the IL dll name, e.g. System.Collections.dll. + // So we need to check if the path exists before returning it, and try the .ni.dll path again if it doesn't exist. + const string DllExt = ".dll"; + const string NiDllExt = ".ni.dll"; + + string path = assembly.ManifestModule.FullyQualifiedName; + if (File.Exists(path)) + { + return path; + } + + if (path.EndsWith(DllExt, StringComparison.OrdinalIgnoreCase) && + !path.EndsWith(NiDllExt, StringComparison.OrdinalIgnoreCase)) + { + path = Path.ChangeExtension(path, NiDllExt); + if (File.Exists(path)) + { + return path; + } + } + // This could happen if the passed-in assembly is a dynamic assembly. + return null; +#else return assembly.Location; +#endif } /// @@ -308,34 +337,6 @@ namespace System.Management.Automation } #endif - /// - /// Porting note: Load assembly by name through the AssemblyLoadContext. - /// This is to ensure that the types get cached. - /// - internal static Assembly Load(AssemblyName assembly) - { -#if CORECLR - var psAssemblyLoader = GetAssemblyLoadContext(); - return psAssemblyLoader.LoadFromAssemblyName(assembly); -#else - return Assembly.Load(assembly); -#endif - } - - /// - /// Same as the above, but overloaded for a name in a string. - /// - internal static Assembly Load(string assembly) - { -#if CORECLR - var psAssemblyLoader = GetAssemblyLoadContext(); - return psAssemblyLoader.LoadFromAssemblyName(new AssemblyName(assembly)); -#else - return Assembly.Load(assembly); -#endif - } - - /// /// Facade for EnumBuilder.CreateTypeInfo /// @@ -569,8 +570,20 @@ namespace System.Management.Automation /// internal static DirectoryInfo GetParent(string path) { - // Porting note: this is in recent CoreCLR +#if CORECLR + // Implementation copied from .NET source code. + if (string.IsNullOrEmpty(path)) + throw new ArgumentNullException("path"); + + string fullPath = Path.GetFullPath(path); + + string s = Path.GetDirectoryName(fullPath); + if (s == null) + return null; + return new DirectoryInfo(s); +#else return Directory.GetParent(path); +#endif } /// diff --git a/src/System.Management.Automation/utils/ExtensionMethods.cs b/src/System.Management.Automation/utils/ExtensionMethods.cs index 32948d31f..a25aefe17 100644 --- a/src/System.Management.Automation/utils/ExtensionMethods.cs +++ b/src/System.Management.Automation/utils/ExtensionMethods.cs @@ -29,15 +29,12 @@ namespace System.Management.Automation internal static class EnumerableExtensions { -#if !CORECLR - // Porting note: .NET Core has this, but full .NET does not internal static IEnumerable Append(this IEnumerable collection, T element) { foreach (T t in collection) yield return t; yield return element; } -#endif internal static IEnumerable Prepend(this IEnumerable collection, T element) { @@ -131,11 +128,6 @@ namespace System.Management.Automation [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static bool IsComObject(this Type type) { - if (!Platform.HasCom()) - { - return false; - } - #if CORECLR // Type.IsComObject(Type) is not in CoreCLR return ComObjectType.IsAssignableFrom(type); #else diff --git a/src/System.Management.Automation/utils/GraphicalHostReflectionWrapper.cs b/src/System.Management.Automation/utils/GraphicalHostReflectionWrapper.cs index 4f71be6c1..b93c7ec62 100644 --- a/src/System.Management.Automation/utils/GraphicalHostReflectionWrapper.cs +++ b/src/System.Management.Automation/utils/GraphicalHostReflectionWrapper.cs @@ -1,5 +1,4 @@ -#if !CORECLR -//----------------------------------------------------------------------- +//----------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // @@ -224,5 +223,3 @@ namespace System.Management.Automation.Internal } } } - -#endif diff --git a/src/System.Management.Automation/utils/PowerShellETWTracer.cs b/src/System.Management.Automation/utils/PowerShellETWTracer.cs index 7685073ba..53bc633e9 100644 --- a/src/System.Management.Automation/utils/PowerShellETWTracer.cs +++ b/src/System.Management.Automation/utils/PowerShellETWTracer.cs @@ -1,8 +1,7 @@ -#if !NOETW // // Copyright (C) Microsoft. All rights reserved. // -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Linq; @@ -1596,6 +1595,4 @@ namespace System.Management.Automation.Tracing } } //pragma warning restore 16001,16003 -} - -#endif +} \ No newline at end of file diff --git a/src/System.Management.Automation/utils/PsUtils.cs b/src/System.Management.Automation/utils/PsUtils.cs index deb01a119..c51a3ebfb 100644 --- a/src/System.Management.Automation/utils/PsUtils.cs +++ b/src/System.Management.Automation/utils/PsUtils.cs @@ -584,19 +584,6 @@ namespace System.Management.Automation } internal static string GetHostName() - { - // Note: non-windows CoreCLR does not support System.Net yet - if (Platform.IsWindows()) - { - return WinGetHostName(); - } - else - { - return Platform.NonWindowsGetHostName(); - } - } - - internal static string WinGetHostName() { System.Net.NetworkInformation.IPGlobalProperties ipProperties = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties(); @@ -611,18 +598,6 @@ namespace System.Management.Automation } internal static uint GetNativeThreadId() - { - if (Platform.IsWindows()) - { - return WinGetNativeThreadId(); - } - else - { - return Platform.NonWindowsGetThreadId(); - } - } - - internal static uint WinGetNativeThreadId() { return NativeMethods.GetCurrentThreadId(); } diff --git a/src/System.Management.Automation/utils/WindowsErrorReporting.cs b/src/System.Management.Automation/utils/WindowsErrorReporting.cs index 8d7d7e79d..5d6b8896e 100644 --- a/src/System.Management.Automation/utils/WindowsErrorReporting.cs +++ b/src/System.Management.Automation/utils/WindowsErrorReporting.cs @@ -1,8 +1,7 @@ -#if !CORECLR // // Copyright (C) Microsoft. All rights reserved. // -using System.Diagnostics; +using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; @@ -130,7 +129,7 @@ namespace System.Management.Automation HonorRestart = 2, /// - /// Add the report to the WER queue without notifying the user. The report is queued only-reporting (sending the report to Microsoft) occurs later based on the user's consent level. + /// Add the report to the WER queue without notifying the user. The report is queued only—reporting (sending the report to Microsoft) occurs later based on the user's consent level. /// Queue = 4, @@ -1044,5 +1043,3 @@ namespace System.Management.Automation #endregion } } - -#endif diff --git a/src/System.Management.Automation/utils/perfCounters/CounterSetInstanceBase.cs b/src/System.Management.Automation/utils/perfCounters/CounterSetInstanceBase.cs index 3acd83528..a38e96a7f 100644 --- a/src/System.Management.Automation/utils/perfCounters/CounterSetInstanceBase.cs +++ b/src/System.Management.Automation/utils/perfCounters/CounterSetInstanceBase.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -604,5 +603,3 @@ namespace System.Management.Automation.PerformanceData } } - -#endif diff --git a/src/System.Management.Automation/utils/perfCounters/CounterSetRegistrarBase.cs b/src/System.Management.Automation/utils/perfCounters/CounterSetRegistrarBase.cs index c51cb765a..215e0a5a1 100644 --- a/src/System.Management.Automation/utils/perfCounters/CounterSetRegistrarBase.cs +++ b/src/System.Management.Automation/utils/perfCounters/CounterSetRegistrarBase.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -364,5 +363,3 @@ namespace System.Management.Automation.PerformanceData } } - -#endif diff --git a/src/System.Management.Automation/utils/perfCounters/PSPerfCountersMgr.cs b/src/System.Management.Automation/utils/perfCounters/PSPerfCountersMgr.cs index 97061e3f2..a533978e2 100644 --- a/src/System.Management.Automation/utils/perfCounters/PSPerfCountersMgr.cs +++ b/src/System.Management.Automation/utils/perfCounters/PSPerfCountersMgr.cs @@ -1,5 +1,4 @@ -#if !CORECLR -/********************************************************************++ +/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ @@ -475,5 +474,3 @@ namespace System.Management.Automation.PerformanceData } } - -#endif diff --git a/src/System.Management.Automation/utils/tracing/EtwActivity.cs b/src/System.Management.Automation/utils/tracing/EtwActivity.cs index 19ed45d07..6abd12063 100644 --- a/src/System.Management.Automation/utils/tracing/EtwActivity.cs +++ b/src/System.Management.Automation/utils/tracing/EtwActivity.cs @@ -1,4 +1,3 @@ -#if !NOETW // // Copyright (C) Microsoft. All rights reserved. // @@ -548,6 +547,3 @@ namespace System.Management.Automation.Tracing } } } - - -#endif diff --git a/src/System.Management.Automation/utils/tracing/EtwActivityReverter.cs b/src/System.Management.Automation/utils/tracing/EtwActivityReverter.cs index ec3b9d385..21e1236a7 100644 --- a/src/System.Management.Automation/utils/tracing/EtwActivityReverter.cs +++ b/src/System.Management.Automation/utils/tracing/EtwActivityReverter.cs @@ -1,5 +1,4 @@ -#if !NOETW -//----------------------------------------------------------------------- +//----------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // @@ -59,6 +58,3 @@ namespace System.Management.Automation.Tracing } } } - - -#endif diff --git a/src/System.Management.Automation/utils/tracing/EtwActivityReverterMethodInvoker.cs b/src/System.Management.Automation/utils/tracing/EtwActivityReverterMethodInvoker.cs index 3cd849ea9..722ff6a11 100644 --- a/src/System.Management.Automation/utils/tracing/EtwActivityReverterMethodInvoker.cs +++ b/src/System.Management.Automation/utils/tracing/EtwActivityReverterMethodInvoker.cs @@ -1,5 +1,4 @@ -#if !NOETW -//----------------------------------------------------------------------- +//----------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // @@ -69,6 +68,3 @@ namespace System.Management.Automation.Tracing #endregion } } - - -#endif diff --git a/src/System.Management.Automation/utils/tracing/EtwEventCorrelator.cs b/src/System.Management.Automation/utils/tracing/EtwEventCorrelator.cs index a8df80b9e..4dc1221d8 100644 --- a/src/System.Management.Automation/utils/tracing/EtwEventCorrelator.cs +++ b/src/System.Management.Automation/utils/tracing/EtwEventCorrelator.cs @@ -1,5 +1,4 @@ -#if !NOETW -//----------------------------------------------------------------------- +//----------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // @@ -116,6 +115,3 @@ namespace System.Management.Automation.Tracing } } } - - -#endif diff --git a/src/System.Management.Automation/utils/tracing/IMethodInvoker.cs b/src/System.Management.Automation/utils/tracing/IMethodInvoker.cs index 980788273..37570678d 100644 --- a/src/System.Management.Automation/utils/tracing/IMethodInvoker.cs +++ b/src/System.Management.Automation/utils/tracing/IMethodInvoker.cs @@ -1,5 +1,4 @@ -#if !NOETW -//----------------------------------------------------------------------- +//----------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // @@ -15,6 +14,3 @@ namespace System.Management.Automation.Tracing object[] CreateInvokerArgs(Delegate methodToInvoke, object[] methodToInvokeArgs); } } - - -#endif diff --git a/src/System.Management.Automation/utils/tracing/PSEtwLog.cs b/src/System.Management.Automation/utils/tracing/PSEtwLog.cs index c784b2975..d2d1b058a 100644 --- a/src/System.Management.Automation/utils/tracing/PSEtwLog.cs +++ b/src/System.Management.Automation/utils/tracing/PSEtwLog.cs @@ -1,4 +1,3 @@ -#if !NOETW // // Copyright (C) Microsoft. All rights reserved. // @@ -311,6 +310,3 @@ namespace System.Management.Automation.Tracing } } } - - -#endif diff --git a/src/System.Management.Automation/utils/tracing/PSEtwLogProvider.cs b/src/System.Management.Automation/utils/tracing/PSEtwLogProvider.cs index 2f8d206e2..32bd8baa4 100644 --- a/src/System.Management.Automation/utils/tracing/PSEtwLogProvider.cs +++ b/src/System.Management.Automation/utils/tracing/PSEtwLogProvider.cs @@ -1,4 +1,3 @@ -#if !NOETW // // Copyright (C) Microsoft. All rights reserved. // @@ -463,6 +462,4 @@ namespace System.Management.Automation.Tracing EventProvider.SetActivityId(ref result); } } -} - -#endif +} \ No newline at end of file diff --git a/src/System.Management.Automation/utils/tracing/Tracing.cs b/src/System.Management.Automation/utils/tracing/Tracing.cs index eea3605ad..301d9ac98 100644 --- a/src/System.Management.Automation/utils/tracing/Tracing.cs +++ b/src/System.Management.Automation/utils/tracing/Tracing.cs @@ -1,4 +1,3 @@ -#if !NOETW // // Copyright (C) Microsoft. All rights reserved. // @@ -53,6 +52,4 @@ namespace System.Management.Automation.Tracing { return true; } } -} - -#endif +} \ No newline at end of file diff --git a/src/System.Management.Automation/utils/tracing/TracingGen.cs b/src/System.Management.Automation/utils/tracing/TracingGen.cs index 30564cff1..35ff735ff 100644 --- a/src/System.Management.Automation/utils/tracing/TracingGen.cs +++ b/src/System.Management.Automation/utils/tracing/TracingGen.cs @@ -1,4 +1,3 @@ -#if !NOETW using System; using System.Collections; using System.Diagnostics.Eventing; @@ -988,5 +987,3 @@ namespace System.Management.Automation.Tracing { } // This code was generated on 02/01/2012 19:52:32 - -#endif diff --git a/src/TypeCatalogGen/TypeCatalogGen.cs b/src/TypeCatalogGen/TypeCatalogGen.cs index ecaff01c0..3bc70e07d 100644 --- a/src/TypeCatalogGen/TypeCatalogGen.cs +++ b/src/TypeCatalogGen/TypeCatalogGen.cs @@ -14,7 +14,6 @@ */ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; @@ -91,16 +90,7 @@ Usage: TypeCatalogGen.exe <{0}> <{1}> } string fullName = GetTypeFullName(metadataReader, typeDefinition); - - // Only add unique types - if (!typeNameToAssemblyMap.ContainsKey(fullName)) - { - typeNameToAssemblyMap.Add(fullName, strongAssemblyName); - } - else - { - Debug.WriteLine($"Not adding duplicate key {fullName}!"); - } + typeNameToAssemblyMap.Add(fullName, strongAssemblyName); } } } diff --git a/src/powershell-native/nativemsh/pwrshcommon/ConfigFileReader.cpp b/src/powershell-native/nativemsh/pwrshcommon/ConfigFileReader.cpp index a070b6782..6a23239a0 100644 --- a/src/powershell-native/nativemsh/pwrshcommon/ConfigFileReader.cpp +++ b/src/powershell-native/nativemsh/pwrshcommon/ConfigFileReader.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include "NativeMsh.h" #include "ConfigFileReader.h"