modelsbuilder/ModelsBuilder.Original

Interface definition only generated when document type is in use

Opened this issue · 1 comments

Problem:
Interface definition is only generated when document type is used in the site.

Expected bahavior:
The interface definition should always be generated, along with the partial class itself, which is always being generated..

Details:
For a document type used as a composition, I am checking for the interface type in code. However, the interface is only generated when the document type is used as a composition by some other document type. When the composition document type is not used anywhere, the document type's class is still correctly auto-generated, but not the interface. This leads to compile-time errors depending on whether a document type is currently used by other document types, or not.

@dhymik This is entirely by design. The generated interface is there for compositions because multiple document types implement it. When a doctype is not used as a composition, it is singular and concrete. If you need an interface, you should create your own and make the document type implement it using a partial class definition.
This also goes for any non-generated interface you want to be able to identify or use your document types as.
There is absolutely no need for an interface for every document type in your solution.