Remove unused parameter (IDE0060)

Property Value
Rule ID IDE0060
Title Remove unused parameter
Category Style
Subcategory Unnecessary code rules
Applicable languages C# and Visual Basic

Overview

This rule flags unused parameters. The option value determines if unused parameters should be flagged only for non-public methods or for both public and non-public methods.

This rule does not flag parameters that are named with the discard symbol _. In addition, the rule ignores parameters that are named with the discard symbol followed by an integer, for example, _1. This behavior reduces warning noise on parameters that are needed for signature requirements, for example, a method used as a delegate, a parameter with special attributes, or a parameter whose value is implicitly accessed at run time by a framework but is not referenced in code.

dotnet_code_quality_unused_parameters

Property Value
Option name dotnet_code_quality_unused_parameters
Option values all - Flag methods with any accessibility that contain unused parameters

non_public - Flag only non-public methods that contain unused parameters
Default option value all

Example

// dotnet_code_quality_unused_parameters = all
public int GetNum1(int unusedParam) { return 1; }
internal int GetNum2(int unusedParam) { return 1; }
private int GetNum3(int unusedParam) { return 1; }

// dotnet_code_quality_unused_parameters = non_public
internal int GetNum4(int unusedParam) { return 1; }
private int GetNum5(int unusedParam) { return 1; }
' dotnet_code_quality_unused_parameters = all
Public Function GetNum1(unused As Integer)
    Return 1
End Function

Friend Function GetNum2(unused As Integer)
    Return 1
End Function

Private Function GetNum3(unused As Integer)
    Return 1
End Function

' dotnet_code_quality_unused_parameters = non_public
Friend Function GetNum4(arg1 As Integer)
    Return 1
End Function

Private Function GetNum5(arg1 As Integer)
    Return 1
End Function

See also