JSobell wrote:
I have a Net6 project that I'm using with LLBLGen. I generate a DLL containing Enum versions of all of the lookup status tables in the DB, and I obviously need to use those Enums in both the business logic and the Designer.
So I have a few questions:
- What are the rules regarding creation of DLLs to provide Enums for use in the designer? Does the DLL have to be a .Net Framework v4.x, or can it be .Net standard or Net6 for the designer to recognise them?
.net framework, .netstandard 2.0 (or lower) work. .NET Core 3.x/.NET 5+ doesn't, as it's not compatible with .net framework.
- is a typeimports entry required for every Enum in my library, or can the designer detect the Enums through reflection on the DLL?
An entry is required. It was never anticipated that there would be hundreds of enums to import, and doing a reflection over a dll for all enums is potentially problematic, as it would import all enums, also the ones you don't want; this might not sound problematic at first, but every imported enum is assigned a type shortcut, which will make modeling with all the types problematic. So it's explicit at the moment.
- since I appear to have to specify the 'additional type converter folder', shouldn't the designer let me choose a relative folder? When the code is checked out on different machines the folder will be different, so relative to the llblgenproj file is the logical location. At the moment it appears that if I add a relative path it is relative to the Designer EXE location?
There are two additional type converter folders: one in the Preferences and one in the Project settings (Entity Model -> General). The one in preferences is an explicit path, as there's no project to base the relative path on. The one in Project settings is relative to the path if it's prefixed with .\
. E.g. in our unit test projects we specify .\
to have the typeimport files next to the llblgenproj files.
Perhaps it would be better if custom types for Enum fields were detectable via an attribute, in the same way TypeConverters are recognised by class signature. The current system seems quite complicated, and I'd like to see a convention based option to avoid all the manual plumbing.
The attribute has to be defined somewhere, so that would mean a reference to the assembly the attribute is defined in in your enum dll. This is problematic as which attribute to pick? Even a BCL attribute is problematic, as a .net standard one is different from a .net framework one.
I agree it's cumbersome tho, but it is a cumbersome process regardless, the types to import have to be defined somewhere. One of the alternatives we tried was indeed simply importing everything and then let the user define type shortcuts, but this was a tedious process as well. I think the 'solution' might be somewhere else, namely why the enums are defined in the first place, but that has a bigger scope (see your other thread) and also a bigger impact (which likely won't be followed by many).
The type import files are now pretty strict. We could look into filters and wildcards. E.g. *
for typename means all enum types, filters for namespaces (e.g. MyEnumNamespace
, which means all enums inside that namespace... ).