Skip to content
Merged
Show file tree
Hide file tree
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
21 changes: 20 additions & 1 deletion src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleShell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Runtime.CompilerServices;

namespace Microsoft.PowerShell
{
Expand All @@ -21,11 +22,29 @@ class ConsoleShell
/// <returns>An integer value which should be used as exit code for the process.</returns>
public static int Start(string bannerText, string helpText, string[] args)
{
return Start(InitialSessionState.CreateDefault2(), bannerText, helpText, args);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be written with the => syntax and dropping the braces, but I guess that's a matter of one's preference. 🙂

public static int Start(string bannerText, string helpText, string[] args) 
    => Start(InitialSessionState.CreateDefault2(), bannerText, helpText, args);


/// <summary>Entry point in to ConsoleShell. Used to create a custom Powershell console application</summary>
/// <param name="initialSessionState">InitialSessionState to be used by the ConsoleHost.</param>
/// <param name="bannerText">Banner text to be displayed by ConsoleHost.</param>
/// <param name="helpText">Help text for the shell.</param>
/// <param name="args">Commandline parameters specified by user.</param>
/// <returns>An integer value which should be used as exit code for the process.</returns>
public static int Start(InitialSessionState initialSessionState, string bannerText, string helpText, string[] args)
{
if (initialSessionState == null)
{
throw PSTraceSource.NewArgumentNullException(nameof(initialSessionState));
}

if (args == null)
{
throw PSTraceSource.NewArgumentNullException("args");
throw PSTraceSource.NewArgumentNullException(nameof(args));
}

ConsoleHost.DefaultInitialSessionState = initialSessionState;

return ConsoleHost.Start(bannerText, helpText, args);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ public static int Start(string consoleFilePath, [MarshalAs(UnmanagedType.LPArray
System.Diagnostics.Debugger.Break();
}
#endif
ConsoleHost.DefaultInitialSessionState = InitialSessionState.CreateDefault2();

int exitCode = 0;
try
{
Expand Down