Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace Microsoft.PowerShell.EditorServices.Commands
public sealed class StartEditorServicesCommand : PSCmdlet
{
// TODO: Remove this when we drop support for PS6.
private static bool s_isWindows =
private readonly static bool s_isWindows =
#if CoreCLR
RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,10 @@ public StreamLogger(StreamWriter streamWriter)
_messageQueue = new BlockingCollection<string>();

// Start writer listening to queue
_writerThread = new Thread(RunWriter);
_writerThread = new Thread(RunWriter)
{
Name = "PSES Stream Logger Thread",
};
_writerThread.Start();
}

Expand All @@ -306,6 +309,8 @@ public void OnCompleted()
_fileWriter.Flush();
_fileWriter.Close();
_fileWriter.Dispose();
_cancellationSource.Dispose();
_messageQueue.Dispose();
}

public void OnError(Exception error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ private Task<PowerShellResult> InvokePowerShellAsync(PSCommand command)

private PowerShellResult InvokePowerShell(PSCommand command)
{
using (var powerShell = System.Management.Automation.PowerShell.Create())
using (var powerShell = System.Management.Automation.PowerShell.Create(RunspaceMode.NewRunspace))
{
powerShell.RunspacePool = _analysisRunspacePool;
powerShell.Commands = command;
Expand Down Expand Up @@ -441,7 +441,7 @@ private IEnumerable<string> GetPSScriptAnalyzerRules()
/// <returns>A runspace pool with PSScriptAnalyzer loaded for running script analysis tasks.</returns>
private static RunspacePool CreatePssaRunspacePool(out PSModuleInfo pssaModuleInfo)
{
using (var ps = System.Management.Automation.PowerShell.Create())
using (var ps = System.Management.Automation.PowerShell.Create(RunspaceMode.NewRunspace))
{
// Run `Get-Module -ListAvailable -Name "PSScriptAnalyzer"`
ps.AddCommand("Get-Module")
Expand Down