JustCode display bad warning: This cast is not required

2 posts, 1 answers
  1. Michał
    Michał avatar
    6 posts
    Member since:
    Apr 2009

    Posted 02 May 2011 Link to this post

    Hello,

    JustCode display bad warning that cast is not required if I try to cast object type to dynamic.
    Example:
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
    public class PositiveRequiredAttribute : RequiredAttribute
    {
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            ValidationResult result = ValidationResult.Success;
            try
            {
                if ((dynamic)value <= 0) // here JustCode display warning
                {
                    result = new ValidationResult(this.FormatErrorMessage(validationContext.DisplayName), new string[] { validationContext.MemberName });
                }
            }
            catch
            {
                result = new ValidationResult(this.FormatErrorMessage(validationContext.DisplayName), new string[] { validationContext.MemberName });
            }
            return result;
        }
    }

    PS.
    I tried to post bug report by Public Issue Tracker but it redirect me to this page:
    http://www.telerik.com/account/support-tickets.aspx

    Regards,
    Michał Zalewski
  2. Answer
    Kaloyan
    Admin
    Kaloyan avatar
    82 posts

    Posted 13 May 2011 Link to this post

    Hi Michał,

    Yeah, that's a good-code-yellow condition you got there. I'll add it to our backlog for a future fix. You get some telerik points for the observation. Stay tuned for an update on the matter.

    All the best,
    Kaloyan
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
Back to Top