Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented property keeps being generated #244

Open
skartknet opened this issue Oct 11, 2020 · 6 comments
Open

Implemented property keeps being generated #244

skartknet opened this issue Oct 11, 2020 · 6 comments

Comments

@skartknet
Copy link

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.

@jvtroyen
Copy link

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.

@skartknet
Copy link
Author

Hey,

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

@skartknet
Copy link
Author

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?

@lindeberg
Copy link

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" />

@nicklastromb
Copy link

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
Copy link

witje commented Dec 15, 2020

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants