Update files from Source Depot changeset [SD:715912]

Corresponds to 77eda782aa78ba8b7a36c51ee619629ce6c990f2 in psl-monad.
This commit is contained in:
PowerShell Team authored and Andrew Schwartzmeyer committed 2016-06-15 18:02:03 -07:00
1 parent d9b11669ce
commit 8ee6d6ca43
74 files changed
+1376 -1336

No files matched your search

@@ -623,29 +623,6 @@ namespace Microsoft.PowerShell
return _outputHandle.Value;
}
internal enum StandardHandleId : uint
{
// From winnt.h
// #define STD_INPUT_HANDLE ((DWORD)-10)
// #define STD_OUTPUT_HANDLE ((DWORD)-11)
// #define STD_ERROR_HANDLE ((DWORD)-12)
Input = 0xFFFFFFF6,
Output = 0xFFFFFFF5,
Error = 0xFFFFFFF4
}
internal static NakedWin32Handle GetStdHandle(StandardHandleId handleId)
{
unchecked
{
// Suppress the PreFAST warning about not using Marshal.GetLastWin32Error() to
// get the error code.
#pragma warning disable 56523
return NativeMethods.GetStdHandle((DWORD)handleId);
}
}
#endregion
#region Mode
@@ -3492,9 +3469,6 @@ namespace Microsoft.PowerShell
[DllImport(PinvokeDllNames.GetLargestConsoleWindowSizeDllName, SetLastError = true, CharSet = CharSet.Unicode)]
internal static extern COORD GetLargestConsoleWindowSize(NakedWin32Handle consoleOutput);
[DllImport(PinvokeDllNames.GetStdHandleDllName, SetLastError = true, CharSet = CharSet.Unicode)]
internal static extern NakedWin32Handle GetStdHandle(DWORD handleId);
[DllImport(PinvokeDllNames.ReadConsoleDllName, SetLastError = true, CharSet = CharSet.Unicode)]
internal static extern bool ReadConsole
(
@@ -1421,7 +1421,7 @@ namespace Microsoft.PowerShell
if (ExitCode == ExitCodeInitFailure) { break; }
if (!noExit && !ui.ReadFromStdin)
if (!noExit && (!ui.ReadFromStdin || Console.In.Peek() == -1))
{
// Wait for runspace to open, init, and run init script before
// setting ShouldEndSession, to allow debugger to work.
@@ -4,6 +4,7 @@ Copyright (c) Microsoft Corporation. All rights reserved.
using System;
using System.Threading;
using System.Reflection;
using System.Management.Automation;
using System.Management.Automation.Internal;
using System.Management.Automation.Runspaces;
@@ -34,6 +35,13 @@ namespace Microsoft.PowerShell
public int Start(string consoleFilePath, string[] args)
#endif
{
#if !CORECLR
// For long-path support, Full .NET requires some AppContext switches;
// (for CoreCLR this is Not needed, because CoreCLR supports long paths by default)
// internally in .NET they are cached once retrieved and are typically hit very early during an application run;
// so per .NET team's recommendation, we are setting them as soon as we enter managed code.
EnableLongPathsInDotNetIfAvailable();
#endif
System.Management.Automation.Runspaces.EarlyStartup.Init();
// Set ETW activity Id
@@ -152,6 +160,27 @@ namespace Microsoft.PowerShell
#endif
}
}
#if !CORECLR
private static void EnableLongPathsInDotNetIfAvailable()
{
// We build against CLR4.5 so we can run on Win7/Win8, but we want to use apis added to CLR 4.6, so we use reflection
try
{
Type appContextType = Type.GetType("System.AppContext"); // type is in mscorlib, so it is sufficient to supply the type name qualified by its namespace
object[] blockLongPathsSwitch = new object[] { "Switch.System.IO.BlockLongPaths", false };
object[] useLegacyPathHandlingSwitch = new object[] { "Switch.System.IO.UseLegacyPathHandling", false };
appContextType.InvokeMember("SetSwitch", BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod, null, null, blockLongPathsSwitch);
appContextType.InvokeMember("SetSwitch", BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod, null, null, useLegacyPathHandlingSwitch);
}
catch
{
// If there are any exceptions (e.g. we are running on CLR prior to 4.6.2), we won't be able to use long paths
}
}
#endif
}
}
@@ -233,7 +233,7 @@ namespace Microsoft.PowerShell.Commands
System.Management.Automation.Remoting.PSSenderInfo psSenderInfo =
this.SessionState.PSVariable.GetValue("PSSenderInfo") as System.Management.Automation.Remoting.PSSenderInfo;
Host.UI.StartTranscribing(effectiveFilePath, psSenderInfo, IncludeInvocationHeader.ToBool());
Host.UI.StartTranscribing(effectiveFilePath, psSenderInfo, IncludeInvocationHeader.ToBool(), this.Context.CurrentRunspace.InstanceId);
// ch.StartTranscribing(effectiveFilePath, Append);
@@ -249,7 +249,7 @@ namespace Microsoft.PowerShell.Commands
{
try
{
Host.UI.StopTranscribing();
Host.UI.StopTranscribing(this.Context.CurrentRunspace.InstanceId);
}
catch
{
@@ -35,7 +35,7 @@ namespace Microsoft.PowerShell.Commands
{
try
{
string outFilename = Host.UI.StopTranscribing();
string outFilename = Host.UI.StopTranscribing(this.Context.CurrentRunspace.InstanceId);
if (outFilename != null)
{
PSObject outputObject = new PSObject(