I'd like to suggest an overload for DotNetTemplateEngine.GetUserCodeRegion which would take an extra string argument which would be the initial text of the user code region. This extra text would only be added if the user code region does not yet exist (as it currently works).
I'll explain my reason for this feature request.
I wrote templates to generate COM wrappers for all the entities, typed lists, and typed views. The problem is my COM interfaces and coclasses need a static GUID. Hence I use the user code region to hold the GUID attribute on my COM interface and coclass. For now I am manually adding the GUID to the generated files, but this gets a bit tedious.
I should probably write a program to parse/update all my generated interfaces/classes, but if the LPT template would allow this feature then I could just generate a GUID in the template code and put it in the generated file when the file is initially created.
For example the template code would look something like:
<%=DotNetTemplateEngine.GetUserCodeRegion("COMAttributes", "//", GenerateCOMGuidAttribute()) %>
<~
public string GenerateCOMGuidAttribute()
{
Guid guid = Guid.NewGuid();
return "[Guid(\"" + guid.ToString("D") + "\")]" + Environment.Newline;
}
~>
The generated code would then look like:
// __LLBLGENPRO_USER_CODE_REGION_START COMAttributes
[Guid("38C1B62A-78C9-4bdc-4271-B159A5AB34E6")]
// __LLBLGENPRO_USER_CODE_REGION_END
If I'm not being clear please let me know and I can explain further.
Thanks for taking the time to consider this enhancement.