limbo-works / Limbo.Umbraco.ModelsBuilder

Custom models builder for Umbraco.
MIT License
4 stars 3 forks source link

Nested Content Properties being generated with empty types #12

Closed hfloyd closed 2 years ago

hfloyd commented 2 years ago

Working on a migration today, and after generating the Models, I see a bunch of these build errors:

Error CS7003 Unexpected use of an unbound generic name

This is showing up for a bunch of generated model files which have a Nested Content Data Type. What is getting generated is something like this:

 [ImplementPropertyType("fAQs")]
  public new System.Collections.Generic.IEnumerable<> FAqs => this.Value<System.Collections.Generic.IEnumerable<>>("fAQs");

The issue is the missing type inside the <>: IEnumerable<>

It seems if the actual DocumentType cannot be identified, it should at least use something general like PublishedElementModel, so that it doesn't cause errors.

abjerner commented 2 years ago

Hi @hfloyd

I've missed this issue, but I'm looking into it now. I tried setting up an Umbraco 10.1 test site, and haven't been able to reproduce the issue.

I know this might have been for Umbraco 9, so what versions of Umbraco and this package are you on?

abjerner commented 2 years ago

I've now spent some time looking into this, as my colleague was experiencing this same issue (he was the one to pointed to this issue). Turns out is was a really simple yet stupid mistake in my code.

The issue only occurred with Nested Content properties with a single type configured, and when the model holding the property was in the same namespace as the item type. If these criteria were met, my logic would set the type name to an empty string.

This has now been fixed 😎

hfloyd commented 2 years ago

👏🏻