We recommend using Visual Studio 2017

CA1801: Review unused parameters


The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

For the latest documentation on Visual Studio 2017, see CA1801: Review unused parameters on docs.microsoft.com.

Breaking ChangeNon Breaking - If the member is not visible outside the assembly, regardless of the change you make.

Non Breaking - If you change the member to use the parameter within its body.

Breaking - If you remove the parameter and it is visible outside the assembly.

A method signature includes a parameter that is not used in the method body. This rule does not examine the following methods:

  • Methods referenced by a delegate.

  • Methods used as event handlers.

  • Methods declared with the abstract (MustOverride in Visual Basic) modifier.

  • Methods declared with the virtual (Overridable in Visual Basic) modifier.

  • Methods declared with the override (Overrides in Visual Basic) modifier.

  • Methods declared with the extern (Declare statement in Visual Basic) modifier.

Review parameters in non-virtual methods that are not used in the method body to make sure no correctness exists around failure to access them. Unused parameters incur maintenance and performance costs.

Sometimes a violation of this rule can point to an implementation bug in the method. For example, the parameter should have been used in the method body. Suppress warnings of this rule if the parameter has to exist because of backward compatibility.

To fix a violation of this rule, remove the unused parameter (a breaking change) or use the parameter in the method body (a non-breaking change).

It is safe to suppress a warning from this rule for previously shipped code for which the fix would be a breaking change.

The following example shows two methods. One method violates the rule and the other method satisfies the rule.

using System;
using System.Globalization;

namespace Samples
    public static class TestClass
        // This method violates the rule.
        public static string GetSomething(int first, int second)
            return first.ToString(CultureInfo.InvariantCulture);

        // This method satisfies the rule.
        public static string GetSomethingElse(int first)
            return first.ToString(CultureInfo.InvariantCulture);

CA1811: Avoid uncalled private code

CA1812: Avoid uninstantiated internal classes

CA1804: Remove unused locals