@@ -192,7 +192,6 @@ public PowerShellContextService(
192
192
OmniSharp . Extensions . LanguageServer . Protocol . Server . ILanguageServerFacade languageServer ,
193
193
bool isPSReadLineEnabled )
194
194
{
195
- logger . LogTrace ( "Instantiating PowerShellContextService and adding event handlers" ) ;
196
195
_languageServer = languageServer ;
197
196
this . logger = logger ;
198
197
this . isPSReadLineEnabled = isPSReadLineEnabled ;
@@ -214,7 +213,7 @@ public static PowerShellContextService Create(
214
213
// Respect a user provided bundled module path.
215
214
if ( Directory . Exists ( hostStartupInfo . BundledModulePath ) )
216
215
{
217
- logger . LogTrace ( $ "Using new bundled module path: { hostStartupInfo . BundledModulePath } ") ;
216
+ logger . LogDebug ( $ "Using new bundled module path: { hostStartupInfo . BundledModulePath } ") ;
218
217
s_bundledModulePath = hostStartupInfo . BundledModulePath ;
219
218
}
220
219
@@ -238,7 +237,6 @@ public static PowerShellContextService Create(
238
237
hostUserInterface ,
239
238
logger ) ;
240
239
241
- logger . LogTrace ( "Creating initial PowerShell runspace" ) ;
242
240
Runspace initialRunspace = PowerShellContextService . CreateRunspace ( psHost , hostStartupInfo . InitialSessionState ) ;
243
241
powerShellContext . Initialize ( hostStartupInfo . ProfilePaths , initialRunspace , true , hostUserInterface ) ;
244
242
powerShellContext . ImportCommandsModuleAsync ( ) ;
@@ -327,7 +325,6 @@ public void Initialize(
327
325
IHostOutput consoleHost )
328
326
{
329
327
Validate . IsNotNull ( "initialRunspace" , initialRunspace ) ;
330
- this . logger . LogTrace ( $ "Initializing PowerShell context with runspace { initialRunspace . Name } ") ;
331
328
332
329
this . ownsInitialRunspace = ownsInitialRunspace ;
333
330
this . SessionState = PowerShellContextState . NotStarted ;
@@ -363,6 +360,7 @@ public void Initialize(
363
360
}
364
361
else
365
362
{
363
+ // TODO: Also throw for PowerShell 6
366
364
throw new NotSupportedException (
367
365
"This computer has an unsupported version of PowerShell installed: " +
368
366
powerShellVersion . ToString ( ) ) ;
@@ -577,10 +575,9 @@ public Task<IEnumerable<TResult>> ExecuteCommandAsync<TResult>(
577
575
cancellationToken ) ;
578
576
}
579
577
580
-
581
578
/// <summary>
582
579
/// Executes a PSCommand against the session's runspace and returns
583
- /// a collection of results of the expected type.
580
+ /// a collection of results of the expected type. This function needs help.
584
581
/// </summary>
585
582
/// <typeparam name="TResult">The expected result type.</typeparam>
586
583
/// <param name="psCommand">The PSCommand to be executed.</param>
@@ -601,8 +598,6 @@ public async Task<IEnumerable<TResult>> ExecuteCommandAsync<TResult>(
601
598
Validate . IsNotNull ( nameof ( psCommand ) , psCommand ) ;
602
599
Validate . IsNotNull ( nameof ( executionOptions ) , executionOptions ) ;
603
600
604
- this . logger . LogTrace ( $ "Attempting to execute command(s): { GetStringForPSCommand ( psCommand ) } ") ;
605
-
606
601
// Add history to PSReadLine before cancelling, otherwise it will be restored as the
607
602
// cancelled prompt when it's called again.
608
603
if ( executionOptions . AddToHistory )
@@ -636,8 +631,6 @@ public async Task<IEnumerable<TResult>> ExecuteCommandAsync<TResult>(
636
631
this . ShouldExecuteWithEventing ( executionOptions ) ||
637
632
( PromptNest . IsRemote && executionOptions . IsReadLine ) ) )
638
633
{
639
- this . logger . LogTrace ( "Passing command execution to pipeline thread" ) ;
640
-
641
634
if ( shouldCancelReadLine && PromptNest . IsReadLineBusy ( ) )
642
635
{
643
636
// If a ReadLine pipeline is running in the debugger then we'll stop responding here
@@ -715,6 +708,7 @@ public async Task<IEnumerable<TResult>> ExecuteCommandAsync<TResult>(
715
708
}
716
709
try
717
710
{
711
+ this . logger . LogTrace ( $ "Executing in debugger: { GetStringForPSCommand ( psCommand ) } ") ;
718
712
return this . ExecuteCommandInDebugger < TResult > (
719
713
psCommand ,
720
714
executionOptions . WriteOutputToHost ) ;
@@ -742,8 +736,6 @@ public async Task<IEnumerable<TResult>> ExecuteCommandAsync<TResult>(
742
736
AddToHistory = executionOptions . AddToHistory
743
737
} ;
744
738
745
- this . logger . LogTrace ( "Passing to PowerShell" ) ;
746
-
747
739
PowerShell shell = this . PromptNest . GetPowerShell ( executionOptions . IsReadLine ) ;
748
740
749
741
// Due to the following PowerShell bug, we can't just assign shell.Commands to psCommand
@@ -767,6 +759,8 @@ public async Task<IEnumerable<TResult>> ExecuteCommandAsync<TResult>(
767
759
: this . CurrentRunspace . Runspace ;
768
760
try
769
761
{
762
+ this . logger . LogDebug ( $ "Invoking: { GetStringForPSCommand ( psCommand ) } ") ;
763
+
770
764
// Nested PowerShell instances can't be invoked asynchronously. This occurs
771
765
// in nested prompts and pipeline requests from eventing.
772
766
if ( shell . IsNested )
@@ -834,15 +828,11 @@ public async Task<IEnumerable<TResult>> ExecuteCommandAsync<TResult>(
834
828
835
829
hadErrors = true ;
836
830
}
837
- else
838
- {
839
- this . logger . LogTrace ( "Execution completed successfully" ) ;
840
- }
841
831
}
842
832
}
843
833
catch ( PSRemotingDataStructureException e )
844
834
{
845
- this . logger . LogHandledException ( "Pipeline stopped while executing command" , e ) ;
835
+ this . logger . LogHandledException ( "PSRemotingDataStructure exception while executing command" , e ) ;
846
836
errorMessages ? . Append ( e . Message ) ;
847
837
}
848
838
catch ( PipelineStoppedException e )
@@ -1087,7 +1077,7 @@ public async Task ExecuteScriptWithArgsAsync(string script, string arguments = n
1087
1077
. FirstOrDefault ( )
1088
1078
. ProviderPath ;
1089
1079
1090
- this . logger . LogTrace ( $ "Prepending working directory { workingDir } to script path { script } ") ;
1080
+ this . logger . LogDebug ( $ "Prepending working directory { workingDir } to script path { script } ") ;
1091
1081
script = Path . Combine ( workingDir , script ) ;
1092
1082
}
1093
1083
catch ( System . Management . Automation . DriveNotFoundException e )
@@ -1119,7 +1109,6 @@ public async Task ExecuteScriptWithArgsAsync(string script, string arguments = n
1119
1109
strBld . Append ( ' ' ) . Append ( arguments ) ;
1120
1110
1121
1111
var launchedScript = strBld . ToString ( ) ;
1122
- this . logger . LogTrace ( $ "Launch script is: { launchedScript } ") ;
1123
1112
1124
1113
command . AddScript ( launchedScript , false ) ;
1125
1114
}
@@ -1261,15 +1250,15 @@ public void AbortExecution()
1261
1250
/// </param>
1262
1251
public void AbortExecution ( bool shouldAbortDebugSession )
1263
1252
{
1253
+ this . logger . LogTrace ( "Execution abort requested..." ) ;
1254
+
1264
1255
if ( this . SessionState == PowerShellContextState . Aborting
1265
1256
|| this . SessionState == PowerShellContextState . Disposed )
1266
1257
{
1267
1258
this . logger . LogTrace ( $ "Execution abort requested when already aborted (SessionState = { this . SessionState } )") ;
1268
1259
return ;
1269
1260
}
1270
1261
1271
- this . logger . LogTrace ( "Execution abort requested..." ) ;
1272
-
1273
1262
if ( shouldAbortDebugSession )
1274
1263
{
1275
1264
this . ExitAllNestedPrompts ( ) ;
@@ -1415,7 +1404,7 @@ private void ResumeDebugger(DebuggerResumeAction resumeAction, bool shouldWaitFo
1415
1404
/// </summary>
1416
1405
public void Close ( )
1417
1406
{
1418
- logger . LogDebug ( "Closing PowerShellContextService..." ) ;
1407
+ logger . LogTrace ( "Closing PowerShellContextService..." ) ;
1419
1408
this . PromptNest . Dispose ( ) ;
1420
1409
this . SessionState = PowerShellContextState . Disposed ;
1421
1410
@@ -1853,13 +1842,7 @@ private void OnSessionStateChanged(object sender, SessionStateChangedEventArgs e
1853
1842
{
1854
1843
if ( this . SessionState != PowerShellContextState . Disposed )
1855
1844
{
1856
- this . logger . LogTrace (
1857
- string . Format (
1858
- "Session state changed --\r \n \r \n Old state: {0}\r \n New state: {1}\r \n Result: {2}" ,
1859
- this . SessionState . ToString ( ) ,
1860
- e . NewSessionState . ToString ( ) ,
1861
- e . ExecutionResult ) ) ;
1862
-
1845
+ this . logger . LogTrace ( $ "Session state was: { SessionState } , is now: { e . NewSessionState } , result: { e . ExecutionResult } ") ;
1863
1846
this . SessionState = e . NewSessionState ;
1864
1847
this . SessionStateChanged ? . Invoke ( sender , e ) ;
1865
1848
}
@@ -1905,8 +1888,6 @@ private void OnExecutionStatusChanged(
1905
1888
/// </remarks>
1906
1889
private void PowerShellContext_RunspaceChangedAsync ( object sender , RunspaceChangedEventArgs e )
1907
1890
{
1908
- this . logger . LogTrace ( "Sending runspaceChanged notification" ) ;
1909
-
1910
1891
_languageServer ? . SendNotification (
1911
1892
"powerShell/runspaceChanged" ,
1912
1893
new MinifiedRunspaceDetails ( e . NewRunspace ) ) ;
@@ -1951,8 +1932,6 @@ public MinifiedRunspaceDetails(RunspaceDetails eventArgs)
1951
1932
/// <param name="e">details of the execution status change</param>
1952
1933
private void PowerShellContext_ExecutionStatusChangedAsync ( object sender , ExecutionStatusChangedEventArgs e )
1953
1934
{
1954
- this . logger . LogTrace ( "Sending executionStatusChanged notification" ) ;
1955
-
1956
1935
// The cancelling of the prompt (PSReadLine) causes an ExecutionStatus.Aborted to be sent after every
1957
1936
// actual execution (ExecutionStatus.Running) on the pipeline. We ignore that event since it's counterintuitive to
1958
1937
// the goal of this method which is to send updates when the pipeline is actually running something.
@@ -1972,8 +1951,6 @@ private void PowerShellContext_ExecutionStatusChangedAsync(object sender, Execut
1972
1951
1973
1952
private IEnumerable < TResult > ExecuteCommandInDebugger < TResult > ( PSCommand psCommand , bool sendOutputToHost )
1974
1953
{
1975
- this . logger . LogTrace ( $ "Attempting to execute command(s) in the debugger: { GetStringForPSCommand ( psCommand ) } ") ;
1976
-
1977
1954
IEnumerable < TResult > output =
1978
1955
this . versionSpecificOperations . ExecuteCommandInDebugger < TResult > (
1979
1956
this ,
0 commit comments