The Wayback Machine - https://web.archive.org/web/20211230131125/https://github.com/dotnet/aspnetcore/pull/39242
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added API analyzer functionality for conditional return expressions #39242

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

@Silverdark
Copy link
Contributor

@Silverdark Silverdark commented Dec 30, 2021

Added API analyzer functionality for conditional return expressions

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Description

The analyzer API1000 and API1001 are not creating warning when returning with a conditional statement. In this PR I added the functionality that conditional statements are evaluated as well.

In order to do this, I had to change the InspectReturnOperation method to return multiple ActualApiResponseMetadata instead of a single one. A single IReturnOperation can have a IConditionalOperation which has two children WhenTrue and WhenFalse.

This leads to the fact that a single conditional statement can return two ActualApiResponseMetadata instances and if there are more conditional statements nested, it will return even more instances from one IReturnOperation.

Fixes #33105

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

1 participant