11// Copyright (c) Microsoft Corporation.
22// Licensed under the MIT License.
33
4- using Microsoft . Extensions . Logging ;
5- using Microsoft . PowerShell . EditorServices . Services . PowerShell . Console ;
64using System ;
75using System . Collections . Generic ;
86using System . Collections . ObjectModel ;
119using System . Reflection ;
1210using System . Security ;
1311using System . Threading ;
12+ using Microsoft . Extensions . Logging ;
13+ using Microsoft . PowerShell . EditorServices . Services . PowerShell . Console ;
1414
1515namespace Microsoft . PowerShell . EditorServices . Services . PowerShell . Host
1616{
1717 internal class EditorServicesConsolePSHostUserInterface : PSHostUserInterface
1818 {
19- private readonly ILogger _logger ;
20-
2119 private readonly IReadLineProvider _readLineProvider ;
2220
2321 private readonly PSHostUserInterface _underlyingHostUI ;
@@ -29,22 +27,22 @@ public EditorServicesConsolePSHostUserInterface(
2927 IReadLineProvider readLineProvider ,
3028 PSHostUserInterface underlyingHostUI )
3129 {
32- _logger = loggerFactory . CreateLogger < EditorServicesConsolePSHostUserInterface > ( ) ;
3330 _readLineProvider = readLineProvider ;
3431 _underlyingHostUI = underlyingHostUI ;
3532 RawUI = new EditorServicesConsolePSHostRawUserInterface ( loggerFactory , underlyingHostUI . RawUI ) ;
3633
3734 _consoleHostUI = GetConsoleHostUI ( _underlyingHostUI ) ;
35+
3836 if ( _consoleHostUI != null )
3937 {
4038 SetConsoleHostUIToInteractive ( _consoleHostUI ) ;
4139 }
4240 }
4341
44- public override PSHostRawUserInterface RawUI { get ; }
45-
4642 public override bool SupportsVirtualTerminal => _underlyingHostUI . SupportsVirtualTerminal ;
4743
44+ public override PSHostRawUserInterface RawUI { get ; }
45+
4846 public override Dictionary < string , PSObject > Prompt ( string caption , string message , Collection < FieldDescription > descriptions )
4947 {
5048 if ( _consoleHostUI != null )
@@ -77,66 +75,45 @@ public override PSCredential PromptForCredential(string caption, string message,
7775
7876 public override PSCredential PromptForCredential ( string caption , string message , string userName , string targetName )
7977 {
80- if ( _consoleHostUI != null )
78+ if ( _consoleHostUI is not null )
8179 {
8280 return _consoleHostUI . PromptForCredential ( caption , message , userName , targetName ) ;
8381 }
8482
8583 return _underlyingHostUI . PromptForCredential ( caption , message , userName , targetName ) ;
8684 }
8785
88- public override string ReadLine ( )
89- {
90- return _readLineProvider . ReadLine . ReadLine ( CancellationToken . None ) ;
91- }
86+ public override string ReadLine ( ) => _readLineProvider . ReadLine . ReadLine ( CancellationToken . None ) ;
9287
93- public override SecureString ReadLineAsSecureString ( )
94- {
95- return _readLineProvider . ReadLine . ReadSecureLine ( CancellationToken . None ) ;
96- }
88+ public override SecureString ReadLineAsSecureString ( ) => _readLineProvider . ReadLine . ReadSecureLine ( CancellationToken . None ) ;
9789
98- public override void Write ( ConsoleColor foregroundColor , ConsoleColor backgroundColor , string value )
99- {
100- _underlyingHostUI . Write ( foregroundColor , backgroundColor , value ) ;
101- }
90+ public override void Write ( ConsoleColor foregroundColor , ConsoleColor backgroundColor , string value ) => _underlyingHostUI . Write ( foregroundColor , backgroundColor , value ) ;
10291
103- public override void Write ( string value )
104- {
105- _underlyingHostUI . Write ( value ) ;
106- }
92+ public override void Write ( string value ) => _underlyingHostUI . Write ( value ) ;
10793
108- public override void WriteDebugLine ( string message )
109- {
110- _underlyingHostUI . WriteDebugLine ( message ) ;
111- }
94+ public override void WriteDebugLine ( string message ) => _underlyingHostUI . WriteDebugLine ( message ) ;
11295
113- public override void WriteErrorLine ( string value )
114- {
115- _underlyingHostUI . WriteErrorLine ( value ) ;
116- }
96+ public override void WriteErrorLine ( string value ) => _underlyingHostUI . WriteErrorLine ( value ) ;
11797
118- public override void WriteLine ( string value )
119- {
120- _underlyingHostUI . WriteLine ( value ) ;
121- }
98+ public override void WriteInformation ( InformationRecord record ) => _underlyingHostUI . WriteInformation ( record ) ;
99+
100+ public override void WriteLine ( ) => _underlyingHostUI . WriteLine ( ) ;
101+
102+ public override void WriteLine ( ConsoleColor foregroundColor , ConsoleColor backgroundColor , string value ) => _underlyingHostUI . WriteLine ( foregroundColor , backgroundColor , value ) ;
103+
104+ public override void WriteLine ( string value ) => _underlyingHostUI . WriteLine ( value ) ;
122105
123106 public override void WriteProgress ( long sourceId , ProgressRecord record ) => _underlyingHostUI . WriteProgress ( sourceId , record ) ;
124107
125- public override void WriteVerboseLine ( string message )
126- {
127- _underlyingHostUI . WriteVerboseLine ( message ) ;
128- }
108+ public override void WriteVerboseLine ( string message ) => _underlyingHostUI . WriteVerboseLine ( message ) ;
129109
130- public override void WriteWarningLine ( string message )
131- {
132- _underlyingHostUI . WriteWarningLine ( message ) ;
133- }
110+ public override void WriteWarningLine ( string message ) => _underlyingHostUI . WriteWarningLine ( message ) ;
134111
135112 private static PSHostUserInterface GetConsoleHostUI ( PSHostUserInterface ui )
136113 {
137114 FieldInfo externalUIField = ui . GetType ( ) . GetField ( "_externalUI" , BindingFlags . NonPublic | BindingFlags . Instance ) ;
138115
139- if ( externalUIField == null )
116+ if ( externalUIField is null )
140117 {
141118 return null ;
142119 }
0 commit comments