File tree 3 files changed +9
-4
lines changed
PowerShellEditorServices/Services/Analysis
PowerShellEditorServices.Hosting
3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -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 static bool s_isWindows =
39
+ private readonly static bool s_isWindows =
40
40
#if CoreCLR
41
41
RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ;
42
42
#else
Original file line number Diff line number Diff line change @@ -286,7 +286,10 @@ public StreamLogger(StreamWriter streamWriter)
286
286
_messageQueue = new BlockingCollection < string > ( ) ;
287
287
288
288
// Start writer listening to queue
289
- _writerThread = new Thread ( RunWriter ) ;
289
+ _writerThread = new Thread ( RunWriter )
290
+ {
291
+ Name = "PSES Stream Logger Thread" ,
292
+ } ;
290
293
_writerThread . Start ( ) ;
291
294
}
292
295
@@ -306,6 +309,8 @@ public void OnCompleted()
306
309
_fileWriter . Flush ( ) ;
307
310
_fileWriter . Close ( ) ;
308
311
_fileWriter . Dispose ( ) ;
312
+ _cancellationSource . Dispose ( ) ;
313
+ _messageQueue . Dispose ( ) ;
309
314
}
310
315
311
316
public void OnError ( Exception error )
Original file line number Diff line number Diff line change @@ -326,7 +326,7 @@ private Task<PowerShellResult> InvokePowerShellAsync(PSCommand command)
326
326
327
327
private PowerShellResult InvokePowerShell ( PSCommand command )
328
328
{
329
- using ( var powerShell = System . Management . Automation . PowerShell . Create ( ) )
329
+ using ( var powerShell = System . Management . Automation . PowerShell . Create ( RunspaceMode . NewRunspace ) )
330
330
{
331
331
powerShell . RunspacePool = _analysisRunspacePool ;
332
332
powerShell . Commands = command ;
@@ -441,7 +441,7 @@ private IEnumerable<string> GetPSScriptAnalyzerRules()
441
441
/// <returns>A runspace pool with PSScriptAnalyzer loaded for running script analysis tasks.</returns>
442
442
private static RunspacePool CreatePssaRunspacePool ( out PSModuleInfo pssaModuleInfo )
443
443
{
444
- using ( var ps = System . Management . Automation . PowerShell . Create ( ) )
444
+ using ( var ps = System . Management . Automation . PowerShell . Create ( RunspaceMode . NewRunspace ) )
445
445
{
446
446
// Run `Get-Module -ListAvailable -Name "PSScriptAnalyzer"`
447
447
ps . AddCommand ( "Get-Module" )
You can’t perform that action at this time.
0 commit comments