-
Notifications
You must be signed in to change notification settings - Fork 23
Description
I have found what appears to be a bug, wherein XmlDoc2CmdletDoc will report "No XML doc comment found" for a parameter when the parameter's type is an array.
The following program generates the error
/// <summary>
/// <para type="description">Something!</para>
/// </summary>
public class Random
{
}
[Cmdlet(VerbsCommon.Get, "Fail")]
public class Class1 : PSCmdlet
{
/// <summary>
/// <para type="description">Hello?</para>
/// </summary>
[Parameter]
public Random[] Param { get; set; }
}I have found the issue appears to be caused by the Redgate Jolt library, specifically method AppendXDCFullTypeNameTo in Convert.cs on line 401.
private static StringBuilder AppendXDCFullTypeNameTo(StringBuilder builder, Type type)
{
if (type.IsGenericType) { type = type.GetGenericTypeDefinition(); }
return AppendNormalizedXDCTypeNameTo(builder, type);
}I believe this method should be modified to also check whether or not the type is an array, as follows
private static StringBuilder AppendXDCFullTypeNameTo(StringBuilder builder, Type type)
{
if (type.IsGenericType)
{
type = type.GetGenericTypeDefinition();
}
else if (type.IsArray)
{
type = type.GetElementType();
}
return AppendNormalizedXDCTypeNameTo(builder, type);
}A potential complexity with this however is that I can see on line 533 of Convert.cs there is a method ReduceToElementType which also appears to be capable of determining the underlying type of an array, however this method does not appear to be invoked by the method chain XmlDoc2CmdletDoc uses.
For reference, the following call stack shows the path to AppendXDCFullTypeNameTo when we need to parse an array.
Jolt.dll!Jolt.Convert.AppendXDCFullTypeNameTo(System.Text.StringBuilder builder, System.Type type) Line 409
Jolt.dll!Jolt.Convert.ToXmlDocCommentMember(System.Type type) Line 62
Jolt.dll!Jolt.XmlDocCommentReader.GetComments(System.Type type) Line 214
XmlDoc2CmdletDoc.Core.dll!XmlDoc2CmdletDoc.Core.Comments.JoltCommentReader.GetComments(System.Type type) Line 26
XmlDoc2CmdletDoc.Core.dll!XmlDoc2CmdletDoc.Core.Comments.LoggingCommentReader.GetComments(System.Type type) Line 31
XmlDoc2CmdletDoc.Core.dll!XmlDoc2CmdletDoc.Core.Comments.RewritingCommentReader.GetComments(System.Type type) Line 28
XmlDoc2CmdletDoc.Core.dll!XmlDoc2CmdletDoc.Core.Comments.CachingCommentReader.GetComments(System.Type type) Line 31
XmlDoc2CmdletDoc.Core.dll!XmlDoc2CmdletDoc.Core.Extensions.CommentReaderExtensions.GetTypeDescriptionElement(XmlDoc2CmdletDoc.Core.Comments.ICommentReader commentReader, System.Type type, XmlDoc2CmdletDoc.Core.ReportWarning reportWarning) Line 338
XmlDoc2CmdletDoc.Core.dll!XmlDoc2CmdletDoc.Core.Engine.GenerateTypeElement(XmlDoc2CmdletDoc.Core.Comments.ICommentReader commentReader, System.Type type, bool includeMamlDescription, XmlDoc2CmdletDoc.Core.ReportWarning reportWarning) Line 560
XmlDoc2CmdletDoc.Core.dll!XmlDoc2CmdletDoc.Core.Engine.GenerateParameterElement(XmlDoc2CmdletDoc.Core.Comments.ICommentReader commentReader, XmlDoc2CmdletDoc.Core.Domain.Parameter parameter, string parameterSetName, XmlDoc2CmdletDoc.Core.ReportWarning reportWarning) Line 387
XmlDoc2CmdletDoc.Core.dll!XmlDoc2CmdletDoc.Core.Engine.GenerateSyntaxItemElement(XmlDoc2CmdletDoc.Core.Comments.ICommentReader commentReader, XmlDoc2CmdletDoc.Core.Domain.Command command, string parameterSetName, XmlDoc2CmdletDoc.Core.ReportWarning reportWarning) Line 332
XmlDoc2CmdletDoc.Core.dll!XmlDoc2CmdletDoc.Core.Engine.GenerateSyntaxElement(XmlDoc2CmdletDoc.Core.Comments.ICommentReader commentReader, XmlDoc2CmdletDoc.Core.Domain.Command command, XmlDoc2CmdletDoc.Core.ReportWarning reportWarning) Line 310
XmlDoc2CmdletDoc.Core.dll!XmlDoc2CmdletDoc.Core.Engine.GenerateCommandElement(XmlDoc2CmdletDoc.Core.Comments.ICommentReader commentReader, XmlDoc2CmdletDoc.Core.Domain.Command command, XmlDoc2CmdletDoc.Core.ReportWarning reportWarning) Line 249
XmlDoc2CmdletDoc.Core.dll!XmlDoc2CmdletDoc.Core.Engine.GenerateHelpItemsElement(XmlDoc2CmdletDoc.Core.Comments.ICommentReader commentReader, System.Collections.Generic.IEnumerable<XmlDoc2CmdletDoc.Core.Domain.Command> commands, XmlDoc2CmdletDoc.Core.ReportWarning reportWarning) Line 235
XmlDoc2CmdletDoc.Core.dll!XmlDoc2CmdletDoc.Core.Engine.GenerateHelp(XmlDoc2CmdletDoc.Core.Options options) Line 57
XmlDoc2CmdletDoc.exe!XmlDoc2CmdletDoc.Program.Main(string[] args) Line 31While this appears to be an issue with the Jolt module used by XmlDoc2CmdletDoc, as Redgate's repo for it does not have an issues page, I am not familiar with what Jolt is typically used for, and @ChrisLambrou appears to be a major contributor to both projects, I am opening an issue here.
Arrays of builtin types do not generate this warning, however this is because XmlDoc2CmdletDoc filters out errors for types outside of the assembly being processed.
Any assistance on this matter would be greatly appreciated.
Regards,
lordmilko