How to specify GUID of Delphi interface in Enterprise Architect?
I am using Enterprise Architect's code generation feature to export my models to Delphi code. Is there a way to specify front-end GUIDs in EA so that the interfaces are fully defined in the output code?
Example:
ILogger = interface procedure Log(AMessage: ILoggerMessage); end;
it should be
ILogger = interface ['{16B77CF4-4219-412D-B1F3-20E29E2E9D9E}'] procedure Log(AMessage: ILoggerMessage); end;
source to share
You should add to the ILogger TaggedValue attribute a value containing the GUID in a form Delphi likes:
Attribute=['{16B77CF4-4219-412D-B1F3-20E29E2E9D9E}']
then you have to change your code templates class class and add
%classTag:"Attribute"%
as the second line (should come after the% if elemType == "Interface"%) EA should now correctly generate the code with the GUID. EA is importing it well, but not generating it properly.
This is a quick fix for interfaces, but I haven't programmed in Delphi for a long time, so I'm not sure if classes can have such attributes too, so the solution is limited to interfaces, for now :).
source to share
Not. Delphi doesn't know if you need a GUID or not, since not all interfaces need to have one. (Interfaces that are not designed for COM and, for example, do not implement IDispatch.) The IDE cannot read your mind (yet - maybe there is hope for the future) and cannot know what type of interface you are using when scheduling creation.
source to share