Repository: PowerShell/PowerShell
File: src/System.Management.Automation/engine/hostifaces/MshHostUserInterface.cs (C#)

Code before:

        /// <summary>
        /// Creates a new instance of the PSHostUserInterface class.
        /// </summary>
        protected PSHostUserInterface()
        {
            CheckSystemTranscript();
        }

        /// <summary>
        /// Helper to transcribe an error through formatting and output.
        /// </summary>
        /// <param name="context">The Execution Context.</param>
        /// <param name="invocation">The invocation info associated with the record.</param>
        /// <param name="errorWrap">The error record.</param>
        internal void TranscribeError(ExecutionContext context, InvocationInfo invocation, PSObject errorWrap)
        {
            context.InternalHost.UI.TranscribeCommandComplete(invocation);
            InitialSessionState minimalState = InitialSessionState.CreateDefault2();
            Collection<PSObject> results = PowerShell.Create(minimalState).AddCommand("Out-String").Invoke(
                new List<PSObject>() { errorWrap });
            TranscribeResult(results[0].ToString());
        }

        /// <summary>
        /// Get Module Logging information from the registry.
        /// </summary>
        internal static TranscriptionOption GetSystemTranscriptOption(TranscriptionOption currentTranscript)
        {
            var transcription = InternalTestHooks.BypassGroupPolicyCaching
                ? Utils.GetPolicySetting<Transcription>(Utils.SystemWideThenCurrentUserConfig)
                : s_transcriptionSettingCache.Value;

            if (transcription != null)
            {
                // If we have an existing system transcript for this process, use that.
                // Otherwise, populate the static variable with the result of the group policy setting.
                //
                // This way, multiple runspaces opened by the same process will share the same transcript.
                lock (s_systemTranscriptLock)
                {
                    if (systemTranscript == null)
                    {
                        systemTranscript = PSHostUserInterface.GetTranscriptOptionFromSettings(transcription, currentTranscript);
                    }
                }
            }

            return systemTranscript;
        }


Review comment (bug):
@TylerLeonhardt this may be why the PowerShell daily build has been causing CI issues.

There's a new abstract method in the host which has broken me:

```
An error has occurred that was not properly handled. Additional information is shown below. The PowerShell process will exit.
Unhandled exception. System.TypeLoadException: Method 'PromptForCredential' in type 'Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.EditorServicesConsolePSHostUserInterface' from assembly 'Microsoft.PowerShell.EditorServices, Version=2.2.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.EditorServicesConsolePSHost..ctor(ILoggerFactory loggerFactory, String name, Version version, PSHost internalHost, ConsoleReadLine readline)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.PowerShellExecutionService.Initialize() in C:\Users\Robert Holt\Documents\Dev\Microsoft\PowerShellEditorServices\src\PowerShellEditorServices\Services\PowerShell\PowerShellExecutionService.cs:line 286
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.PowerShellExecutionService.RunTopLevelConsumerLoop() in C:\Users\Robert Holt\Documents\Dev\Microsoft\PowerShellEditorServices\src\PowerShellEditorServices\Services\PowerShell\PowerShellExecutionService.cs:line 244
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
```

I'll open an issue to track fixing this

Code after:
        /// <param name="targetName">
        /// Name of the target for which the credential is being collected.
        /// </param>
        /// <param name="allowedCredentialTypes">
        /// Types of credential can be supplied by the user.
        /// </param>
        /// <param name="options">
        /// Options that control the credential gathering UI behavior.
        /// </param>
        /// <returns>
        /// User input credential.
        /// </returns>
        /// <seealso cref="System.Management.Automation.Host.PSHostUserInterface.ReadLine"/>
        /// <seealso cref="System.Management.Automation.Host.PSHostUserInterface.ReadLineAsSecureString"/>
        /// <seealso cref="System.Management.Automation.Host.PSHostUserInterface.Prompt"/>
        /// <seealso cref="System.Management.Automation.Host.PSHostUserInterface.PromptForChoice"/>
        /// <seealso cref="System.Management.Automation.Host.PSHostUserInterface.PromptForCredential(string, string, string, string)"/>
        /// <seealso cref="System.Management.Automation.Host.PSHostUserInterface.PromptForCredential(string, string, string, string, System.Management.Automation.PSCredentialTypes, System.Management.Automation.PSCredentialUIOptions)"/>
        public abstract PSCredential PromptForCredential(
            string caption,
            string message,
            string userName,
            bool confirmPassword,
            string targetName,
            PSCredentialTypes allowedCredentialTypes,
            PSCredentialUIOptions options);

        /// <summary>
        /// Presents a dialog allowing the user to choose an option from a set of options.
        /// </summary>
        /// <param name="caption">
        /// Caption to precede or title the prompt.  E.g. "Parameters for get-foo (instance 1 of 2)"
        /// </param>
        /// <param name="message">
        /// A message that describes what the choice is for.
        /// </param>
        /// <param name="choices">
        /// An Collection of ChoiceDescription objects that describe each choice.
        /// </param>
        /// <param name="defaultChoice">
        /// The index of the label in the choices collection element to be presented to the user as the default choice.  -1
        /// means "no default". Must be a valid index.
        /// </param>
        /// <returns>
        /// The index of the choices element that corresponds to the option selected.
        /// </returns>
        /// <seealso cref="System.Management.Automation.Host.PSHostUserInterface.ReadLine"/>
        /// <seealso cref="System.Management.Automation.Host.PSHostUserInterface.ReadLineAsSecureString"/>
        /// <seealso cref="System.Management.Automation.Host.PSHostUserInterface.Prompt"/>
        /// <seealso cref="System.Management.Automation.Host.PSHostUserInterface.PromptForCredential(string, string, string, string)"/>
        /// <seealso cref="System.Management.Automation.Host.PSHostUserInterface.PromptForCredential(string, string, string, string, System.Management.Automation.PSCredentialTypes, System.Management.Automation.PSCredentialUIOptions)"/>