Skip to content

Conversation

@pranavkm
Copy link
Contributor

@pranavkm pranavkm commented Aug 20, 2021

Contributes to #35528

@ghost ghost added the area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework label Aug 20, 2021
@pranavkm pranavkm marked this pull request as ready for review August 21, 2021 04:19
@pranavkm pranavkm requested a review from Pilchie as a code owner August 21, 2021 04:19
@pranavkm pranavkm requested a review from BrennanConroy August 21, 2021 04:19
@davidfowl
Copy link
Member

Backport tot RC1 right? This needs a rebase on @halter73's rename.


private static ITypeSymbol UnwrapPossibleAsyncReturnType(ITypeSymbol returnType)
{
if (returnType is not INamedTypeSymbol { Name: "Task" or "ValueTask", IsGenericType: true, TypeArguments: { Length: 1 } } taskLike)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't wait until we get list patterns. This is beautiful.

var diagnostic = Assert.Single(diagnostics);
Assert.Same(DiagnosticDescriptors.DoNotReturnActionResultsFromMapActions, diagnostic.Descriptor);
AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location);
Assert.Equal("IActionResult instances should not be returned from a MapGet delegate parameter. Consider returning an equivalent result from Microsoft.AspNetCore.Http.Results.", diagnostic.GetMessage());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could go crazy here and make figure out the suggestion based on the context (you could even do a codefix).

}

[Fact]
public async Task MinimalAction_ReturningActionResultFromMethodReference_ProducesDiagnostics()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intra-method analysis too? Impressive 😄

@pranavkm pranavkm force-pushed the prkrishn/action-result-returning-analyzer branch from f3bb75e to 1131f1f Compare August 21, 2021 14:37
@pranavkm pranavkm force-pushed the prkrishn/action-result-returning-analyzer branch from 1131f1f to 6373715 Compare August 21, 2021 14:38
@davidfowl davidfowl added feature-minimal-actions Controller-like actions for endpoint routing old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels and removed area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework labels Aug 21, 2021
@davidfowl
Copy link
Member

If you want a stretch goal, write a fixer that suggests the right Results.* to use 😉

@pranavkm pranavkm enabled auto-merge (squash) August 22, 2021 00:15
@pranavkm
Copy link
Contributor Author

/backport to release/6.0-rc1

@github-actions
Copy link
Contributor

@github-actions
Copy link
Contributor

@pranavkm backporting to release/6.0-rc1 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Complain when returning IActionResult from MinimalAction
.git/rebase-apply/patch:573: new blank line at EOF.
+
warning: 1 line adds whitespace errors.
Using index info to reconstruct a base tree...
A	src/Framework/Analyzer/src/DelegateEndpoints/DelegateEndpointAnalyzer.cs
A	src/Framework/Analyzer/src/DelegateEndpoints/DiagnosticDescriptors.cs
A	src/Framework/Analyzer/src/DelegateEndpoints/WellKnownTypes.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Framework/Analyzer/src/MinimalActions/WellKnownTypes.cs
Auto-merging src/Framework/Analyzer/src/MinimalActions/MinimalActionAnalyzer.cs
CONFLICT (content): Merge conflict in src/Framework/Analyzer/src/MinimalActions/MinimalActionAnalyzer.cs
Auto-merging src/Framework/Analyzer/src/MinimalActions/DiagnosticDescriptors.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Complain when returning IActionResult from MinimalAction
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@pranavkm pranavkm merged commit 60acf4c into main Aug 22, 2021
@pranavkm pranavkm deleted the prkrishn/action-result-returning-analyzer branch August 22, 2021 01:51
@ghost ghost added this to the 7.0-preview1 milestone Aug 22, 2021
@pranavkm
Copy link
Contributor Author

/backport to release/6.0

@github-actions
Copy link
Contributor

@davidfowl davidfowl changed the title Complain when returning IActionResult from MinimalAction Complain when returning IActionResult from route handlers Aug 26, 2021
@amcasey amcasey added the area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc label Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc feature-minimal-actions Controller-like actions for endpoint routing old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants