Skip to content

CA1801 false report for implicit interface implementation #1394

Open

Description

Analyzer package

Microsoft.CodeQuality.Analyzers

Analyzer

ReviewUnusedParameters

Repro steps

Open https://github.com/dotnet/project-system/blob/master/ProjectSystem.sln and enable CA1801 in https://github.com/dotnet/project-system/blob/master/build/Default.ruleset#L5

Expected behavior

No CA1801 for https://github.com/dotnet/project-system/blob/master/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests/ProjectSystem/VS/Tree/Dependencies/Snapshot/TestDependency.cs#L42 as it implicitly implements the interface method on IDependency.

Actual behavior

Severity	Code	Description	Project	File	Line	Suppression State
Warning	CA1801	Parameter caption of method SetProperties is never used. Remove the parameter or use it in the method body.	Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests	c:\project-system\src\Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests\ProjectSystem\VS\Tree\Dependencies\Snapshot\TestDependency.cs	43	Active
Warning	CA1801	Parameter resolved of method SetProperties is never used. Remove the parameter or use it in the method body.	Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests	c:\project-system\src\Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests\ProjectSystem\VS\Tree\Dependencies\Snapshot\TestDependency.cs	44	Active
Warning	CA1801	Parameter flags of method SetProperties is never used. Remove the parameter or use it in the method body.	Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests	c:\project-system\src\Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests\ProjectSystem\VS\Tree\Dependencies\Snapshot\TestDependency.cs	45	Active
Warning	CA1801	Parameter schemaName of method SetProperties is never used. Remove the parameter or use it in the method body.	Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests	c:\project-system\src\Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests\ProjectSystem\VS\Tree\Dependencies\Snapshot\TestDependency.cs	46	Active
Warning	CA1801	Parameter dependencyIDs of method SetProperties is never used. Remove the parameter or use it in the method body.	Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests	c:\project-system\src\Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests\ProjectSystem\VS\Tree\Dependencies\Snapshot\TestDependency.cs	47	Active
Warning	CA1801	Parameter icon of method SetProperties is never used. Remove the parameter or use it in the method body.	Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests	c:\project-system\src\Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests\ProjectSystem\VS\Tree\Dependencies\Snapshot\TestDependency.cs	48	Active
Warning	CA1801	Parameter expandedIcon of method SetProperties is never used. Remove the parameter or use it in the method body.	Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests	c:\project-system\src\Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests\ProjectSystem\VS\Tree\Dependencies\Snapshot\TestDependency.cs	49	Active
Warning	CA1801	Parameter isImplicit of method SetProperties is never used. Remove the parameter or use it in the method body.	Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests	c:\project-system\src\Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests\ProjectSystem\VS\Tree\Dependencies\Snapshot\TestDependency.cs	50	Active

It seems we do bail out on interface implementation in general cases. For example, no CA1801 is reported on:

interface I
{
    void M(int x);
}

class C : I
{
    public void M(int x)
    {
    }
}

So likely there is some specific bug in the detection of whether a method is interface implementation,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions