Skip to content

Commit 8aec158

Browse files
authored
Clean up uses of CommandTypes.Workflow and WorkflowInfo (PowerShell#6708)
[breaking change] Clean up code related to the uses of `CommandTypes.Workflow` and `WorkflowInfo` in `System.Management.Automation`. This change mainly affects help provider code. This PR includes a few minor breaking changes: - Change the `public` constructors of `WorkflowInfo` to `internal`. We don't support workflow in PSCore, so I think it makes sense to not allow people to create `Workflow` instances. - Remove the type `System.Management.Automation.DebugSource` since it's only used for workflow debugging. - Remove the overload of `SetParent` from the abstract class `Debugger` that is only used for workflow debugging. - Remove the same overload of `SetParent` from the derived class `RemotingJobDebugger`.
1 parent 2406924 commit 8aec158

23 files changed

Lines changed: 52 additions & 447 deletions

src/System.Management.Automation/FormatAndOutput/DefaultFormatters/HelpV3_format_ps1xml.cs

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -254,19 +254,11 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_ExtendedCmdletHelpInfo(
254254
.EndEntry()
255255
.EndControl();
256256

257-
var control6 = CustomControl.Create()
258-
.StartEntry()
259-
.AddText(StringUtil.Format("[{0}]", HelpDisplayStrings.CommonWorkflowParameters))
260-
.EndEntry()
261-
.EndControl();
262-
263257
var control5 = CustomControl.Create()
264258
.StartEntry()
265259
.AddPropertyExpressionBinding(@"name")
266260
.AddText(" ")
267261
.AddPropertyExpressionBinding(@"Parameter", enumerateCollection: true, customControl: sharedControls[1])
268-
.AddScriptBlockExpressionBinding(@" ", selectedByScript: "$_.WorkflowCommonParameters -eq $true", customControl: control6)
269-
.AddText(" ")
270262
.AddScriptBlockExpressionBinding(@" ", selectedByScript: "$_.CommonParameters -eq $true", customControl: control7)
271263
.AddNewline()
272264
.AddNewline()
@@ -340,18 +332,6 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_ExtendedCmdletHelpInfo_
340332
.EndEntry()
341333
.EndControl();
342334

343-
var control15 = CustomControl.Create()
344-
.StartEntry()
345-
.AddText(HelpDisplayStrings.CommonWorkflowParameters)
346-
.AddNewline()
347-
.StartFrame(leftIndent: 4)
348-
.AddText(HelpDisplayStrings.BaseWorkflowCmdletInformation)
349-
.EndFrame()
350-
.AddNewline()
351-
.AddNewline()
352-
.EndEntry()
353-
.EndControl();
354-
355335
var control14 = CustomControl.Create()
356336
.StartEntry()
357337
.AddText("-")
@@ -376,21 +356,11 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_ExtendedCmdletHelpInfo_
376356
.EndEntry()
377357
.EndControl();
378358

379-
var control11 = CustomControl.Create()
380-
.StartEntry()
381-
.AddText("[")
382-
.AddText(HelpDisplayStrings.CommonWorkflowParameters)
383-
.AddText("]")
384-
.EndEntry()
385-
.EndControl();
386-
387359
var control10 = CustomControl.Create()
388360
.StartEntry()
389361
.AddPropertyExpressionBinding(@"name")
390362
.AddText(" ")
391363
.AddPropertyExpressionBinding(@"Parameter", enumerateCollection: true, customControl: sharedControls[1])
392-
.AddScriptBlockExpressionBinding(@" ", selectedByScript: "$_.WorkflowCommonParameters -eq $true", customControl: control11)
393-
.AddText(" ")
394364
.AddScriptBlockExpressionBinding(@" ", selectedByScript: "$_.CommonParameters -eq $true", customControl: control12)
395365
.AddNewline()
396366
.AddNewline()
@@ -429,7 +399,6 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_ExtendedCmdletHelpInfo_
429399
.AddNewline()
430400
.StartFrame(leftIndent: 4)
431401
.AddPropertyExpressionBinding(@"Parameters", customControl: control13)
432-
.AddScriptBlockExpressionBinding(@" ", selectedByScript: "$_.WorkflowCommonParameters -eq $true", customControl: control15)
433402
.AddScriptBlockExpressionBinding(@" ", selectedByScript: "$_.CommonParameters -eq $true", customControl: control16)
434403
.AddScriptBlockExpressionBinding(@" ", selectedByScript: "($_.CommonParameters -eq $false) -and ($_.parameters.parameter.count -eq 0)", customControl: control17)
435404
.EndFrame()
@@ -499,18 +468,6 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_ExtendedCmdletHelpInfo_
499468
.EndEntry()
500469
.EndControl();
501470

502-
var control29 = CustomControl.Create()
503-
.StartEntry()
504-
.AddText(HelpDisplayStrings.CommonWorkflowParameters)
505-
.AddNewline()
506-
.StartFrame(leftIndent: 4)
507-
.AddText(HelpDisplayStrings.BaseWorkflowCmdletInformation)
508-
.EndFrame()
509-
.AddNewline()
510-
.AddNewline()
511-
.EndEntry()
512-
.EndControl();
513-
514471
var control28 = CustomControl.Create()
515472
.StartEntry()
516473
.AddText(HelpDisplayStrings.NamedParameter)
@@ -584,21 +541,11 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_ExtendedCmdletHelpInfo_
584541
.EndEntry()
585542
.EndControl();
586543

587-
var control21 = CustomControl.Create()
588-
.StartEntry()
589-
.AddText("[")
590-
.AddText(HelpDisplayStrings.CommonWorkflowParameters)
591-
.AddText("]")
592-
.EndEntry()
593-
.EndControl();
594-
595544
var control20 = CustomControl.Create()
596545
.StartEntry()
597546
.AddPropertyExpressionBinding(@"name")
598547
.AddText(" ")
599548
.AddPropertyExpressionBinding(@"Parameter", enumerateCollection: true, customControl: sharedControls[1])
600-
.AddScriptBlockExpressionBinding(@" ", selectedByScript: "$_.WorkflowCommonParameters -eq $true", customControl: control21)
601-
.AddText(" ")
602549
.AddScriptBlockExpressionBinding(@" ", selectedByScript: "$_.CommonParameters -eq $true", customControl: control22)
603550
.AddNewline()
604551
.AddNewline()
@@ -637,7 +584,6 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_ExtendedCmdletHelpInfo_
637584
.AddNewline()
638585
.StartFrame(leftIndent: 4)
639586
.AddPropertyExpressionBinding(@"Parameters", customControl: control23)
640-
.AddScriptBlockExpressionBinding(@" ", selectedByScript: "$_.WorkflowCommonParameters -eq $true", customControl: control29)
641587
.AddScriptBlockExpressionBinding(@" ", selectedByScript: "$_.CommonParameters -eq $true", customControl: control30)
642588
.AddScriptBlockExpressionBinding(@" ", selectedByScript: "($_.CommonParameters -eq $false) -and ($_.parameters.parameter.count -eq 0)", customControl: control31)
643589
.AddNewline()

src/System.Management.Automation/FormatAndOutput/DefaultFormatters/Help_format_ps1xml.cs

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,6 @@ internal static IEnumerable<ExtendedTypeDefinition> GetFormatData()
140140
.EndEntry()
141141
.EndControl();
142142

143-
var CommonWorkflowParametersControl = CustomControl.Create()
144-
.StartEntry()
145-
.AddScriptBlockExpressionBinding(StringUtil.Format(@"$wfp = $_.psobject.Properties['WorkflowCommonParameters']
146-
if ($null -ne $wfp -and $wfp.Value)
147-
{{
148-
'[{0}] '
149-
}}", HelpDisplayStrings.CommonWorkflowParameters))
150-
.EndEntry()
151-
.EndControl();
152-
153143
var RelatedLinksHelpInfoControl = CustomControl.Create()
154144
.StartEntry()
155145
.StartFrame(leftIndent: 4)
@@ -270,7 +260,6 @@ internal static IEnumerable<ExtendedTypeDefinition> GetFormatData()
270260
.AddPropertyExpressionBinding(@"name")
271261
.AddText(" ")
272262
.AddPropertyExpressionBinding(@"Parameter", enumerateCollection: true, customControl: MamlParameterControl)
273-
.AddCustomControlExpressionBinding(CommonWorkflowParametersControl)
274263
.AddText("[" + HelpDisplayStrings.CommonParameters + "]")
275264
.AddNewline(2)
276265
.EndEntry()
@@ -413,7 +402,6 @@ internal static IEnumerable<ExtendedTypeDefinition> GetFormatData()
413402
MamlPossibleValueControl,
414403
MamlTrueFalseShortControl,
415404
MamlIndentedSyntaxControl,
416-
CommonWorkflowParametersControl,
417405
MamlSyntaxControl,
418406
MamlTypeWithDescriptionControl,
419407
RelatedLinksHelpInfoControl,
@@ -578,7 +566,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_MamlCommandHelpInfo(Cus
578566
.AddText(HelpDisplayStrings.RelatedLinks)
579567
.AddNewline()
580568
.StartFrame(leftIndent: 4)
581-
.AddPropertyExpressionBinding(@"relatedLinks", customControl: sharedControls[20])
569+
.AddPropertyExpressionBinding(@"relatedLinks", customControl: sharedControls[19])
582570
.EndFrame()
583571
.AddNewline()
584572
.AddText(HelpDisplayStrings.RemarksSection)
@@ -597,7 +585,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_MamlCommandHelpInfo(Cus
597585
.AddScriptBlockExpressionBinding(@"""get-help "" + $_.Details.Name + "" -full""")
598586
.AddText(@""".")
599587
.AddNewline()
600-
.AddCustomControlExpressionBinding(sharedControls[19])
588+
.AddCustomControlExpressionBinding(sharedControls[18])
601589
.EndFrame()
602590
.EndEntry()
603591
.EndControl());
@@ -634,7 +622,6 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_MamlCommandHelpInfo_Det
634622
.AddNewline()
635623
.StartFrame(leftIndent: 4)
636624
.AddPropertyExpressionBinding(@"Parameters", customControl: control9)
637-
.AddCustomControlExpressionBinding(sharedControls[16])
638625
.AddText(HelpDisplayStrings.CommonParameters)
639626
.AddNewline()
640627
.StartFrame(leftIndent: 4)
@@ -664,7 +651,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_MamlCommandHelpInfo_Det
664651
.AddScriptBlockExpressionBinding(@"""get-help "" + $_.Details.Name + "" -full""")
665652
.AddText(@""".")
666653
.AddNewline()
667-
.AddCustomControlExpressionBinding(sharedControls[19])
654+
.AddCustomControlExpressionBinding(sharedControls[18])
668655
.EndFrame()
669656
.EndEntry()
670657
.EndControl());
@@ -711,7 +698,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_MamlCommandHelpInfo_Ful
711698
.AddText(HelpDisplayStrings.NonHyphenTerminatingErrors)
712699
.AddNewline()
713700
.StartFrame(leftIndent: 4)
714-
.AddPropertyExpressionBinding(@"nonTerminatingError", enumerateCollection: true, customControl: sharedControls[21])
701+
.AddPropertyExpressionBinding(@"nonTerminatingError", enumerateCollection: true, customControl: sharedControls[20])
715702
.EndFrame()
716703
.EndEntry()
717704
.EndControl();
@@ -721,20 +708,20 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_MamlCommandHelpInfo_Ful
721708
.AddText(HelpDisplayStrings.TerminatingErrors)
722709
.AddNewline()
723710
.StartFrame(leftIndent: 4)
724-
.AddPropertyExpressionBinding(@"terminatingError", enumerateCollection: true, customControl: sharedControls[21])
711+
.AddPropertyExpressionBinding(@"terminatingError", enumerateCollection: true, customControl: sharedControls[20])
725712
.EndFrame()
726713
.EndEntry()
727714
.EndControl();
728715

729716
var control12 = CustomControl.Create()
730717
.StartEntry()
731-
.AddPropertyExpressionBinding(@"ReturnValue", enumerateCollection: true, customControl: sharedControls[18])
718+
.AddPropertyExpressionBinding(@"ReturnValue", enumerateCollection: true, customControl: sharedControls[17])
732719
.EndEntry()
733720
.EndControl();
734721

735722
var control11 = CustomControl.Create()
736723
.StartEntry()
737-
.AddPropertyExpressionBinding(@"InputType", enumerateCollection: true, customControl: sharedControls[18])
724+
.AddPropertyExpressionBinding(@"InputType", enumerateCollection: true, customControl: sharedControls[17])
738725
.EndEntry()
739726
.EndControl();
740727

@@ -747,7 +734,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_MamlCommandHelpInfo_Ful
747734
.AddText(HelpDisplayStrings.Parameters)
748735
.AddNewline()
749736
.StartFrame(leftIndent: 4)
750-
.AddPropertyExpressionBinding(@"Parameters", customControl: sharedControls[23])
737+
.AddPropertyExpressionBinding(@"Parameters", customControl: sharedControls[22])
751738
.EndFrame()
752739
.AddText(HelpDisplayStrings.InputType)
753740
.AddNewline()
@@ -778,7 +765,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_MamlCommandHelpInfo_Ful
778765
.AddText(HelpDisplayStrings.RelatedLinks)
779766
.AddNewline()
780767
.StartFrame(leftIndent: 4)
781-
.AddPropertyExpressionBinding(@"relatedLinks", customControl: sharedControls[20])
768+
.AddPropertyExpressionBinding(@"relatedLinks", customControl: sharedControls[19])
782769
.EndFrame()
783770
.EndEntry()
784771
.EndControl());
@@ -946,7 +933,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_ProviderHelpInfo(Custom
946933
.AddText(HelpDisplayStrings.RelatedLinks)
947934
.AddNewline()
948935
.StartFrame(leftIndent: 4)
949-
.AddPropertyExpressionBinding(@"relatedLinks", customControl: sharedControls[20])
936+
.AddPropertyExpressionBinding(@"relatedLinks", customControl: sharedControls[19])
950937
.EndFrame()
951938
.EndEntry()
952939
.EndControl());
@@ -1085,7 +1072,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_MamlCommandHelpInfo_Par
10851072
CustomControl.Create()
10861073
.StartEntry()
10871074
.StartFrame(leftIndent: 4)
1088-
.AddCustomControlExpressionBinding(sharedControls[23])
1075+
.AddCustomControlExpressionBinding(sharedControls[22])
10891076
.EndFrame()
10901077
.EndEntry()
10911078
.EndControl());
@@ -1096,7 +1083,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_MamlCommandHelpInfo_Par
10961083
yield return new FormatViewDefinition("MamlCommandParameterView",
10971084
CustomControl.Create()
10981085
.StartEntry()
1099-
.AddScriptBlockExpressionBinding(@"$_", customControl: sharedControls[22])
1086+
.AddScriptBlockExpressionBinding(@"$_", customControl: sharedControls[21])
11001087
.EndEntry()
11011088
.EndControl());
11021089
}
@@ -1106,7 +1093,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_MamlCommandHelpInfo_Syn
11061093
yield return new FormatViewDefinition("MamlCommandSyntax",
11071094
CustomControl.Create()
11081095
.StartEntry()
1109-
.AddScriptBlockExpressionBinding(@"$_", customControl: sharedControls[17])
1096+
.AddScriptBlockExpressionBinding(@"$_", customControl: sharedControls[16])
11101097
.EndEntry()
11111098
.EndControl());
11121099
}
@@ -1126,7 +1113,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_MamlCommandHelpInfo_inp
11261113
yield return new FormatViewDefinition("MamlInputTypes",
11271114
CustomControl.Create()
11281115
.StartEntry()
1129-
.AddPropertyExpressionBinding(@"InputType", enumerateCollection: true, customControl: sharedControls[18])
1116+
.AddPropertyExpressionBinding(@"InputType", enumerateCollection: true, customControl: sharedControls[17])
11301117
.EndEntry()
11311118
.EndControl());
11321119
}
@@ -1136,7 +1123,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_MamlCommandHelpInfo_non
11361123
yield return new FormatViewDefinition("MamlNonTerminatingErrors",
11371124
CustomControl.Create()
11381125
.StartEntry()
1139-
.AddPropertyExpressionBinding(@"nonTerminatingError", enumerateCollection: true, customControl: sharedControls[21])
1126+
.AddPropertyExpressionBinding(@"nonTerminatingError", enumerateCollection: true, customControl: sharedControls[20])
11401127
.EndEntry()
11411128
.EndControl());
11421129
}
@@ -1146,7 +1133,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_MamlCommandHelpInfo_ter
11461133
yield return new FormatViewDefinition("MamlTerminatingErrors",
11471134
CustomControl.Create()
11481135
.StartEntry()
1149-
.AddPropertyExpressionBinding(@"terminatingError", enumerateCollection: true, customControl: sharedControls[21])
1136+
.AddPropertyExpressionBinding(@"terminatingError", enumerateCollection: true, customControl: sharedControls[20])
11501137
.EndEntry()
11511138
.EndControl());
11521139
}
@@ -1156,7 +1143,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_MamlCommandHelpInfo_rel
11561143
yield return new FormatViewDefinition("MamlRelatedLinks",
11571144
CustomControl.Create()
11581145
.StartEntry()
1159-
.AddScriptBlockExpressionBinding(@"$_", customControl: sharedControls[20])
1146+
.AddScriptBlockExpressionBinding(@"$_", customControl: sharedControls[19])
11601147
.EndEntry()
11611148
.EndControl());
11621149
}
@@ -1166,7 +1153,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_MamlCommandHelpInfo_ret
11661153
yield return new FormatViewDefinition("MamlReturnTypes",
11671154
CustomControl.Create()
11681155
.StartEntry()
1169-
.AddPropertyExpressionBinding(@"ReturnValue", enumerateCollection: true, customControl: sharedControls[18])
1156+
.AddPropertyExpressionBinding(@"ReturnValue", enumerateCollection: true, customControl: sharedControls[17])
11701157
.EndEntry()
11711158
.EndControl());
11721159
}

src/System.Management.Automation/engine/CmdletInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ public override string Definition
297297
_verb,
298298
StringLiterals.CommandVerbNounSeparator,
299299
_noun,
300-
parameterSet.ToString((this.CommandType & CommandTypes.Workflow) == CommandTypes.Workflow)));
300+
parameterSet.ToString()));
301301
}
302302
}
303303
else

src/System.Management.Automation/engine/CommandDiscovery.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,6 @@ internal CommandProcessorBase LookupCommandProcessor(CommandInfo commandInfo,
651651
break;
652652
case CommandTypes.Filter:
653653
case CommandTypes.Function:
654-
case CommandTypes.Workflow:
655654
case CommandTypes.Configuration:
656655
FunctionInfo functionInfo = (FunctionInfo)commandInfo;
657656
processor = CreateCommandProcessorForScript(functionInfo, Context, useLocalScope ?? true, sessionState);

0 commit comments

Comments
 (0)