-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Greater than 1 FromBody analyzer. #46494
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
Greater than 1 FromBody analyzer. #46494
Conversation
src/Framework/AspNetCoreAnalyzers/src/Analyzers/DiagnosticDescriptors.cs
Outdated
Show resolved
Hide resolved
src/Framework/AspNetCoreAnalyzers/src/Analyzers/RouteHandlers/AtMostOneFromBodyAttribute.cs
Outdated
Show resolved
Hide resolved
src/Framework/AspNetCoreAnalyzers/src/Analyzers/RouteHandlers/AtMostOneFromBodyAttribute.cs
Outdated
Show resolved
Hide resolved
src/Framework/AspNetCoreAnalyzers/test/RouteHandlers/AtMostOneFromBodyAttributeTest.cs
Outdated
Show resolved
Hide resolved
src/Framework/AspNetCoreAnalyzers/src/Analyzers/DiagnosticDescriptors.cs
Outdated
Show resolved
Hide resolved
src/Framework/AspNetCoreAnalyzers/src/Analyzers/DiagnosticDescriptors.cs
Outdated
Show resolved
Hide resolved
src/Framework/AspNetCoreAnalyzers/src/Analyzers/RouteHandlers/AtMostOneFromBodyAttribute.cs
Outdated
Show resolved
Hide resolved
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
…riptors.cs Co-authored-by: James Newton-King <[email protected]>
…riptors.cs Co-authored-by: James Newton-King <[email protected]>
@halter73 waiting on your review. Based on @martincostello's feedback I also added support for scenarios where <data name="Analyzer_MultipleFromBody_Message" xml:space="preserve">
<value>Route handler has multiple parameters with the [FromBody] attribute or a parameter with an [AsParameters] attribute where the parameter type contains multiple members with [FromBody] attributes. Only one parameter can have a [FromBody] attribute.</value>
</data> |
/azp run |
Commenter does not have sufficient privileges for PR 46494 in repo dotnet/aspnetcore |
/azp run aspnetcore-ci |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run aspnetcore-components-e2e |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run aspnetcore-quarantined-pr |
Azure Pipelines successfully started running 1 pipeline(s). |
5de0b4a
to
fc414d7
Compare
|
||
if (fromBodyMetadataInterfaceParameters.Count() >= 2) | ||
{ | ||
ReportDiagnostics(context, fromBodyMetadataInterfaceParameters); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wouldn't fail if there's a single [FromBody]
parameter and then another [AsParameter]
parameter with a single [FromBody]
property, right? Or multiple [AsParameter]
parameters with a single [FromBody]
property each? All of these should fail. Can we add test cases for these?
I think the new message is good. I think the old message was good enough too. Hopefully it's obvious to the people using the feature that |
This PR addresses #45382.
Detect when two or more [FromBody] attributes are used
Description
This PR ads another diagnostic for when two
[FromBody]
attributes are used on a single handler function. It ads a diagnostic for each parameter which is decorated with[FromBody]
.