Stable Release Recommendation?

Topics: Developer Forum
Dec 29, 2008 at 10:18 AM
Hi there

The framework looks very promising, but with the latest release being of April and lots of activity on the source, especially in the split spike, I'm wondering which version to take. I tried the latest builds, but getting initialization exceptions doing just the standards stuff. Can you recommend a specific build that runs rather stable?

Cheers,
Philipp


Sample exception: I'm getting the exception below as soon as I decorate the third property with a RangeRule. Two properties work, the third one, no matter what range I Enter: boom.

public interface IPlatform
{
    [RangeRule(1, 10)]
    int PlatformNumber { get; set; }

    [RangeRule(-999.999, 999.999)]
    double StartPosition { get; set; }

    [RangeRule(0.1, 99.99)]
    double EndPosition { get; set; }
}



failed: System.InvalidCastException: Unable to cast object of type 'ValidationFramework.Validators.RequiredValidator`1[System.String]' to type 'ValidationFramework.Validators.LengthValidator'.
    M:\Downloads\ValidationFramework-45201\SplitSpike\ValidationFramework\Validators\Length\LengthValidator.cs(67,0): at ValidationFramework.Validators.LengthValidator.IsEquivalent(IValidator validator)
    M:\Downloads\ValidationFramework-45201\SplitSpike\ValidationFramework\Validators\Length\LengthStringValidator.cs(81,0): at ValidationFramework.Validators.LengthStringValidator.IsEquivalent(IValidator validator)
    M:\Downloads\ValidationFramework-45201\SplitSpike\ValidationFramework\Rule.cs(144,0): at ValidationFramework.Rule.IsEquivalent(Rule rule)
    M:\Downloads\ValidationFramework-45201\SplitSpike\ValidationFramework\Reflection\RuleCollection.cs(133,0): at ValidationFramework.Reflection.RuleCollection.AreDuplicates(Type ruleToTestType, Rule ruleToTest, Rule existingRule)
    M:\Downloads\ValidationFramework-45201\SplitSpike\ValidationFramework\Reflection\RuleCollection.cs(121,0): at ValidationFramework.Reflection.RuleCollection.<>c__DisplayClass1.<IsDuplicate>b__0(Rule x)
    at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
    M:\Downloads\ValidationFramework-45201\SplitSpike\ValidationFramework\Reflection\RuleCollection.cs(121,0): at ValidationFramework.Reflection.RuleCollection.IsDuplicate(Rule rule)
    M:\Downloads\ValidationFramework-45201\SplitSpike\ValidationFramework\Reflection\RuleCollection.cs(98,0): at ValidationFramework.Reflection.RuleCollection.CheckForDuplicate(Rule rule, String ruleSet)
    M:\Downloads\ValidationFramework-45201\SplitSpike\ValidationFramework\Reflection\RuleCollection.cs(54,0): at ValidationFramework.Reflection.RuleCollection.Add(Rule item)
    M:\Downloads\ValidationFramework-45201\SplitSpike\ValidationFramework\Reflection\RuleCollection.cs(68,0): at ValidationFramework.Reflection.RuleCollection.AddNew(Rule item)
    M:\Downloads\ValidationFramework-45201\SplitSpike\ValidationFramework\Reflection\InfoDescriptor.cs(136,0): at ValidationFramework.Reflection.InfoDescriptor.AddRule(Rule rule, RuleScope scope)
    M:\Downloads\ValidationFramework-45201\SplitSpike\ValidationFramework\Reflection\PropertyDescriptor.cs(79,0): at ValidationFramework.Reflection.PropertyDescriptor.AddRulesFromPropertyInfo(PropertyInfo propertyInfo)
    M:\Downloads\ValidationFramework-45201\SplitSpike\ValidationFramework\Reflection\TypeDescriptor.cs(77,0): at ValidationFramework.Reflection.TypeDescriptor.ProccessProperties(Type currentType)
    M:\Downloads\ValidationFramework-45201\SplitSpike\ValidationFramework\Reflection\TypeDescriptor.cs(46,0): at ValidationFramework.Reflection.TypeDescriptor..ctor(RuntimeTypeHandle runtimeTypeHandle)
    M:\Downloads\ValidationFramework-45201\SplitSpike\ValidationFramework\Reflection\TypeCache.cs(66,0): at ValidationFramework.Reflection.TypeCache.GetType(RuntimeTypeHandle runtimeTypeHandle)
    M:\Downloads\ValidationFramework-45201\SplitSpike\ValidationFramework\ValidationManagerFactory.cs(26,0): at ValidationFramework.ValidationManagerFactory.GetPropertyValidationManager(Object target)
    D:\Philipp\Repositories\Noser\Ramses\Workspace\Main\Source Code\Platform\Core\StationItems\StationItemBase.cs(227,0): at Siemens.Ramses.Platform.Core.StationItems.StationItemBase..ctor()
    D:\Philipp\Repositories\Noser\Ramses\Workspace\Main\Source Code\XData\XItems\XStationItem.cs(104,0): at Siemens.Ramses.XData.XItems.XStationItem..ctor(XElement element)
    D:\Philipp\Repositories\Noser\Ramses\Workspace\Main\Source Code\XData\XItems\XStation.cs(43,0): at Siemens.Ramses.XData.XItems.XStation..ctor(XElement element)
    D:\Philipp\Repositories\Noser\Ramses\Workspace\Main\Source Code\XData\XItems\XStation.cs(30,0): at Siemens.Ramses.XData.XItems.XStation..ctor(String stationId)
    D:\Philipp\Repositories\Noser\Ramses\Workspace\Main\Source Code\XData\XItems\XStationItemFactory.cs(26,0): at Siemens.Ramses.XData.XItems.XStationItemFactory.CreateStation(String stationId)
    D:\Philipp\Repositories\Noser\Ramses\Workspace\Main\Source Code\Test\XData Tests\_Station Items\XTrack Tests\Given_XTrack_When_Is_Created.cs(42,0): at Siemens.Ramses.XData.Testing._Station_Items.XTrack_Tests.Given_XTrack_When_Is_Created.Init()



Coordinator
Dec 29, 2008 at 2:04 PM
Edited Dec 29, 2008 at 2:06 PM
Philipp,

Its a function of time. The split branch was intended just for the splitting of Rule/Validator but became the place for work on all the features for the next release. The split branch is mostly feature complete, but there it still needs more testing and fleshing out. For example most built-in validators lack fluent configuration extensions. While the way they are written and used is not going to change, they still need to be implemented.

I'm working as fast as I can to get the VF to a stable pt for the next release. Its will definitely be a more feature complete release with a cleaner architecture to ease the learning curve for new comers. Help like this is very much appreciated. If you'd like to contribute patches/join the team this would also be welcomed.

Either way I will fix this error today if possible.

Happy new year,

Dane
Coordinator
Dec 29, 2008 at 2:46 PM
Philipp,

I just checked in some tests for the scenario you mentioned. I'm working the the ValidationASPMVCQuickStarts solution. Take a look at ValidationFramework.Tests -> RangeAttributeTests and ValidationFramework.Tests.Integration -> AttributeTests. It appears to work just fine.

Upon looking at your exact exception I noticed it seems like your code is trying to cast a requiredValidator to a lengthValidator. The framework shouldn't be doing anything with these when working with a rule that uses a range validator.

Do you have a rule that uses a length validator anywhere? I don't have integration tests for that validator yet. If you can post your code I'll write them.

Dane
Dec 29, 2008 at 6:04 PM
Edited Dec 29, 2008 at 6:06 PM
Dane,

First of all thank your very much for the quick reply - it's great to see you really are putting a lot of efforts into the project :-)

I do have a length validator, but in a different interface, that is a parent of the item that makes trouble. My hierarchy is the following:

Station -> Track -> Platform (all 1:n relations)

ITrack contained a single RangeRule, but this one's commented out since the same exception occurred there, too. IStation contains these two rules:

    [RangeRule(0, 999999)]
    int StationNumber { get; set; }

    [Required]
    [LengthStringRule(7, Minimum = 2)]
    string StationCode { get; set; }


and the root interface that is implemented by all my business objects contains this one here:

    [LengthStringRule(99, Minimum = 1)]
    string ItemName { get; set; }



Unfortunately, I was mainly testing and removed a lot of the validation attributes I added for testing after I could no longer run my application. I tried to reproduce everything, but it appears I forgot something as I can no longer reproduce the exception. I'm afraid that's all the info I can get you right now. However, my test was pretty vanilla, basically a few rules and the initialization code in the base class that contained the initialization code at the first line:

    protected StationItemBase()
    {
      //init validation
      ValidationManager = ValidationManagerFactory.GetPropertyValidationManager(this);
    }




As another hint: The third rule that "triggered" the exception was declared in IPlatform - a remote child of IStation. Judging from the stack trace, this exception occurs way before the first IPlatform instance is even created. Hope that helps at least a little - I'll get the latest build and repost as soon as I see something else.

Cheers,
Philipp

Dec 30, 2008 at 12:10 PM
Edited Dec 30, 2008 at 12:18 PM
Don't know whether this is related or not, but here's another test that crashes due to an exception in the framework (latest build as well as the previous one):

    M:\Downloads\ValidationFramework-45338\SplitSpike\ValidationFramework\Reflection\PropertyDescriptor.cs(33,0): at ValidationFramework.Reflection.PropertyDescriptor..ctor(TypeDescriptor typeDescriptor, PropertyInfo propertyInfo)
    M:\Downloads\ValidationFramework-45338\SplitSpike\ValidationFramework\Reflection\TypeDescriptor.cs(138,0): at ValidationFramework.Reflection.TypeDescriptor.ProcessBaseClassProperties(IDictionary`2 dictionary, Type currentType)
    M:\Downloads\ValidationFramework-45338\SplitSpike\ValidationFramework\Reflection\TypeDescriptor.cs(98,0): at ValidationFramework.Reflection.TypeDescriptor.ProccessProperties(Type currentType)
    M:\Downloads\ValidationFramework-45338\SplitSpike\ValidationFramework\Reflection\TypeDescriptor.cs(46,0): at ValidationFramework.Reflection.TypeDescriptor..ctor(RuntimeTypeHandle runtimeTypeHandle)
    M:\Downloads\ValidationFramework-45338\SplitSpike\ValidationFramework\Reflection\TypeCache.cs(66,0): at ValidationFramework.Reflection.TypeCache.GetType(RuntimeTypeHandle runtimeTypeHandle)
    M:\Downloads\ValidationFramework-45338\SplitSpike\ValidationFramework\ValidationManagerFactory.cs(26,0): at ValidationFramework.ValidationManagerFactory.GetPropertyValidationManager(Object target)
    D:\Philipp\Repositories\Noser\Ramses\Workspace\Main\Source Code\Platform\Core\StationItems\StationItemBase.cs(227,0): at Siemens.Ramses.Platform.Core.StationItems.StationItemBase..ctor()



Strange enough: I removed the validators in the common base classes and the error still occurs - for all tests on one of the child classes. This one, however, does not and did never contain any validation rules.


Cheers, Philipp
Coordinator
Dec 30, 2008 at 1:29 PM
I'll look into this asap. Hopefully by the end of the day. If not, tomorrow. Thanks for the feedback/help.
Jan 6, 2009 at 8:02 AM
Hi Dane

FYI, another exception, which happens if I invoke the ValidateAll method (my validation attributes are still disabled, though).

---> System.IndexOutOfRangeException: Index was outside the bounds of the array.

   at (Object , Object[] )
   at ValidationFramework.Reflection.PropertyDescriptor.GetValue(Object instance) in M:\Downloads\ValidationFramework-45338\SplitSpike\ValidationFramework\Reflection\PropertyDescriptor.cs:line 117
   at ValidationFramework.ValidationPolicy.Validate(Object parentValue, ValidationOptions options) in M:\Downloads\ValidationFramework-45338\SplitSpike\ValidationFramework\ValidationPolicy.cs:line 95
   at ValidationFramework.MemberValidationManager.ValidateMember(IValidationPolicy policy, Boolean throwException) in M:\Downloads\ValidationFramework-45338\SplitSpike\ValidationFramework\MemberValidationManager.cs:line 205
   at ValidationFramework.MemberValidationManager.ValidateAll() in M:\Downloads\ValidationFramework-45338\SplitSpike\ValidationFramework\MemberValidationManager.cs:line 239
   at XXX.Platform.Core.StationItems.StationItemBase.ValidateItem() in D:\Philipp\Repositories\Noser\Ramses\Workspace\Main\Source Code\Platform\Core\StationItems\StationItemBase.cs:line 480
   at XXX.Platform.Core.StationItems.StationItemBase.OnPropertyChanged(String propertyName) in D:\Philipp\Repositories\Noser\Ramses\Workspace\Main\Source Code\Platform\Core\StationItems\StationItemBase.cs:line 442
   at XXX.Platform.Core.StationItems.StationItemBase.set_ParentItem(IStationItem value) in D:\Philipp\Repositories\Noser\Ramses\Workspace\Main\Source Code\Platform\Core\StationItems\StationItemBase.cs:line 132


I need to start with the validation part, so using the Split Branch seems to be out of the equation. Would you recommend the 2.0.0.0 beta or a later release? Or should I rather switch to EntLib for the time being?

Cheers,
Philipp