Skip to content

Commit 2843336

Browse files
committed
Fix PowerShell#570 Get-Help -ShowWindow errors in PSIC
This fix overrides the built-in PSHost.PrivateData property, which returns null. The override instead returns an empty PSObject. This fixes the Get-Help -ShowWindow scenario since Windows PowerShell will no longer get a NullRefEx on access the host PrivateData property without doing a null check. Since PrivateData["Window"] will still return null, PowerShell will show the dialog with the desktop as the parent window. IOW this PR does not fix the issue with the help window not appearing on top. It simply fixes the error you get in PSIC.
1 parent 1030d81 commit 2843336

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/PowerShellEditorServices/Session/Host/EditorServicesPSHost.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
44
//
55

6-
using Microsoft.PowerShell.EditorServices.Console;
76
using Microsoft.PowerShell.EditorServices.Session;
87
using Microsoft.PowerShell.EditorServices.Utility;
98
using System;
9+
using System.Management.Automation;
1010
using System.Management.Automation.Host;
1111
using System.Management.Automation.Runspaces;
1212

@@ -77,6 +77,16 @@ public override string Name
7777
get { return this.hostDetails.Name; }
7878
}
7979

80+
/// <summary>
81+
///
82+
/// </summary>
83+
public override PSObject PrivateData
84+
{
85+
// There is no PrivateData yet but by returning an empty object we can get past PowerShell's
86+
// check for $host.PrivateData["window"] which errors on the null returned by default.
87+
get { return new PSObject(); }
88+
}
89+
8090
/// <summary>
8191
///
8292
/// </summary>

0 commit comments

Comments
 (0)