This is a migrated thread and some comments may be shown as answers.

JustCode display bad warning: This cast is not required

1 Answer 41 Views
Code Analysis
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michał
Top achievements
Rank 1
Michał asked on 03 May 2011, 12:23 AM
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

1 Answer, 1 is accepted

Sort by
0
Accepted
Kaloyan
Telerik team
answered on 13 May 2011, 01:18 PM
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
Tags
Code Analysis
Asked by
Michał
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Share this question
or