[IgnorePropertyType] doesn't work as expected
tatevmkrtchyan opened this issue · 3 comments
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?
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 😉
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
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.