Skip to content

Finish redirection of $Host.PrivateData #1734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ internal class PsesInternalHost : PSHost, IHostSupportsInteractiveSession, IRuns

private EngineIntrinsics _mainRunspaceEngineIntrinsics;

private bool _shouldExit = false;
private bool _shouldExit;

private int _shuttingDown = 0;
private int _shuttingDown;

private string _localComputerName;

private ConsoleKeyInfo? _lastKey;

private bool _skipNextPrompt = false;
private bool _skipNextPrompt;

private bool _resettingRunspace = false;
private bool _resettingRunspace;

public PsesInternalHost(
ILoggerFactory loggerFactory,
Expand Down Expand Up @@ -126,6 +126,8 @@ public PsesInternalHost(

public override string Name { get; }

public override PSObject PrivateData => _hostInfo.PSHost.PrivateData;

public override PSHostUserInterface UI { get; }

public override Version Version { get; }
Expand Down Expand Up @@ -156,25 +158,13 @@ public PsesInternalHost(

private bool ShouldExitExecutionLoop => _shouldExit || _shuttingDown != 0;

public override void EnterNestedPrompt()
{
PushPowerShellAndRunLoop(CreateNestedPowerShell(CurrentRunspace), PowerShellFrameType.Nested);
}
public override void EnterNestedPrompt() => PushPowerShellAndRunLoop(CreateNestedPowerShell(CurrentRunspace), PowerShellFrameType.Nested);

public override void ExitNestedPrompt()
{
SetExit();
}
public override void ExitNestedPrompt() => SetExit();

public override void NotifyBeginApplication()
{
_hostInfo.PSHost.NotifyBeginApplication();
}
public override void NotifyBeginApplication() => _hostInfo.PSHost.NotifyBeginApplication();

public override void NotifyEndApplication()
{
_hostInfo.PSHost.NotifyEndApplication();
}
public override void NotifyEndApplication() => _hostInfo.PSHost.NotifyEndApplication();

public void PopRunspace()
{
Expand All @@ -188,11 +178,8 @@ public void PushRunspace(Runspace runspace)
PushPowerShellAndRunLoop(CreatePowerShellForRunspace(runspace), PowerShellFrameType.Remote);
}

public override void SetShouldExit(int exitCode)
{
// TODO: Handle exit code if needed
SetExit();
}
// TODO: Handle exit code if needed
public override void SetShouldExit(int exitCode) => SetExit();

/// <summary>
/// Try to start the PowerShell loop in the host.
Expand Down