RuleDescription in 3.6 beta2

RuleDescription in 3.6 beta2

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


Killian35 posted on Tuesday, October 28, 2008

Hello,

I upgraded my project to 3.6 and noticed the RuleDescription property MethodName now returns a <RuleMethodName/PropertyName> format and it seems the property PropertyName tries to do the same thing, however, the value from PropertyName seems to have trimmed off the first letter. So in the Csla test ValidationTests.MergeBrokenRules the result is:
MethodName: RuleBroken/Test1
PropertyName: uleBroken/Test1

Now it's hard for me to belive that is the desired result from PropertyName ;)

Kelly

Killian35 replied on Tuesday, October 28, 2008

Hello again,

Also, I noticed that the BrokenRule.RuleName property returns a different format based on how you define your ValidationRules.AddRule call. For instance:

{
      ValidationRules.AddRule<BrokenRulesMergeRoot>(CustomValidate, DurationProperty);
      ValidationRules.AddRule(CustomValidate, "Duration");
     ...
}

    private static PropertyInfo<int> DurationProperty = RegisterProperty(new PropertyInfo<int>("Duration", "Duration"));
    public int Duration
    {
        get { return GetProperty(DurationProperty); }
        set { SetProperty(DurationProperty, value); }
    }

    private static bool CustomValidate(BrokenRulesMergeRoot target, RuleArgs args)
    {
        args.Description = "CustomValidate Broken";
        return false;
    }

    private static bool CustomValidate(object target, RuleArgs args)
    {
        args.Description = "CustomValidate Broken";
        return false;
    }



These lines of code were added to the BrokenRulesMergeRoot class in the Csla.Validation tests. Each broken rule name in the broken rules collection is different:

The rule that uses the string "Default" returns the following rule name: rule://root.Csla.Test.ValidationRules.BrokenRulesMergeRoot/CustomValidate/Duration

and the one that uses the DefaultProperty info returns this : rule://root.CustomValidate/Duration

The RuleDescription class doesn't handle the second rule name very well, so I hope this is a fixable bug.

Thanks,
Kelly

RockfordLhotka replied on Tuesday, October 28, 2008

Thank you for finding this - I'll add it to the bug list.

Copyright (c) Marimer LLC