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
@@ -1,10 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Microsoft.Extensions.Logging;
using Microsoft.PowerShell.EditorServices.Services.PowerShell.Host;
using System;
using System.Threading;
using Microsoft.Extensions.Logging;
using Microsoft.PowerShell.EditorServices.Services.PowerShell.Host;
using SMA = System.Management.Automation;

namespace Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution
Expand All @@ -23,7 +23,7 @@ public SynchronousDelegateTask(
CancellationToken cancellationToken)
: base(logger, cancellationToken)
{
ExecutionOptions = executionOptions ?? new ExecutionOptions();
ExecutionOptions = executionOptions ?? s_defaultExecutionOptions;
_representation = representation;
_action = action;
}
Expand Down Expand Up @@ -58,7 +58,7 @@ public SynchronousDelegateTask(
{
_func = func;
_representation = representation;
ExecutionOptions = executionOptions ?? new ExecutionOptions();
ExecutionOptions = executionOptions ?? s_defaultExecutionOptions;
}

public override ExecutionOptions ExecutionOptions { get; }
Expand Down Expand Up @@ -94,7 +94,7 @@ public SynchronousPSDelegateTask(
_psesHost = psesHost;
_action = action;
_representation = representation;
ExecutionOptions = executionOptions ?? new ExecutionOptions();
ExecutionOptions = executionOptions ?? s_defaultExecutionOptions;
}

public override ExecutionOptions ExecutionOptions { get; }
Expand Down Expand Up @@ -131,7 +131,7 @@ public SynchronousPSDelegateTask(
_psesHost = psesHost;
_func = func;
_representation = representation;
ExecutionOptions = executionOptions ?? new ExecutionOptions();
ExecutionOptions = executionOptions ?? s_defaultExecutionOptions;
}

public override ExecutionOptions ExecutionOptions { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ internal class SynchronousPowerShellTask<TResult> : SynchronousTask<IReadOnlyLis

private SMA.PowerShell _pwsh;

private readonly static PowerShellExecutionOptions s_defaultPowerShellExecutionOptions = new();

public SynchronousPowerShellTask(
ILogger logger,
PsesInternalHost psesHost,
Expand All @@ -36,7 +38,7 @@ public SynchronousPowerShellTask(
_logger = logger;
_psesHost = psesHost;
_psCommand = command;
PowerShellExecutionOptions = executionOptions ?? new PowerShellExecutionOptions();
PowerShellExecutionOptions = executionOptions ?? s_defaultPowerShellExecutionOptions;
}

public PowerShellExecutionOptions PowerShellExecutionOptions { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public TResult Result

public abstract ExecutionOptions ExecutionOptions { get; }

[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "RCS1158", Justification = "Field is not type-dependent")]
internal static readonly ExecutionOptions s_defaultExecutionOptions = new();

public abstract TResult Run(CancellationToken cancellationToken);

public abstract override string ToString();
Expand Down