RegisterProperty with lambdaExpression doesn't work as it used to work in Csla 3.6.2

RegisterProperty with lambdaExpression doesn't work as it used to work in Csla 3.6.2

Old forum URL: forums.lhotka.net/forums/t/7136.aspx


rfcdejong posted on Friday, June 19, 2009

It seems that the RegisterProperty has changed

When i look at the 3.6.1 version and compare it with 3.6.2 the following is differend:

protected static PropertyInfo<P> RegisterProperty<P>(Expression<Func<T, P>> propertyLambdaExpression, string friendlyName)

And 3.6.2

protected
static PropertyInfo<P> RegisterProperty<P>(Expression<Func<T, object>> propertyLambdaExpression, string friendlyName)

This results into All Property Registrations giving an error when registering without explicitly specified argument:

internal static PropertyInfo<AAND_TYPE_MENU> aandTypeMenuProperty = RegisterProperty(c => c.AandTypeMenu, "Type menu");

error CS0411: The type arguments for method 'Csla.BusinessBase<U4A.Ceedrie.Business.Infrastructure.Entities.Menu>.RegisterProperty<P>(System.Linq.Expressions.Expression<System.Func<U4A.Ceedrie.Business.Infrastructure.Entities.Menu,object>>, Csla.RelationshipTypes)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

rfcdejong replied on Friday, June 19, 2009

I found the change causing the compile errors.

Issue ID 314 "Consider a new overload of RegisterProperty to get compile checking on property names"
http://www.lhotka.net/cslabugs/edit_bug.aspx?id=314

As example for the ReadOnlyBase the differences are under:
http://www.lhotka.net/cslabugs/svn_diff.aspx?id=4716

Can this be reverted or added as overloads?

Anyway it should had been a "breaking change". Having 1000+ property registrations it's alot of work going to an upgrade. I ran into this issue because i'm analysing the impact of going to Silverlight, ofcourse i took the newest version 3.6.3.

PS: If it's really better to use "object" instead of "P" i don't really mind and we just spend a few hours changing those, but it isn't needed since our properties are always of the same type as the propertyinfo.

RockfordLhotka replied on Saturday, June 20, 2009

This change was made to address a direct issue - but I don't remember the specifics right now.

I am not adverse to adding it as an overload if that would work - why don't you try that idea and see if it works (with the same and different property/field types).

rfcdejong replied on Saturday, June 20, 2009

i'm not sure if they will work as overload, since i didn't try it.
Anyway using the generic as payload for the lambda expression is more strict and offered the posibility of leaving away a specific declaration. The object is just more flexibel and allows a differend type of registered propertyinfo on another property type.

It doesn't matter that much for us atm, we didn't released anything yet and a find and replace isn't hard.. And i love refactoring :)

Copyright (c) Marimer LLC