Skip to content

Create and include an analyzer that validates action method return types match the declared ActionResult<T> #8535

@DamianEdwards

Description

@DamianEdwards

Add an analyzer that validates the return types from an action method returning ActionResult<T>, e.g. don't let it return ObjectResult with a different T value, e.g. the following is invalid:

[HttpGet]
public ActionResult<IEnumerable<string>> Get()
{
    return new ObjectResult(new { Not = "Valid" });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-mediumThis issue impacts approximately half of our customersanalyzerIndicates an issue which is related to analyzer experiencearea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-openapiseverity-minorThis label is used by an internal tool

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions