Skip to content

Make code more explicit #1467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 29, 2021
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