You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which exact Umbraco version are you using? For example: 9.0.1 - don't just write v9
9.1.2
Bug summary
When I create a composition (eg. for error handling) an interface is not added to the generated model by the models builder.
Composition: Generated code:
However, if I now create a document type and compose from this error handling composition, the interface is added to the generated code. Document type: Generated code:
This is a problem for code which is dependent on this interface - both other classes using the interface, but also when it comes to tests mocking with the interface - since a solution will not build if the composition is removed from the document type again. I've read this documentation (https://our.umbraco.com/Documentation/Reference/Templating/Modelsbuilder/Introduction), but I can't see whether or not this behavior is a feature or a bug - it seems weird to me though that the interface is not just added per default when a composition is created.
Create a composition (with some properties), eg. 'TestComposition'
Let models builder run
Refer to the interface 'ITestComposition' in the code from another class or test
See expected/actual result here.
The following steps will fix the issue:
4. Create document type, eg. 'TestDocumentType'
5. Add 'TestComposition' to compositions in 'TestDocumentType'
6. Let models builder run
Issue will happen again if 'TestComposition' is removed from compositions in all document types.
Expected result / actual result
Expected result:
Creating a composition in back office and running models builder will generate code containing a partial interface for the composition as well as a partial class implementing this (and other) interface(s). This interface can then be used other places in code.
Actual result:
Interface is not created and can therefore not be used.
The text was updated successfully, but these errors were encountered:
Hi @mariusAppstract - I just tested these steps in v8.8 and indeed we get the same behavior here. I assume if the element is not used in a composition it could be used in nested content for example, at which point it's not being generated as an interface either.
I am sure this is inconvenient! However, this is how it's been working for as long as I can remember, so I would assume people have found workarounds or other ideas to deal with your scenario. I would recommend you ask around on the forum or do a search, I haven't looked myself, so not sure.
Of the top of my head I seem to remember there's ways to manipulate how models get generated but I don't have
Currently we have no plans to make changes to how the built-in ModelsBuilder works. The external ModelsBuilder package looks like it's looking for active maintainers though, maybe you can team up with them if you're craving some additional features?
Which exact Umbraco version are you using? For example: 9.0.1 - don't just write v9
9.1.2
Bug summary
When I create a composition (eg. for error handling) an interface is not added to the generated model by the models builder.
Composition:
![image](https://user-images.githubusercontent.com/97677864/149337777-80c6ab64-2246-4245-90dc-c391321d8c25.png)
![image](https://user-images.githubusercontent.com/97677864/149338158-349f2b94-b202-4c36-becf-b7a76a7a8eab.png)
Generated code:
However, if I now create a document type and compose from this error handling composition, the interface is added to the generated code.
![image](https://user-images.githubusercontent.com/97677864/149338455-7fd706fd-3968-4bae-8dc1-b02595015a5f.png)
![image](https://user-images.githubusercontent.com/97677864/149338547-5a801bac-c5f1-4182-8caa-96544c967a73.png)
Document type:
Generated code:
This is a problem for code which is dependent on this interface - both other classes using the interface, but also when it comes to tests mocking with the interface - since a solution will not build if the composition is removed from the document type again. I've read this documentation (https://our.umbraco.com/Documentation/Reference/Templating/Modelsbuilder/Introduction), but I can't see whether or not this behavior is a feature or a bug - it seems weird to me though that the interface is not just added per default when a composition is created.
Specifics
Models builder version:
Umbraco.ModelsBuilder.Embedded v9.1.2+915f1cb34c3c63d3c88ebced61dd35d80255408c
Models builder mode:
![image](https://user-images.githubusercontent.com/97677864/149342013-db364724-dc52-4d89-ab39-57bbf0cac9f1.png)
Steps to reproduce
Steps to reproduce issue:
See expected/actual result here.
The following steps will fix the issue:
4. Create document type, eg. 'TestDocumentType'
5. Add 'TestComposition' to compositions in 'TestDocumentType'
6. Let models builder run
Issue will happen again if 'TestComposition' is removed from compositions in all document types.
Expected result / actual result
Expected result:
Creating a composition in back office and running models builder will generate code containing a partial interface for the composition as well as a partial class implementing this (and other) interface(s). This interface can then be used other places in code.
Actual result:
Interface is not created and can therefore not be used.
The text was updated successfully, but these errors were encountered: