Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Umbraco.ModelsBuilder/Building/TextBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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/// <summary>{0}</summary>\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/// <summary>{0}</summary>\n", XmlCommentString("The <see cref=\"PublishedItemType\"/> this model represents."));
WriteGeneratedCodeAttribute(sb, "\t\t");
sb.AppendFormat("\t\tpublic new const PublishedItemType ModelItemType = PublishedItemType.{0};\n",
itemType);
sb.AppendFormat("\t\t/// <summary>{0}</summary>\n", XmlCommentString("Gets the <see cref=\"IPublishedContentType\"/> 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/// <summary>{0}</summary>\n", XmlCommentString("Gets the <see cref=\"IPublishedPropertyType\"/> for a model property based on the provided expression."));
WriteGeneratedCodeAttribute(sb, "\t\t");
sb.AppendFormat("\t\tpublic static IPublishedPropertyType GetModelPropertyType<TValue>(Expression<Func<{0}, TValue>> selector)\n",
type.ClrName);
Expand All @@ -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/// <inheritdoc />\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
Expand Down