Skip to content

Mvc.Api.Analyzers.ApiConventionAnalyzer throws ArgumentNullException when action doesn't return #48528

@Briaoeuidhtns

Description

@Briaoeuidhtns

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

If an action just has a throw expression and no return, the analyzer throws a NullArgumentException with no other information or location in the code.

Expected Behavior

No exception is thrown, or a proper warning about never returning is given

Steps To Reproduce

https://github.com/Briaoeuidhtns/Mvc.Api.Analyzers.ApiConventionAnalyzer-NullArgumentException-on-no-return-repro

Exceptions (if any)

CSC : warning AD0001: Analyzer 'Microsoft.AspNetCore.Mvc.Api.Analyzers.ApiConventionAnalyzer' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. (Parameter 'target')'.

.NET Version

7.0.302

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    analyzerIndicates an issue which is related to analyzer experiencearea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesbugThis issue describes a behavior which is not expected - a bug.feature-openapi

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions