From 12bf5f4a0ca5cf341d71a0330378aa32f9fce6b6 Mon Sep 17 00:00:00 2001 From: Ilya Date: Tue, 10 Mar 2020 21:30:53 +0500 Subject: [PATCH] Bring back `MainWindowTitle` in `PSHostProcessInfo` (#11885) * Bring back MainWindowTitle in PSHostProcessInfo * Add test --- .../engine/remoting/commands/EnterPSHostProcessCommand.cs | 4 ---- .../Get-PSHostProcessInfo.Tests.ps1 | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs b/src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs index 727c5ef709..cf06c4cda1 100644 --- a/src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs +++ b/src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs @@ -765,7 +765,6 @@ namespace Microsoft.PowerShell.Commands private set; } -#if !CORECLR /// /// Main window title of the process. /// @@ -774,7 +773,6 @@ namespace Microsoft.PowerShell.Commands get; private set; } -#endif #endregion @@ -794,7 +792,6 @@ namespace Microsoft.PowerShell.Commands if (string.IsNullOrEmpty(appDomainName)) { throw new PSArgumentNullException("appDomainName"); } -#if !CORECLR MainWindowTitle = string.Empty; try { @@ -803,7 +800,6 @@ namespace Microsoft.PowerShell.Commands } catch (ArgumentException) { } catch (InvalidOperationException) { } -#endif this.ProcessName = processName; this.ProcessId = processId; diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-PSHostProcessInfo.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-PSHostProcessInfo.Tests.ps1 index a8665db1d3..e53e4942ec 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-PSHostProcessInfo.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-PSHostProcessInfo.Tests.ps1 @@ -29,6 +29,11 @@ Describe "Get-PSHostProcessInfo tests" -Tag CI { (Get-PSHostProcessInfo).ProcessId | Should -Contain $PID } + It "Should return own self window title" { + $expected = (Get-Process -Id $PID).MainWindowTitle + (Get-PSHostProcessInfo -Id $PID).MainWindowTitle | Should -BeExactly $expected + } + It "Should list info for other PowerShell hosted processes" { # Creation of the named pipe is async Wait-UntilTrue {