You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Analyzers API1000 and API1001 should trigger on conditional returns #33105
analyzerIndicates an issue which is related to analyzer experiencearea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesfeature-openapigood first issueGood for newcomers.help wantedUp for grabs. We would accept a PR to help resolve this issue
Analyzers API1000 and API1001 should trigger on returns (or expression-bodied methods) with conditional expressions.
Additional context
publicActionResult<object>OopsUndocumentedIf(intid){if(id==0){returnNotFound();// API1000}returnOk(newobject());}publicActionResult<object>OopsUndocumentedConditional(intid){returnid==0?NotFound():Ok(newobject());// No API1000}
@eatdrinksleepcode I think rewriting these analyzers to use operation blocks should simplify authoring it and address a lot of these control-flow issues. Is that something you might be interested in trying to pick up?
@Youssef1313 the code was rewritten to use operations instead of syntax, but conditional returns were not handled as far as I can see. The new code is still examining the return for method calls and object creation, not for conditionals.
analyzerIndicates an issue which is related to analyzer experiencearea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesfeature-openapigood first issueGood for newcomers.help wantedUp for grabs. We would accept a PR to help resolve this issue
Activity
pranavkm commentedon May 28, 2021
@eatdrinksleepcode I think rewriting these analyzers to use operation blocks should simplify authoring it and address a lot of these control-flow issues. Is that something you might be interested in trying to pick up?
eatdrinksleepcode commentedon May 29, 2021
Agreed, using operations makes more sense with these semantic rules. I can look into that this weekend. Should I open a separate issue?
mkArtakMSFT commentedon Jun 1, 2021
Thanks for contacting us, @eatdrinksleepcode .
Let's use this issue to track it. Send out the PR and we'll look at it.
singh733 commentedon Jun 21, 2021
@pranavkm I have gone through the code and below is the proposed solution. Please see the TODO Comment :
Youssef1313 commentedon Jul 17, 2021
It's better to completely rewrite using IOperation rather than using syntax analysis.
Youssef1313 commentedon Jul 17, 2021
Looks like this was already rewritten in #34020.
This will need a test to confirm whether this specific issue was fixed with the rewrite or not.
eatdrinksleepcode commentedon Jul 28, 2021
@Youssef1313 the code was rewritten to use operations instead of syntax, but conditional returns were not handled as far as I can see. The new code is still examining the return for method calls and object creation, not for conditionals.
pranavkm commentedon Jul 28, 2021
Yup - it was straight rewrite without adding new features. If you'd like to extend it further, we'd be happy to accept a PR for it.
Support conditional expressions in API1000/API1001 analyzers
Youssef1313 commentedon Aug 18, 2026
This analyzer was deprecated in .NET 10 and removed in .NET 11. See https://learn.microsoft.com/en-us/aspnet/core/breaking-changes/10/openapi-analyzers-deprecated
Related to #68087
cc @danroth27