Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CC0013 Should check for a common type and cast is necessary. #521

@paulomorgado

Description

@paulomorgado

Take this example:

    if (this.Url.IsLocalUrl(returnUrl))
    {
        return this.Redirect(returnUrl);
    }
    else
    {
        return this.RedirectToAction("Index");
    }

It is rewritten as:

return this.Url.IsLocalUrl(returnUrl) ? this.Redirect(returnUrl) : this.RedirectToAction("Index");

However, the return types are not the same and the compiler should assume that the expression has the value of the return type, but it doesn't.

    return this.Url.IsLocalUrl(returnUrl)
        ? (ActionResult)this.Redirect(returnUrl)
        : this.RedirectToAction("Index");

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions