Suggestion - Overload for DotNetTemplateEngine.GetUserCodeRegion

Posts   
 
    
Posts: 6
Joined: 07-Sep-2006
# Posted on: 19-Sep-2006 23:36:32   

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.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 20-Sep-2006 09:26:53   

Good suggestion.

To solve it for now, you could opt for a file you load which contains the guids per class to generate, so you can restore the original guids when you regen a class.

I'll add your overload.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 20-Sep-2006 11:13:43   

Added in next build. If you specify an empty string or null, you'll get the original region, otherwise the text specified will be added to the region, prefixed with a tab and ended with a CRLF.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 6
Joined: 07-Sep-2006
# Posted on: 20-Sep-2006 22:20:28   

That will work fine!

Thanks so much.