Small difference between code generated from the designer and using the CLIGenerator

Posts   
 
    
twaindev avatar
twaindev
User
Posts: 178
Joined: 08-Oct-2007
# Posted on: 09-Mar-2018 00:25:21   

Using 5.3 (5.3.4) RTM

There is an additional blank line after every

// __LLBLGENPRO_USER_CODE_REGION_END

when the code is generated using CLIGenerator.

Or the line is omitted when generating code using the designer (I actually like the extra line).

Code generated using the designer:

namespace TestData.EntityClasses
{
    // __LLBLGENPRO_USER_CODE_REGION_START AdditionalNamespaces
    // __LLBLGENPRO_USER_CODE_REGION_END
    /// <summary>Entity class which represents the entity 'Address'.<br/><br/></summary>
    [Serializable]
    public partial class AddressEntity : CommonEntityBase
        // __LLBLGENPRO_USER_CODE_REGION_START AdditionalInterfaces
        // __LLBLGENPRO_USER_CODE_REGION_END    
    {
        #region Class Member Declarations
        private EntityCollection<SiteEntity> _sites;
        private CountryEntity _country;

        // __LLBLGENPRO_USER_CODE_REGION_START PrivateMembers
        // __LLBLGENPRO_USER_CODE_REGION_END
        #endregion


Code generated using CLIGenerator:

namespace TestData.EntityClasses
{
    // __LLBLGENPRO_USER_CODE_REGION_START AdditionalNamespaces
    // __LLBLGENPRO_USER_CODE_REGION_END
    
    /// <summary>Entity class which represents the entity 'Address'.<br/><br/></summary>
    [Serializable]
    public partial class AddressEntity : CommonEntityBase
        // __LLBLGENPRO_USER_CODE_REGION_START AdditionalInterfaces
        // __LLBLGENPRO_USER_CODE_REGION_END
            
    {
        #region Class Member Declarations
        private EntityCollection<SiteEntity> _sites;
        private CountryEntity _country;

        // __LLBLGENPRO_USER_CODE_REGION_START PrivateMembers
        // __LLBLGENPRO_USER_CODE_REGION_END
        
        #endregion

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 09-Mar-2018 11:38:08   

That's odd, considering they're using the same code smile

Will see if I can repro it.

Frans Bouma | Lead developer LLBLGen Pro
twaindev avatar
twaindev
User
Posts: 178
Joined: 08-Oct-2007
# Posted on: 09-Mar-2018 11:55:45   

I was also surprised when Git reported that all sources had changed.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 12-Mar-2018 10:57:30   

I can't reproduce it. Do you run the cligenerator with the same user account? If not, the preferences are different then, but even then, it's odd...

my generated code from the cli generator looks like:

    // __LLBLGENPRO_USER_CODE_REGION_START AdditionalNamespaces
    // __LLBLGENPRO_USER_CODE_REGION_END
    /// <summary>Entity class which represents the entity 'Order'.<br/><br/></summary>
    [Serializable]
    public partial class OrderEntity : CommonEntityBase
        // __LLBLGENPRO_USER_CODE_REGION_START AdditionalInterfaces
        // __LLBLGENPRO_USER_CODE_REGION_END    
    {
        #region Class Member Declarations

Do you use the 'old' command arguments or the new ones? (with both I can't reproduce it), is this for netstandard, or full .net ?

Frans Bouma | Lead developer LLBLGen Pro
twaindev avatar
twaindev
User
Posts: 178
Joined: 08-Oct-2007
# Posted on: 12-Mar-2018 11:21:38   

This is for full .net. With the same user account. From PowerShell.

I also see this for my test project (the one I uploaded earlier) with the command line:

& 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v5.3\CliGenerator.exe' .\TestData.llblgenproj 1

A screenshot with the differences is attached (left side is from the designer, right side from the cli).

Attachments
Filename File size Added on Approval
differences gui vs cli.png 137,169 12-Mar-2018 11:21.54 Approved
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 12-Mar-2018 13:48:03   

very odd, it indeed happens with this project. I can also repro it with a project of our own using the designer, but the project I use is a copy of the one we use for our unit tests which code is generated using the cligenerator and it is OK there.

So I wondered, if I re-generate it onto the same code again, and it is then OK again. So the initial code in an empty folder indeed contains the empty lines, every subsequential generations onto the same code base are OK (no empty lines)

This likely has to do with the regexp we use to find the regions. Initially the regions are empty, so the code in the template is emitted as-is. Next time, it finds the regions with the regexp (even if they're empty), so start/end marker plus contents are replacing the keywords for the region in the template. I think this makes a crlf be swallowed as such so there's 1 crlf less in the output.

I never noticed this as I looked at the code generated by the unit test project generator as that contains many situations (inheritance, m:n, 1:1 etc.) and that code is never 'new'.

It's clear in this output:


    public partial class CustomerEntity : CommonEntityBase
        // __LLBLGENPRO_USER_CODE_REGION_START AdditionalInterfaces
        // __LLBLGENPRO_USER_CODE_REGION_END    
<TAB>
    {

second time:


    public partial class CustomerEntity : CommonEntityBase
        // __LLBLGENPRO_USER_CODE_REGION_START AdditionalInterfaces
        // __LLBLGENPRO_USER_CODE_REGION_END    <TAB>
    {

so the <TAB> is still there (causing the empty line) but the CRLF after the marker isn't there, so the line moves up.

We'll see if the crlf can be added to the regexp, to see what that ends up with. Will be for v5.4 (so we can clean up the templates some more and get rid of the empty lines, sorry wink )

Frans Bouma | Lead developer LLBLGen Pro
twaindev avatar
twaindev
User
Posts: 178
Joined: 08-Oct-2007
# Posted on: 12-Mar-2018 15:03:28   

No problem.

I always use the CLI, but testing the datetime2 template I noticed this strange issue.