Skip to content

Commit 9818713

Browse files
Copilotkilasuit
andcommitted
Fix compilation errors: move BackgroundThreadJob to ChainableAst and use compound assignment
- Moved BackgroundThreadJob property from PipelineAst to ChainableAst base class to make it accessible to both PipelineAst and PipelineChainAst - Updated PipelineChainAst.Copy() to preserve BackgroundThreadJob property - Fixed IDE0074 warning by using ??= compound assignment operator - Fixes CS1061 error where PipelineBaseAst didn't have BackgroundThreadJob property Co-authored-by: kilasuit <6355225+kilasuit@users.noreply.github.com>
1 parent 44d084e commit 9818713

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

src/System.Management.Automation/engine/parser/ast.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5540,6 +5540,11 @@ public abstract class ChainableAst : PipelineBaseAst
55405540
protected ChainableAst(IScriptExtent extent) : base(extent)
55415541
{
55425542
}
5543+
5544+
/// <summary>
5545+
/// Indicates that this pipeline should be run in the background as a ThreadJob.
5546+
/// </summary>
5547+
public bool BackgroundThreadJob { get; internal set; }
55435548
}
55445549

55455550
/// <summary>
@@ -5610,7 +5615,9 @@ public PipelineChainAst(
56105615
/// </returns>
56115616
public override Ast Copy()
56125617
{
5613-
return new PipelineChainAst(Extent, CopyElement(LhsPipelineChain), CopyElement(RhsPipeline), Operator, Background);
5618+
var copy = new PipelineChainAst(Extent, CopyElement(LhsPipelineChain), CopyElement(RhsPipeline), Operator, Background);
5619+
copy.BackgroundThreadJob = this.BackgroundThreadJob;
5620+
return copy;
56145621
}
56155622

56165623
internal override object Accept(ICustomAstVisitor visitor)
@@ -5767,11 +5774,6 @@ public PipelineAst(IScriptExtent extent, CommandBaseAst commandAst) : this(exten
57675774
/// </summary>
57685775
public bool Background { get; internal set; }
57695776

5770-
/// <summary>
5771-
/// Indicates that this pipeline should be run in the background as a ThreadJob.
5772-
/// </summary>
5773-
public bool BackgroundThreadJob { get; internal set; }
5774-
57755777
/// <summary>
57765778
/// If the pipeline represents a pure expression, the expression is returned, otherwise null is returned.
57775779
/// </summary>

src/System.Management.Automation/engine/runtime/Operations/MiscOps.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,8 @@ internal static void InvokePipelineInBackground(
593593
try
594594
{
595595
commandInfo = context.SessionState.InvokeCommand.GetCmdlet("Start-ThreadJob");
596-
if (commandInfo == null)
597-
{
598-
// Fall back to Start-Job if Start-ThreadJob is not available
599-
commandInfo = new CmdletInfo("Start-Job", typeof(StartJobCommand));
600-
}
596+
// Fall back to Start-Job if Start-ThreadJob is not available
597+
commandInfo ??= new CmdletInfo("Start-Job", typeof(StartJobCommand));
601598
}
602599
catch (CommandNotFoundException)
603600
{

0 commit comments

Comments
 (0)