@@ -288,6 +288,48 @@ private string ReadNotes(XmlReader reader)
288288 }
289289 }
290290
291+ /// <summary>
292+ /// Reads nodes in <command:inputType> or <command:returnValue>
293+ /// and returns <see cref="InputOutput"/> object if possible.
294+ /// </summary>
295+ /// <param name="subTreeReader">Sub tree instance of <see cref="XmlReader"/>.</param>
296+ private static InputOutput ? ReadInputOutput ( XmlReader subTreeReader )
297+ {
298+ string ? typeName = null ;
299+ StringBuilder typeDescription = Constants . StringBuilderPool . Get ( ) ;
300+
301+ try
302+ {
303+ while ( subTreeReader . Read ( ) )
304+ {
305+ switch ( subTreeReader . Name )
306+ {
307+ // Supports both `<maml:name>` and `<dev:name>`.
308+ // `<dev:name>` is wrong namespace, but used in PlatyPS v1.0.1
309+ case Constants . MamlNameTag :
310+ case "dev:name" :
311+ typeName = subTreeReader . ReadElementContentAsString ( ) ;
312+ continue ;
313+ case Constants . MamlParaTag :
314+ typeDescription . AppendLine ( subTreeReader . ReadElementContentAsString ( ) . Trim ( ) )
315+ . AppendLine ( ) ;
316+ continue ;
317+ }
318+ }
319+
320+ if ( typeName is not null )
321+ {
322+ return new InputOutput ( typeName , typeDescription . ToString ( ) . Trim ( ) ) ;
323+ }
324+
325+ return null ;
326+ }
327+ finally
328+ {
329+ Constants . StringBuilderPool . Return ( typeDescription ) ;
330+ }
331+ }
332+
291333 private List < InputOutput > ReadInput ( XmlReader reader )
292334 {
293335 List < InputOutput > inputItem = new ( ) ;
@@ -298,24 +340,11 @@ private List<InputOutput> ReadInput(XmlReader reader)
298340 {
299341 do
300342 {
301- string ? typeName = null ;
302- string ? typeDescription = null ;
303-
304- if ( reader . ReadToFollowing ( Constants . MamlNameTag ) )
305- {
306- typeName = reader . ReadElementContentAsString ( ) ;
307- }
308-
309- if ( reader . ReadToFollowing ( Constants . MamlParaTag ) )
343+ var input = ReadInputOutput ( reader . ReadSubtree ( ) ) ;
344+ if ( input is not null )
310345 {
311- typeDescription = reader . ReadElementContentAsString ( ) ;
346+ inputItem . Add ( input ) ;
312347 }
313-
314- if ( typeName is not null && typeDescription is not null )
315- {
316- inputItem . Add ( new InputOutput ( typeName , typeDescription ) ) ;
317- }
318-
319348 } while ( reader . ReadToNextSibling ( Constants . MamlCommandInputTypeTag ) ) ;
320349 }
321350 }
@@ -333,24 +362,11 @@ private List<InputOutput> ReadOutput(XmlReader reader)
333362 {
334363 do
335364 {
336- string ? typeName = null ;
337- string ? typeDescription = null ;
338-
339- if ( reader . ReadToFollowing ( Constants . MamlNameTag ) )
340- {
341- typeName = reader . ReadElementContentAsString ( ) ;
342- }
343-
344- if ( reader . ReadToFollowing ( Constants . MamlParaTag ) )
365+ var output = ReadInputOutput ( reader . ReadSubtree ( ) ) ;
366+ if ( output is not null )
345367 {
346- typeDescription = reader . ReadElementContentAsString ( ) ;
368+ outputItem . Add ( output ) ;
347369 }
348-
349- if ( typeName is not null && typeDescription is not null )
350- {
351- outputItem . Add ( new InputOutput ( typeName , typeDescription ) ) ;
352- }
353-
354370 } while ( reader . ReadToNextSibling ( Constants . MamlCommandReturnValueTag ) ) ;
355371 }
356372 }
0 commit comments