modelsbuilder/ModelsBuilder.Original

Implemented property keeps being generated

Opened this issue · 6 comments

I have a Post model that is Umbraco-generated. I have created a partial Post class that implements a property like so:

        public partial class Post
	{
		///<summary>
		/// OgImage: If the image is left empty, the page's "feature image" will be used.
		///</summary>	
		[ImplementPropertyType("ogImage")]
		public IPublishedContent OgImage
		{
			get
			{
				if (OpenGraph.GetOgImage(this) is null)
				{
					return MainImage;
				}

				return OpenGraph.GetOgImage(this);
			}
		}
	}

That 'ogImage' property is still being generated by Umbraco in the other partial class as:

///<summary>
/// OgImage: If the image is left empty, the page's "feature image" will be used.
///</summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder", "8.1.6")]
[ImplementPropertyType("ogImage")]
public IPublishedContent OgImage => OpenGraph.GetOgImage(this);

I'm running Umbraco 8.6 and Models Builder 8.1.6. My Models Builder configuration is LiveAppData.

Hi,

just some sanity-checking. Where did you put your partial implementation? Did you match the namespace?
I usually put my partial classes next to the builder.cs (under which the generated code is placed), making sure the namespace matches.
I've also noticed that I need to build the project containing the partial classes at least once, before calling the API to re-generate. I could be mistaken about this last one.

Hey,

Yes, both classes are in the same namespace and in the same folder.

I think the issue might happen because the implemented property is not an actual property of the doctype but it uses a mixin from another class called OpenGraph? Is it possible that because the property needs to be generated to comply with the IOpenGraph interface it ignores the 'ImplementPropertyType' attribute?

Happens to me too. Both for ImplementPropertyType and IgnorePropertyType.

Could be my settings? Using:

    <add key="Umbraco.ModelsBuilder.Enable" value="true" />
    <add key="Umbraco.ModelsBuilder.ModelsMode" value="AppData" />
    <add key="Umbraco.ModelsBuilder.ModelsNamespace" value="Umbraco.Web.PublishedModels" />
    <add key="Umbraco.ModelsBuilder.ModelsDirectory" value="~/../ProjectName.PublishedModels/Models" />
    <add key="Umbraco.ModelsBuilder.AcceptUnsafeModelsDirectory" value="true" />

Happens to me too. Both for ImplementPropertyType and IgnorePropertyType.

Could be my settings? Using:

    <add key="Umbraco.ModelsBuilder.Enable" value="true" />
    <add key="Umbraco.ModelsBuilder.ModelsMode" value="AppData" />
    <add key="Umbraco.ModelsBuilder.ModelsNamespace" value="Umbraco.Web.PublishedModels" />
    <add key="Umbraco.ModelsBuilder.ModelsDirectory" value="~/../ProjectName.PublishedModels/Models" />
    <add key="Umbraco.ModelsBuilder.AcceptUnsafeModelsDirectory" value="true" />

Experiencing these issues also with the same configuration setup.

witje commented

Happens to me too. Both for ImplementPropertyType and IgnorePropertyType.
Could be my settings? Using:

    <add key="Umbraco.ModelsBuilder.Enable" value="true" />
    <add key="Umbraco.ModelsBuilder.ModelsMode" value="AppData" />
    <add key="Umbraco.ModelsBuilder.ModelsNamespace" value="Umbraco.Web.PublishedModels" />
    <add key="Umbraco.ModelsBuilder.ModelsDirectory" value="~/../ProjectName.PublishedModels/Models" />
    <add key="Umbraco.ModelsBuilder.AcceptUnsafeModelsDirectory" value="true" />

Experiencing these issues also with the same configuration setup.

It happens also to me in the same scenario as above (Looks like it occurs when 'ModelsDirectory' is configured with a directory outside the root)

Edit:
After installing and using Umbraco.ModelsBuilder.Api, the properties aren't regenerated anymore :)