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

[IgnorePropertyType] doesn't work as expected #19

Open
tatevmkrtchyan opened this issue Sep 19, 2023 · 3 comments
Open

[IgnorePropertyType] doesn't work as expected #19

tatevmkrtchyan opened this issue Sep 19, 2023 · 3 comments
Labels
state/needs-more-info type/question We have a question of some kind umbraco/v12 Issues and tasks related to Umbraco 12.

Comments

@tatevmkrtchyan
Copy link

I tried to use the Limbo.Umbraco.ModelsBuilder IgnorePropertyType, I created a separate class with the same name as the one generated in the same namespace and added IgnorePropertyType attribute with the field names which ones should be ignored but it doesn't work.
Should I do anything else?
I need to add Generation Rules for Model Builder in Umbraco 12 Application?

@abjerner
Copy link
Member

Hi @tatevmkrtchyan

Could you share some examples of your code? In case there is a bug in the package, could you specify exact versions of Umbraco and this package?

Anyways - it seems to work fine when I test, but the attribute is case sensitive - meaning you have the specify the property alias, not the property name. IIRC this aligns with what the old models builder for Umbraco 8 did, but one could argue that it should be case insensitive - hence #17.

Models with inheritance or compositions can also be a bit tricky, so if a property is inherited, you need to add the attribute to the model that declares the property.

Hope that makes sense 😉

@abjerner abjerner added type/question We have a question of some kind umbraco/v12 Issues and tasks related to Umbraco 12. state/needs-more-info labels Sep 21, 2023
@tatevmkrtchyan
Copy link
Author

Hi @abjerner,

Thank you for your response, in my application

  • Umbraco.Cms version is 12.0.1,
  • Limbo.Umbraco.ModelsBuilder version is 2.0.4

I am using those configs for model builder
"ModelsBuilder": {
"ModelsMode": "Nothing",
"FlagOutOfDateModels": true,
"AcceptUnsafeModelsDirectory": true,
"ModelsDirectory": "~/../Models/Generated/"
}

In Models.Generated namespace I added the generation rules in this way:

using Limbo.Umbraco.ModelsBuilder.Attributes;

namespace Models.Generated
{
[IgnorePropertyType("allowedGroup")]
public partial class PersonalLink
{
}

[IgnorePropertyType("image")]
[IgnorePropertyType("searchBar")]
public partial class ArticleOverview
{
}

[IgnorePropertyType("allowedGroups")]
public partial class WebComponent
{
}

[IgnorePropertyType("buttons")]
public partial class NotificationWebComponent
{
}
...

}

The models are getting generated in the subfolders of /Models/Generated/ folder and with those namespaces:
Umbraco.Cms.Web.Common.PublishedModels.Elements
Umbraco.Cms.Web.Common.PublishedModels.Compositions
Umbraco.Cms.Web.Common.PublishedModels.Content.Compositions, etc.

Without ignoring any property.

I also tried to write the generation rules in those two namespaces
Models.Generated.Elements
and
Umbraco.Cms.Web.Common.PublishedModels.Elements
Again I didn't get the expected result.

I can provide more details if needed, please let me know what else I should do to fix the issue.

Best regards,
Tate

@abjerner
Copy link
Member

Hi @tatevmkrtchyan

Can you share some examples from the generated partials? Of possibly how the content types look in the backoffice?

From what I can tell, you're using the attributes correctly. But like mentioned earlier, there could be things like compositions that come into play as well, but I can't really see whether that is the case from the provided information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state/needs-more-info type/question We have a question of some kind umbraco/v12 Issues and tasks related to Umbraco 12.
Projects
None yet
Development

No branches or pull requests

2 participants