Description
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.
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.
Specifics
Models builder version:
Umbraco.ModelsBuilder.Embedded v9.1.2+915f1cb34c3c63d3c88ebced61dd35d80255408c
Steps to reproduce
Steps to reproduce issue:
- 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.