All docs
V19.2
19.2
19.1
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

CRR0042 - Unused parameter

This analyzer detects a method parameter that is not used in the method body.

void SomeMethod1(int a, int b) // the "b" parameter is unused
{
    Calculate(a);
}

void SomeMethod2(int a) // the "a" value is unused
{
    a = 10;
    Calculate(a);
}

To fix issues, remove the unused parameter from methods:

void SomeMethod1(int a) 
{
    Calculate(a);
}

void SomeMethod2() 
{
    a = 10;
    Calculate(a);
}

Call the Remove Unused Parameter refactoring to remove an unused parameter from a method. If you need to do it in different places at once, use the Code Cleanup feature with Remove unused parameter rule enabled.

Limitations

The analyzer ignores:

  • Virtual, override methods and interface implementations.

  • The "this" parameter of extension methods.

  • Methods that have attributes defined on them.

  • Empty or unsupported methods.