I added some validationrules like this:
ValidationRules.AddRule(Csla.Validation.CommonRules.MaxValue<decimal>,
new Csla.Validation.CommonRules.MaxValueRuleArgs<decimal>("GrossWeight", 99999.99m));
The code happily compiles and executes until I set the GrossWeight property. It then fails, with an exception with generic description like Unable to set property, that is hiding the real cause of the exception: throw ArgumentException(Resources.PrimitiveTypeRequired);
Why isn't decimal supported in the CommonRules class, seems easy enough?
Why is the real exception hidden, making med debug this for 30 minutes before I found out what was wrong?
Regards;
/jb
Not sure what is leading up to the exception during runtime, but the statement you've included does make me wonder if some kind of a Type.IsPrimitive condition is being evaluated (use of Resource.PrimitiveTypeRequired as the exception message).
If this is the case, then the condition will fail for System.Decimal (decimal) because it is not considered a primitive type. See if that helps.
As I recall the check for IsPrimitiveType did exist in an older implementation of this rule
But Rocky updated it in 2.1 to this:
Public Function MaxValue(Of T As IComparable)(ByVal target As Object, ByVal e As RuleArgs) As BooleanHowever, I did a quick test and found a problem with the use of DirectCast. I had a large Integer value that could not be DirectCast to a Decimal value. But CType of the same Integer value to Decimal worked fine.
So I think this is a bug in the latest version which needs to be fixed.
Joe
Copyright (c) Marimer LLC