Skip to content

Latest commit

 

History

History
64 lines (49 loc) · 1.5 KB

ASP007.md

File metadata and controls

64 lines (49 loc) · 1.5 KB

ASP007

The method has no corresponding parameter

Topic Value
Id ASP007
Severity Warning
Enabled True
Category AspNetCoreAnalyzers.Routing
Code AttributeAnalyzer

Description

The method has no corresponding parameter.

Motivation

[HttpGet(""api/orders/{id}"")]
public async Task<IActionResult> GetOrder()
{
    ...
}

In the abobe there should be a parameter named id

How to fix violations

[HttpGet(""api/orders/{id}"")]
public async Task<IActionResult> GetOrder(int id)
{
    ...
}

Configure severity

Via ruleset file.

Configure the severity per project, for more info see MSDN.

Via #pragma directive.

#pragma warning disable ASP007 // The method has no corresponding parameter
Code violating the rule here
#pragma warning restore ASP007 // The method has no corresponding parameter

Or put this at the top of the file to disable all instances.

#pragma warning disable ASP007 // The method has no corresponding parameter

Via attribute [SuppressMessage].

[System.Diagnostics.CodeAnalysis.SuppressMessage("AspNetCoreAnalyzers.Routing", 
    "ASP007:The method has no corresponding parameter", 
    Justification = "Reason...")]