AnantLabs / codesmith

Automatically exported from code.google.com/p/codesmith
1 stars 0 forks source link

CSLA TEMPLATES - PROPERTY INCORRECTLY NAMED AND INCONSISTENCY BETWEEN .Generated AND .DataAccess #651

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Moving from : CodeSmith: v6.0.0, CSLA Templates: v3.0.3.2368
To      : CodeSmith: v6.0.3, CSLA Templates: v4.0.0.0

I have two tables, Project and ProjectStatus.  Since moving to the new 
templates I am getting compilation errors.  For this example project I am only 
adding one output which is 
ProjectStatus as EditableRoot.  

When I generate I can see that generated property for associated Projects is 
being generated differently.  In both the Generated and DataAccess class the 
name of the property is now ProjectStatuses instead of Projects.

I now add another output which is Project as ReadOnlyList (and also 
ReadOnlyChild).  When I generate the type of the property now changes from 
ProjectList to ProjectInfoList in the Generated class but does not change in 
the DataAccess class causing a compilation error.

If I now add a NameValueList for ProjectStatus the property changes back from 
ProjectInfoList to ProjectList.

What version of the product are you using?
v6.0.3

Please provide any additional information below.
See the attached database schema and project.

Original issue reported on code.google.com by ianmcdid...@gmail.com on 18 May 2012 at 11:10

Attachments:

GoogleCodeExporter commented 9 years ago
Hello,

Thanks for reporting this, I'll take a look and let you know what I find.

Original comment by bniemyjski on 21 May 2012 at 8:45

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2684.

Fixed some inconsistent naming in the CSLA Templates (Commit 1 of 2).

Original comment by bniemyjski on 23 May 2012 at 6:35

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2686.

Fixed a bug where associations were getting a crazy names...
The new rules are as follows:
1. If the relationship is a ZeroOrOneToMany, OneToMany, ManyToMany then the 
Association's Name and Type name follow the rules specified via configuration 
(AssociationTypeNameSuffix and AssociationSuffix).
2. If the relationship is not a ZeroOrOneToMany, OneToMany, ManyToMany, then it 
is automatically made Singular!

Original comment by bniemyjski on 23 May 2012 at 7:26

GoogleCodeExporter commented 9 years ago
These issues have been fixed in the latest nightly build. If you run into any 
issues. Please let me know...

Original comment by bniemyjski on 23 May 2012 at 7:26

GoogleCodeExporter commented 9 years ago
Hi,

Thanks for your help so far.  I tried the latest build out on my real 
project.  There is one issue that has crept in me thinks.  I haven't had a 
proper look as yet - will try to do so tomorrow, but just flagging it up.

I have a ReadOnlyChild being generated for my table 'Account'.  The class 
name is AccountInfo.  BUT the synchronous factory methods in the .Generated 
class are returning Account.

This is my only instance of this in what is a reasonably large project.  Not 
sure what is making the Account table so special, but I assume it is the 
relationships that are causing this.  Once I have a bit more info I'll post 
it here.

Original comment by ianmcdid...@gmail.com on 23 May 2012 at 9:04

GoogleCodeExporter commented 9 years ago
I have found that adding a Switchable object for a table that already has a 
Read Only Child will cause this.  For example I add a ReadOnly child for table 
Project.  In the ProjectInfo.Generated class the synchronous factory methods 
return ProjectInfo.  If I now add a Switchable object for table Project and 
generate, the ProjectInfo class is affected.  It now returns Project instead of 
ProjectInfo.

Original comment by ianmcdid...@gmail.com on 28 May 2012 at 2:19

GoogleCodeExporter commented 9 years ago
Hello,

I'm not sure what we can do in this scenario, as we don't know which one should 
take precedence. If you are in a read-only business object then we could assume 
you want the  read only version. Could you add an updated csp for this.

Original comment by bniemyjski on 28 May 2012 at 4:21

GoogleCodeExporter commented 9 years ago
Hi,

Revised project attached that shows the issue.  There are two outputs for the 
Project table.  ReadOnly and Switchable.  If you look at the generated ReadOnly 
class you will see the factory methods return Project instead of ProjectInfo.  

Note that it is the factory methods that I'm talking about here, not the 
properties for associated entities.  Surely the factory methods should always 
return the same type as the class that contains them?

i.e. In Project they should return Project, in ProjectInfo they return 
ProjectInfo.

Original comment by ianmcdid...@gmail.com on 30 May 2012 at 10:40

Attachments:

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2701.

Fixed a bug where factory methods were getting an incorrect type name.

Original comment by bniemyjski on 31 May 2012 at 6:33

GoogleCodeExporter commented 9 years ago
These issues have been fixed in the latest nightly build. If you run into any 
issues. Please let me know...

Original comment by bniemyjski on 31 May 2012 at 6:34

GoogleCodeExporter commented 9 years ago
The factory methods change looks good.  But, sorry, I have spotted a problem to 
do with the original issue (associated child collection properties).

If I add outputs so that I have a ReadOnlyRoot for ProjectStatus and 
ReadOnlyList & ReadOnlyChild for Project, there is an issue in the 
ProjectStatusInfo.Generated class.

If look at the generated property for Projects it correctly returns a list of 
type ProjectInfoList.  But the code inside the property works with ProjectList. 
 i.e.

if(Code.ProjectList.Exists(criteria))
   LoadProperty(_projectsProperty, Code.ProjectList.GetByStatusId(ProjectStatusId));

I would expect the lists within the property to be the same type as the 
property returns.  (For this instance they should all be ProjectInfoList).

The attached project shows the problem.

Original comment by ianmcdid...@gmail.com on 31 May 2012 at 2:20

Attachments:

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2704.

Fixed a bug with association names inside of properties.

Original comment by bniemyjski on 31 May 2012 at 5:42

GoogleCodeExporter commented 9 years ago
Hello,

I fixed this issue. I did notice that the partial void 
OnChildInserting(ProjectStatus projectStatus, S are being generated with the 
wrong types. I can't fix that at this point in the release as it is a Massive 
change (and shouldn't effect to many people). If you can log it, I'll make sure 
its fixed in the next version of the templates.

Original comment by bniemyjski on 31 May 2012 at 5:43