diff --git a/src/MamlWriter/DataType.cs b/src/MamlWriter/DataType.cs
index c6cccfd3..4d9f36c5 100644
--- a/src/MamlWriter/DataType.cs
+++ b/src/MamlWriter/DataType.cs
@@ -16,7 +16,7 @@ public class DataType
///
/// The data-type name.
///
- [XmlElement("name", Namespace = Constants.XmlNamespace.Dev, Order = 0)]
+ [XmlElement("name", Namespace = Constants.XmlNamespace.MAML, Order = 0)]
public string Name { get; set; } = string.Empty;
///
diff --git a/src/Transform/TransformMaml.cs b/src/Transform/TransformMaml.cs
index 9c3127a9..e62816ad 100644
--- a/src/Transform/TransformMaml.cs
+++ b/src/Transform/TransformMaml.cs
@@ -288,6 +288,48 @@ private string ReadNotes(XmlReader reader)
}
}
+ ///
+ /// Reads nodes in <command:inputType> or <command:returnValue>
+ /// and returns object if possible.
+ ///
+ /// Sub tree instance of .
+ private static InputOutput? ReadInputOutput(XmlReader subTreeReader)
+ {
+ string? typeName = null;
+ StringBuilder typeDescription = Constants.StringBuilderPool.Get();
+
+ try
+ {
+ while (subTreeReader.Read())
+ {
+ switch (subTreeReader.Name)
+ {
+ // Supports both `` and ``.
+ // `` is wrong namespace, but used in PlatyPS v1.0.1
+ case Constants.MamlNameTag:
+ case "dev:name":
+ typeName = subTreeReader.ReadElementContentAsString();
+ continue;
+ case Constants.MamlParaTag:
+ typeDescription.AppendLine(subTreeReader.ReadElementContentAsString().Trim())
+ .AppendLine();
+ continue;
+ }
+ }
+
+ if (typeName is not null)
+ {
+ return new InputOutput(typeName, typeDescription.ToString().Trim());
+ }
+
+ return null;
+ }
+ finally
+ {
+ Constants.StringBuilderPool.Return(typeDescription);
+ }
+ }
+
private List ReadInput(XmlReader reader)
{
List inputItem = new();
@@ -298,24 +340,11 @@ private List ReadInput(XmlReader reader)
{
do
{
- string? typeName = null;
- string? typeDescription = null;
-
- if (reader.ReadToFollowing(Constants.MamlNameTag))
- {
- typeName = reader.ReadElementContentAsString();
- }
-
- if (reader.ReadToFollowing(Constants.MamlParaTag))
+ var input = ReadInputOutput(reader.ReadSubtree());
+ if (input is not null)
{
- typeDescription = reader.ReadElementContentAsString();
+ inputItem.Add(input);
}
-
- if (typeName is not null && typeDescription is not null)
- {
- inputItem.Add(new InputOutput(typeName, typeDescription));
- }
-
} while (reader.ReadToNextSibling(Constants.MamlCommandInputTypeTag));
}
}
@@ -333,24 +362,11 @@ private List ReadOutput(XmlReader reader)
{
do
{
- string? typeName = null;
- string? typeDescription = null;
-
- if (reader.ReadToFollowing(Constants.MamlNameTag))
- {
- typeName = reader.ReadElementContentAsString();
- }
-
- if (reader.ReadToFollowing(Constants.MamlParaTag))
+ var output = ReadInputOutput(reader.ReadSubtree());
+ if (output is not null)
{
- typeDescription = reader.ReadElementContentAsString();
+ outputItem.Add(output);
}
-
- if (typeName is not null && typeDescription is not null)
- {
- outputItem.Add(new InputOutput(typeName, typeDescription));
- }
-
} while (reader.ReadToNextSibling(Constants.MamlCommandReturnValueTag));
}
}
diff --git a/test/Pester/ImportMamlHelp.Tests.ps1 b/test/Pester/ImportMamlHelp.Tests.ps1
index d50d280c..94d3a819 100644
--- a/test/Pester/ImportMamlHelp.Tests.ps1
+++ b/test/Pester/ImportMamlHelp.Tests.ps1
@@ -46,5 +46,30 @@ Describe "Import-YamlHelp tests" {
$cmdlet.Metadata[$key] | Should -Be $Value
}
}
+
+ Context "Inputs/Outputs check" {
+ It "has the proper Inputs for the '' cmdlet" -testcases @(
+ @{ name = 'Add-Member'; expectedValues = 'System.Management.Automation.PSObject' },
+ @{ name = 'Get-PSBreakpoint'; expectedValues = 'System.Int32', 'Microsoft.PowerShell.Commands.BreakpointType' }
+ ) {
+ param ([string]$name, [string[]]$expectedValues)
+
+ $values = $importedCmds.Where({$_.Title -eq $name}).Inputs.Typename
+ $values | Should -BeExactly $expectedValues
+ }
+
+ It "has the proper Outputs for the '' cmdlet" -testcases @(
+ @{ name = 'Add-Member'; expectedValues = 'None', 'System.Object' },
+ @{ name = 'Get-PSBreakpoint'; expectedValues = 'System.Management.Automation.CommandBreakpoint',
+ 'System.Management.Automation.LineBreakpoint',
+ 'System.Management.Automation.VariableBreakpoint',
+ 'System.Management.Automation.Breakpoint' }
+ ) {
+ param ([string]$name, [string[]]$expectedValues)
+
+ $values = $importedCmds.Where({$_.Title -eq $name}).Outputs.Typename
+ $values | Should -BeExactly $expectedValues
+ }
+ }
}
-}
\ No newline at end of file
+}