Skip to content

Commit feadcee

Browse files
Merge pull request #1467 from rjmholt/pses-fixes
Make code more explicit
2 parents 3274c23 + 7ddfb8e commit feadcee

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/PowerShellEditorServices.Hosting/Commands/StartEditorServicesCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace Microsoft.PowerShell.EditorServices.Commands
3636
public sealed class StartEditorServicesCommand : PSCmdlet
3737
{
3838
// TODO: Remove this when we drop support for PS6.
39-
private static bool s_isWindows =
39+
private readonly static bool s_isWindows =
4040
#if CoreCLR
4141
RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
4242
#else

src/PowerShellEditorServices.Hosting/Configuration/HostLogger.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,10 @@ public StreamLogger(StreamWriter streamWriter)
286286
_messageQueue = new BlockingCollection<string>();
287287

288288
// Start writer listening to queue
289-
_writerThread = new Thread(RunWriter);
289+
_writerThread = new Thread(RunWriter)
290+
{
291+
Name = "PSES Stream Logger Thread",
292+
};
290293
_writerThread.Start();
291294
}
292295

@@ -306,6 +309,8 @@ public void OnCompleted()
306309
_fileWriter.Flush();
307310
_fileWriter.Close();
308311
_fileWriter.Dispose();
312+
_cancellationSource.Dispose();
313+
_messageQueue.Dispose();
309314
}
310315

311316
public void OnError(Exception error)

src/PowerShellEditorServices/Services/Analysis/PssaCmdletAnalysisEngine.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ private Task<PowerShellResult> InvokePowerShellAsync(PSCommand command)
326326

327327
private PowerShellResult InvokePowerShell(PSCommand command)
328328
{
329-
using (var powerShell = System.Management.Automation.PowerShell.Create())
329+
using (var powerShell = System.Management.Automation.PowerShell.Create(RunspaceMode.NewRunspace))
330330
{
331331
powerShell.RunspacePool = _analysisRunspacePool;
332332
powerShell.Commands = command;
@@ -441,7 +441,7 @@ private IEnumerable<string> GetPSScriptAnalyzerRules()
441441
/// <returns>A runspace pool with PSScriptAnalyzer loaded for running script analysis tasks.</returns>
442442
private static RunspacePool CreatePssaRunspacePool(out PSModuleInfo pssaModuleInfo)
443443
{
444-
using (var ps = System.Management.Automation.PowerShell.Create())
444+
using (var ps = System.Management.Automation.PowerShell.Create(RunspaceMode.NewRunspace))
445445
{
446446
// Run `Get-Module -ListAvailable -Name "PSScriptAnalyzer"`
447447
ps.AddCommand("Get-Module")

0 commit comments

Comments
 (0)