@@ -36,7 +36,7 @@ namespace Microsoft.PowerShell.EditorServices.Commands
36
36
public sealed class StartEditorServicesCommand : PSCmdlet
37
37
{
38
38
// TODO: Remove this when we drop support for PS6.
39
- private readonly static bool s_isWindows =
39
+ private static readonly bool s_isWindows =
40
40
#if CoreCLR
41
41
RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ;
42
42
#else
@@ -237,15 +237,13 @@ protected override void EndProcessing()
237
237
// Create the configuration from parameters
238
238
EditorServicesConfig editorServicesConfig = CreateConfigObject ( ) ;
239
239
240
- var sessionFileWriter = new SessionFileWriter ( _logger , SessionDetailsPath ) ;
240
+ SessionFileWriter sessionFileWriter = new ( _logger , SessionDetailsPath ) ;
241
241
_logger . Log ( PsesLogLevel . Diagnostic , "Session file writer created" ) ;
242
242
243
- using ( var psesLoader = EditorServicesLoader . Create ( _logger , editorServicesConfig , sessionFileWriter , _loggerUnsubscribers ) )
244
- {
245
- _logger . Log ( PsesLogLevel . Verbose , "Loading EditorServices" ) ;
246
- // Start editor services and wait here until it shuts down
247
- psesLoader . LoadAndRunEditorServicesAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
248
- }
243
+ using EditorServicesLoader psesLoader = EditorServicesLoader . Create ( _logger , editorServicesConfig , sessionFileWriter , _loggerUnsubscribers ) ;
244
+ _logger . Log ( PsesLogLevel . Verbose , "Loading EditorServices" ) ;
245
+ // Start editor services and wait here until it shuts down
246
+ psesLoader . LoadAndRunEditorServicesAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
249
247
}
250
248
catch ( Exception e )
251
249
{
@@ -277,7 +275,7 @@ private void StartLogging()
277
275
// if it's being used as a protocol transport
278
276
if ( ! Stdio )
279
277
{
280
- var hostLogger = new PSHostLogger ( Host . UI ) ;
278
+ PSHostLogger hostLogger = new ( Host . UI ) ;
281
279
_loggerUnsubscribers . Add ( _logger . Subscribe ( hostLogger ) ) ;
282
280
}
283
281
@@ -292,7 +290,7 @@ private void StartLogging()
292
290
logPath = Path . Combine ( logDirPath , $ "StartEditorServices-temp{ randomInt . ToString ( "X" , CultureInfo . InvariantCulture . NumberFormat ) } .log") ;
293
291
}
294
292
295
- var fileLogger = StreamLogger . CreateWithNewFile ( logPath ) ;
293
+ StreamLogger fileLogger = StreamLogger . CreateWithNewFile ( logPath ) ;
296
294
_disposableResources . Add ( fileLogger ) ;
297
295
IDisposable fileLoggerUnsubscriber = _logger . Subscribe ( fileLogger ) ;
298
296
fileLogger . AddUnsubscriber ( fileLoggerUnsubscriber ) ;
@@ -316,23 +314,21 @@ private string GetLogDirPath()
316
314
private void RemovePSReadLineForStartup ( )
317
315
{
318
316
_logger . Log ( PsesLogLevel . Verbose , "Removing PSReadLine" ) ;
319
- using ( var pwsh = SMA . PowerShell . Create ( RunspaceMode . CurrentRunspace ) )
320
- {
321
- bool hasPSReadLine = pwsh . AddCommand ( new CmdletInfo ( "Microsoft.PowerShell.Core\\ Get-Module" , typeof ( GetModuleCommand ) ) )
322
- . AddParameter ( "Name" , "PSReadLine" )
323
- . Invoke ( )
324
- . Any ( ) ;
317
+ using SMA . PowerShell pwsh = SMA . PowerShell . Create ( RunspaceMode . CurrentRunspace ) ;
318
+ bool hasPSReadLine = pwsh . AddCommand ( new CmdletInfo ( "Microsoft.PowerShell.Core\\ Get-Module" , typeof ( GetModuleCommand ) ) )
319
+ . AddParameter ( "Name" , "PSReadLine" )
320
+ . Invoke ( )
321
+ . Any ( ) ;
325
322
326
- if ( hasPSReadLine )
327
- {
328
- pwsh . Commands . Clear ( ) ;
323
+ if ( hasPSReadLine )
324
+ {
325
+ pwsh . Commands . Clear ( ) ;
329
326
330
- pwsh . AddCommand ( new CmdletInfo ( "Microsoft.PowerShell.Core\\ Remove-Module" , typeof ( RemoveModuleCommand ) ) )
331
- . AddParameter ( "Name" , "PSReadLine" )
332
- . AddParameter ( "ErrorAction" , "SilentlyContinue" ) ;
327
+ pwsh . AddCommand ( new CmdletInfo ( "Microsoft.PowerShell.Core\\ Remove-Module" , typeof ( RemoveModuleCommand ) ) )
328
+ . AddParameter ( "Name" , "PSReadLine" )
329
+ . AddParameter ( "ErrorAction" , "SilentlyContinue" ) ;
333
330
334
- _logger . Log ( PsesLogLevel . Verbose , "Removed PSReadLine" ) ;
335
- }
331
+ _logger . Log ( PsesLogLevel . Verbose , "Removed PSReadLine" ) ;
336
332
}
337
333
}
338
334
@@ -352,14 +348,14 @@ private EditorServicesConfig CreateConfigObject()
352
348
bundledModulesPath ) ) ;
353
349
}
354
350
355
- var profile = ( PSObject ) GetVariableValue ( "profile" ) ;
351
+ PSObject profile = ( PSObject ) GetVariableValue ( "profile" ) ;
356
352
357
- var hostInfo = new HostInfo ( HostName , HostProfileId , HostVersion ) ;
353
+ HostInfo hostInfo = new ( HostName , HostProfileId , HostVersion ) ;
358
354
359
- var initialSessionState = Runspace . DefaultRunspace . InitialSessionState ;
355
+ InitialSessionState initialSessionState = Runspace . DefaultRunspace . InitialSessionState ;
360
356
initialSessionState . LanguageMode = Runspace . DefaultRunspace . SessionStateProxy . LanguageMode ;
361
357
362
- var editorServicesConfig = new EditorServicesConfig (
358
+ EditorServicesConfig editorServicesConfig = new (
363
359
hostInfo ,
364
360
Host ,
365
361
SessionDetailsPath ,
@@ -425,9 +421,9 @@ private ConsoleReplKind GetReplKind()
425
421
}
426
422
427
423
// TODO: Remove this when we drop support for PS6.
428
- var psVersionTable = ( Hashtable ) this . SessionState . PSVariable . GetValue ( "PSVersionTable" ) ;
424
+ Hashtable psVersionTable = ( Hashtable ) SessionState . PSVariable . GetValue ( "PSVersionTable" ) ;
429
425
dynamic version = psVersionTable [ "PSVersion" ] ;
430
- var majorVersion = ( int ) version . Major ;
426
+ int majorVersion = ( int ) version . Major ;
431
427
432
428
if ( UseLegacyReadLine || ( ! s_isWindows && majorVersion == 6 ) )
433
429
{
0 commit comments