@@ -192,7 +192,6 @@ public PowerShellContextService(
192192 OmniSharp . Extensions . LanguageServer . Protocol . Server . ILanguageServerFacade languageServer ,
193193 bool isPSReadLineEnabled )
194194 {
195- logger . LogTrace ( "Instantiating PowerShellContextService and adding event handlers" ) ;
196195 _languageServer = languageServer ;
197196 this . logger = logger ;
198197 this . isPSReadLineEnabled = isPSReadLineEnabled ;
@@ -214,7 +213,7 @@ public static PowerShellContextService Create(
214213 // Respect a user provided bundled module path.
215214 if ( Directory . Exists ( hostStartupInfo . BundledModulePath ) )
216215 {
217- logger . LogTrace ( $ "Using new bundled module path: { hostStartupInfo . BundledModulePath } ") ;
216+ logger . LogDebug ( $ "Using new bundled module path: { hostStartupInfo . BundledModulePath } ") ;
218217 s_bundledModulePath = hostStartupInfo . BundledModulePath ;
219218 }
220219
@@ -238,7 +237,6 @@ public static PowerShellContextService Create(
238237 hostUserInterface ,
239238 logger ) ;
240239
241- logger . LogTrace ( "Creating initial PowerShell runspace" ) ;
242240 Runspace initialRunspace = PowerShellContextService . CreateRunspace ( psHost , hostStartupInfo . InitialSessionState ) ;
243241 powerShellContext . Initialize ( hostStartupInfo . ProfilePaths , initialRunspace , true , hostUserInterface ) ;
244242 powerShellContext . ImportCommandsModuleAsync ( ) ;
@@ -327,7 +325,6 @@ public void Initialize(
327325 IHostOutput consoleHost )
328326 {
329327 Validate . IsNotNull ( "initialRunspace" , initialRunspace ) ;
330- this . logger . LogTrace ( $ "Initializing PowerShell context with runspace { initialRunspace . Name } ") ;
331328
332329 this . ownsInitialRunspace = ownsInitialRunspace ;
333330 this . SessionState = PowerShellContextState . NotStarted ;
@@ -363,6 +360,7 @@ public void Initialize(
363360 }
364361 else
365362 {
363+ // TODO: Also throw for PowerShell 6
366364 throw new NotSupportedException (
367365 "This computer has an unsupported version of PowerShell installed: " +
368366 powerShellVersion . ToString ( ) ) ;
@@ -577,10 +575,9 @@ public Task<IEnumerable<TResult>> ExecuteCommandAsync<TResult>(
577575 cancellationToken ) ;
578576 }
579577
580-
581578 /// <summary>
582579 /// 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.
584581 /// </summary>
585582 /// <typeparam name="TResult">The expected result type.</typeparam>
586583 /// <param name="psCommand">The PSCommand to be executed.</param>
@@ -601,8 +598,6 @@ public async Task<IEnumerable<TResult>> ExecuteCommandAsync<TResult>(
601598 Validate . IsNotNull ( nameof ( psCommand ) , psCommand ) ;
602599 Validate . IsNotNull ( nameof ( executionOptions ) , executionOptions ) ;
603600
604- this . logger . LogTrace ( $ "Attempting to execute command(s): { GetStringForPSCommand ( psCommand ) } ") ;
605-
606601 // Add history to PSReadLine before cancelling, otherwise it will be restored as the
607602 // cancelled prompt when it's called again.
608603 if ( executionOptions . AddToHistory )
@@ -636,8 +631,6 @@ public async Task<IEnumerable<TResult>> ExecuteCommandAsync<TResult>(
636631 this . ShouldExecuteWithEventing ( executionOptions ) ||
637632 ( PromptNest . IsRemote && executionOptions . IsReadLine ) ) )
638633 {
639- this . logger . LogTrace ( "Passing command execution to pipeline thread" ) ;
640-
641634 if ( shouldCancelReadLine && PromptNest . IsReadLineBusy ( ) )
642635 {
643636 // 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>(
715708 }
716709 try
717710 {
711+ this . logger . LogTrace ( $ "Executing in debugger: { GetStringForPSCommand ( psCommand ) } ") ;
718712 return this . ExecuteCommandInDebugger < TResult > (
719713 psCommand ,
720714 executionOptions . WriteOutputToHost ) ;
@@ -742,8 +736,6 @@ public async Task<IEnumerable<TResult>> ExecuteCommandAsync<TResult>(
742736 AddToHistory = executionOptions . AddToHistory
743737 } ;
744738
745- this . logger . LogTrace ( "Passing to PowerShell" ) ;
746-
747739 PowerShell shell = this . PromptNest . GetPowerShell ( executionOptions . IsReadLine ) ;
748740
749741 // 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>(
767759 : this . CurrentRunspace . Runspace ;
768760 try
769761 {
762+ this . logger . LogDebug ( $ "Invoking: { GetStringForPSCommand ( psCommand ) } ") ;
763+
770764 // Nested PowerShell instances can't be invoked asynchronously. This occurs
771765 // in nested prompts and pipeline requests from eventing.
772766 if ( shell . IsNested )
@@ -834,15 +828,11 @@ public async Task<IEnumerable<TResult>> ExecuteCommandAsync<TResult>(
834828
835829 hadErrors = true ;
836830 }
837- else
838- {
839- this . logger . LogTrace ( "Execution completed successfully" ) ;
840- }
841831 }
842832 }
843833 catch ( PSRemotingDataStructureException e )
844834 {
845- this . logger . LogHandledException ( "Pipeline stopped while executing command" , e ) ;
835+ this . logger . LogHandledException ( "PSRemotingDataStructure exception while executing command" , e ) ;
846836 errorMessages ? . Append ( e . Message ) ;
847837 }
848838 catch ( PipelineStoppedException e )
@@ -1087,7 +1077,7 @@ public async Task ExecuteScriptWithArgsAsync(string script, string arguments = n
10871077 . FirstOrDefault ( )
10881078 . ProviderPath ;
10891079
1090- this . logger . LogTrace ( $ "Prepending working directory { workingDir } to script path { script } ") ;
1080+ this . logger . LogDebug ( $ "Prepending working directory { workingDir } to script path { script } ") ;
10911081 script = Path . Combine ( workingDir , script ) ;
10921082 }
10931083 catch ( System . Management . Automation . DriveNotFoundException e )
@@ -1119,7 +1109,6 @@ public async Task ExecuteScriptWithArgsAsync(string script, string arguments = n
11191109 strBld . Append ( ' ' ) . Append ( arguments ) ;
11201110
11211111 var launchedScript = strBld . ToString ( ) ;
1122- this . logger . LogTrace ( $ "Launch script is: { launchedScript } ") ;
11231112
11241113 command . AddScript ( launchedScript , false ) ;
11251114 }
@@ -1261,15 +1250,15 @@ public void AbortExecution()
12611250 /// </param>
12621251 public void AbortExecution ( bool shouldAbortDebugSession )
12631252 {
1253+ this . logger . LogTrace ( "Execution abort requested..." ) ;
1254+
12641255 if ( this . SessionState == PowerShellContextState . Aborting
12651256 || this . SessionState == PowerShellContextState . Disposed )
12661257 {
12671258 this . logger . LogTrace ( $ "Execution abort requested when already aborted (SessionState = { this . SessionState } )") ;
12681259 return ;
12691260 }
12701261
1271- this . logger . LogTrace ( "Execution abort requested..." ) ;
1272-
12731262 if ( shouldAbortDebugSession )
12741263 {
12751264 this . ExitAllNestedPrompts ( ) ;
@@ -1415,7 +1404,7 @@ private void ResumeDebugger(DebuggerResumeAction resumeAction, bool shouldWaitFo
14151404 /// </summary>
14161405 public void Close ( )
14171406 {
1418- logger . LogDebug ( "Closing PowerShellContextService..." ) ;
1407+ logger . LogTrace ( "Closing PowerShellContextService..." ) ;
14191408 this . PromptNest . Dispose ( ) ;
14201409 this . SessionState = PowerShellContextState . Disposed ;
14211410
@@ -1853,13 +1842,7 @@ private void OnSessionStateChanged(object sender, SessionStateChangedEventArgs e
18531842 {
18541843 if ( this . SessionState != PowerShellContextState . Disposed )
18551844 {
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 } ") ;
18631846 this . SessionState = e . NewSessionState ;
18641847 this . SessionStateChanged ? . Invoke ( sender , e ) ;
18651848 }
@@ -1905,8 +1888,6 @@ private void OnExecutionStatusChanged(
19051888 /// </remarks>
19061889 private void PowerShellContext_RunspaceChangedAsync ( object sender , RunspaceChangedEventArgs e )
19071890 {
1908- this . logger . LogTrace ( "Sending runspaceChanged notification" ) ;
1909-
19101891 _languageServer ? . SendNotification (
19111892 "powerShell/runspaceChanged" ,
19121893 new MinifiedRunspaceDetails ( e . NewRunspace ) ) ;
@@ -1951,8 +1932,6 @@ public MinifiedRunspaceDetails(RunspaceDetails eventArgs)
19511932 /// <param name="e">details of the execution status change</param>
19521933 private void PowerShellContext_ExecutionStatusChangedAsync ( object sender , ExecutionStatusChangedEventArgs e )
19531934 {
1954- this . logger . LogTrace ( "Sending executionStatusChanged notification" ) ;
1955-
19561935 // The cancelling of the prompt (PSReadLine) causes an ExecutionStatus.Aborted to be sent after every
19571936 // actual execution (ExecutionStatus.Running) on the pipeline. We ignore that event since it's counterintuitive to
19581937 // 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
19721951
19731952 private IEnumerable < TResult > ExecuteCommandInDebugger < TResult > ( PSCommand psCommand , bool sendOutputToHost )
19741953 {
1975- this . logger . LogTrace ( $ "Attempting to execute command(s) in the debugger: { GetStringForPSCommand ( psCommand ) } ") ;
1976-
19771954 IEnumerable < TResult > output =
19781955 this . versionSpecificOperations . ExecuteCommandInDebugger < TResult > (
19791956 this ,
0 commit comments