diff --git a/src/MamlWriter/MamlHelpers.cs b/src/MamlWriter/MamlHelpers.cs
index bc9025d7..7be73dc3 100644
--- a/src/MamlWriter/MamlHelpers.cs
+++ b/src/MamlWriter/MamlHelpers.cs
@@ -164,8 +164,24 @@ private static SyntaxItem ConvertSyntax(Model.SyntaxItem syntax)
private static PipelineInputType GetPipelineInputType(Model.Parameter parameter)
{
+ var pipelineInput = PipelineInputType.None;
+
+ bool byValue = parameter.ParameterSets.Any(ps => ps.ValueFromPipeline);
+ bool byPropertyName = parameter.ParameterSets.Any(ps => ps.ValueFromPipelineByPropertyName);
+
+ if (byValue && byPropertyName)
+ {
+ pipelineInput = PipelineInputType.ByValue | PipelineInputType.ByPropertyName;
+ }
+ else if (byValue)
+ {
+ pipelineInput = PipelineInputType.ByValue;
+ }
+ else if (byPropertyName)
+ {
+ pipelineInput = PipelineInputType.ByPropertyName;
+ }
- var pipelineInput = new PipelineInputType();
return pipelineInput;
}
@@ -192,6 +208,7 @@ private static Parameter ConvertParameter(Model.Parameter parameter)
var pSet = parameter.ParameterSets.FirstOrDefault();
newParameter.Position = pSet is null ? Model.Constants.NamedString : pSet.Position;
newParameter.Value = GetParameterValue(parameter);
+ newParameter.SupportsPipelineInput = GetPipelineInputType(parameter);
if (parameter.Description is not null)
{
@@ -259,4 +276,3 @@ private static CommandDetails ConvertCommandDetails(CommandHelp commandHelp)
}
}
-
diff --git a/src/MamlWriter/Parameter.cs b/src/MamlWriter/Parameter.cs
index 37a4f287..153691f9 100644
--- a/src/MamlWriter/Parameter.cs
+++ b/src/MamlWriter/Parameter.cs
@@ -50,7 +50,7 @@ public class Parameter
/// Can the parameter accept its value from the pipeline?
///
///
- /// Either "true (ByValue)", "true (ByPropertyName)", or "false".
+ /// Either "true (ByValue)", "true (ByPropertyName)", "true (ByValue, ByPropertyName)", or "false".
///
[XmlAttribute("pipelineInput")]
public string PipelineInputString
@@ -58,22 +58,14 @@ public string PipelineInputString
set { throw new System.NotImplementedException(); }
get
{
- if (SupportsPipelineInput == PipelineInputType.ByValue && SupportsPipelineInput == PipelineInputType.ByPropertyName)
+ return SupportsPipelineInput switch
{
- return "true (ByValue, ByPropertyName)";
- }
- else if (SupportsPipelineInput == PipelineInputType.ByValue)
- {
- return "true (ByValue)";
- }
- else if (SupportsPipelineInput == PipelineInputType.ByPropertyName)
- {
- return "true (ByPropertyName)";
- }
- else
- {
- return "false";
- }
+ PipelineInputType.None => "false",
+ PipelineInputType.ByValue => "true (ByValue)",
+ PipelineInputType.ByPropertyName => "true (ByPropertyName)",
+ PipelineInputType.ByValueAndByPropertyName => "true (ByValue, ByPropertyName)",
+ _ => "false"
+ };
}
}
diff --git a/src/MamlWriter/PipelineInputType.cs b/src/MamlWriter/PipelineInputType.cs
index 0d7ce92b..416d3f90 100644
--- a/src/MamlWriter/PipelineInputType.cs
+++ b/src/MamlWriter/PipelineInputType.cs
@@ -25,6 +25,12 @@ public enum PipelineInputType
/// Parameter can take its value from a property of the same name on objects in the pipeline.
///
[XmlEnum("true (ByPropertyName)")]
- ByPropertyName = 2
+ ByPropertyName = 2,
+
+ ///
+ /// Parameter can take its value from the pipeline both by value and by property name.
+ ///
+ [XmlEnum("true (ByValue, ByPropertyName)")]
+ ByValueAndByPropertyName = ByValue | ByPropertyName
}
}
diff --git a/test/Pester/Cmdlet.Tests.ps1 b/test/Pester/Cmdlet.Tests.ps1
index cefe31ce..4f6c4607 100644
--- a/test/Pester/Cmdlet.Tests.ps1
+++ b/test/Pester/Cmdlet.Tests.ps1
@@ -172,6 +172,11 @@ Describe "Miscellaneous cmdlet tests" {
$help.name | Should -BeExactly "Get-ChildItem"
}
-
+ It "Should have correct ByValue and ByPropertyName for the Path parameter" {
+ $help = Show-HelpPreview -Path $mamlPath
+ $param = $help.parameters.parameter | Where-Object -Property Name -EQ "Path"
+ $param | Should -Not -BeNullOrEmpty
+ $param.pipelineInput | Should -Be "true (ByValue, ByPropertyName)"
+ }
}
}