From 80fd1b0a4d0b434d7877725e99aafd05236075f3 Mon Sep 17 00:00:00 2001 From: Michael Chart Date: Mon, 21 Oct 2019 11:39:48 +0100 Subject: [PATCH] Add XML comments to public members When XML documentation is enabled for the project, the CS1591 compiler warning means that any public members must have a comment to prevent a warning. There's also currently no way to disable this documentation requirement for generated code: https://github.com/dotnet/roslyn/issues/12702. This commit adds comments to the previously uncommented members of the generated models classes. --- src/Umbraco.ModelsBuilder/Building/TextBuilder.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.ModelsBuilder/Building/TextBuilder.cs b/src/Umbraco.ModelsBuilder/Building/TextBuilder.cs index 8318c996..54cd0456 100644 --- a/src/Umbraco.ModelsBuilder/Building/TextBuilder.cs +++ b/src/Umbraco.ModelsBuilder/Building/TextBuilder.cs @@ -195,16 +195,20 @@ private void WriteContentType(StringBuilder sb, TypeModel type) // as 'new' since parent has its own - or maybe not - disable warning sb.Append("\t\t// helpers\n"); sb.Append("#pragma warning disable 0109 // new is redundant\n"); + sb.AppendFormat("\t\t/// {0}\n", XmlCommentString("The alias of the model type.")); WriteGeneratedCodeAttribute(sb, "\t\t"); sb.AppendFormat("\t\tpublic new const string ModelTypeAlias = \"{0}\";\n", type.Alias); var itemType = type.IsElement ? TypeModel.ItemTypes.Content : type.ItemType; // fixme + sb.AppendFormat("\t\t/// {0}\n", XmlCommentString("The this model represents.")); WriteGeneratedCodeAttribute(sb, "\t\t"); sb.AppendFormat("\t\tpublic new const PublishedItemType ModelItemType = PublishedItemType.{0};\n", itemType); + sb.AppendFormat("\t\t/// {0}\n", XmlCommentString("Gets the of the model type.")); WriteGeneratedCodeAttribute(sb, "\t\t"); sb.Append("\t\tpublic new static IPublishedContentType GetModelContentType()\n"); sb.Append("\t\t\t=> PublishedModelUtility.GetModelContentType(ModelItemType, ModelTypeAlias);\n"); + sb.AppendFormat("\t\t/// {0}\n", XmlCommentString("Gets the for a model property based on the provided expression.")); WriteGeneratedCodeAttribute(sb, "\t\t"); sb.AppendFormat("\t\tpublic static IPublishedPropertyType GetModelPropertyType(Expression> selector)\n", type.ClrName); @@ -213,7 +217,7 @@ private void WriteContentType(StringBuilder sb, TypeModel type) // write the ctor if (!type.HasCtor) - sb.AppendFormat("\t\t// ctor\n\t\tpublic {0}(IPublished{1} content)\n\t\t\t: base(content)\n\t\t{{ }}\n\n", + sb.AppendFormat("\t\t// ctor\n\t\t/// \n\t\tpublic {0}(IPublished{1} content)\n\t\t\t: base(content)\n\t\t{{ }}\n\n", type.ClrName, type.IsElement ? "Element" : "Content"); // write the properties