Barkley, Chris wrote: >With this method for validating Int32 you lose one of the validators >features and that is setting a defined range for the integer. Is it possible >to use both? > > Good point. We should use both. Then I guess its just booleanValidator we don't need.
Ian >-----Original Message----- >From: Ian MacLean [mailto:[EMAIL PROTECTED]] >Sent: Monday, September 30, 2002 2:20 PM >To: Scott Hernandez >Cc: 'Barkley, Chris'; [EMAIL PROTECTED] >Subject: Re: [nant-dev] Adding Validators > > >I think some of this came out when InitializeAttributes was originally >rewritten. As it stands we only have BooleanValidator and >Int32Validator. In fact this line of code > paramaters[0] = Convert.ChangeType(attrValue, propertyInfo.PropertyType); > >will throw an exception if attrValue cannont safely be converted to >PropertyType. So for bool it must be 'true' or 'false'. This is not to >say we shouldn't fix it, only that we don't actually need validators for >Bool or Int32 and thats why this hasn't been found earlier. > >Ian > > > > >>I would call this feature missing a bug. It seems like we need to add >>some unit tests to check this so more features don't disappear. >> >>I looked in an old snapshot of nant (circa may 17th) and there is >>validation related code commented out there. It must have been removed >> >> >>from the file sometime after that. The CVS history is probably gone > > >>because of all the cvs changes done recently with the directly re-org, >>otherwise we might be able to see comments about why. >> >>I've included the interesting and removed code below. >> >>At the top of Element.InitializeAttribute >> >>ValidateAttributes(elementNode); >> >>/* >> See InitializeAttributes for details about these functions and >>why >> they are commentted out for now. >> >> protected virtual void ValidateAttribute(string attributeName) { >> Type currentType = GetType(); >> while (currentType != typeof(object)) { >> // iterate over each property looking for BuildAttribute >>attributes >> PropertyInfo[] propertyInfoArray = >>currentType.GetProperties(BindingFlags.Public|BindingFlags.Instance); >> foreach (PropertyInfo propertyInfo in propertyInfoArray >>) { >> // get the BuildAttribute attribute >> BuildAttributeAttribute buildAttribute = >>(BuildAttributeAttribute) >> Attribute.GetCustomAttribute(propertyInfo, >>typeof(BuildAttributeAttribute)); >> >> if (buildAttribute != null && buildAttribute.Name == >>attributeName) { >> // found a handler for this attribute >> return; >> } >> } >> >> // try looking in the super class for BuildAttribute >>attributes >> currentType = currentType.BaseType; >> } >> >> // If we haven't found a BuildAttribute then the attribute >>is unknown >> // unless this is a special case and the class forgot to >>override this >> // method and provide a check for it. >> throw new BuildException(String.Format("Unknown attribute >>'{0}'", attributeName), Location); >> } >> >> protected virtual void ValidateAttributes(XmlNode elementNode) { >> foreach (XmlNode attributeNode in elementNode.Attributes) { >> ValidateAttribute(attributeNode.Name); >> } >> } >>*/ >> >> >> >> >> >> >>------------------------------------------------------- >>This sf.net email is sponsored by:ThinkGeek >>Welcome to geek heaven. >>http://thinkgeek.com/sf >>_______________________________________________ >>Nant-developers mailing list >>[EMAIL PROTECTED] >>https://lists.sourceforge.net/lists/listinfo/nant-developers >> >> >> >> >> >> > > > ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Nant-developers mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/nant-developers