Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CA1801 ignores use in deep collection initializer #1084

Closed
flcdrg opened this issue Nov 16, 2016 · 2 comments
Closed

CA1801 ignores use in deep collection initializer #1084

flcdrg opened this issue Nov 16, 2016 · 2 comments

Comments

@flcdrg
Copy link
Contributor

flcdrg commented Nov 16, 2016

Analyzer package

Microsoft.Maintainability.Analyzers

Analyzer

ReviewUnusedParameters

Repro steps

The following code triggers CA1801 on the count parameter of the TheMethod method:

using System.Collections.Generic;

namespace ClassLibrary4
{
    public class Class1
    {
        public void TheMethod(int count)
        {
            var testParams = new OtherClass(new List<int[]> { new[] { count } });
        }
    }

    public class OtherClass
    {
#pragma warning disable CA1801 // Review unused parameters
        public OtherClass( List<int[]> intses)
#pragma warning restore CA1801 // Review unused parameters
        {
        }
    }
}

Expected behavior

Analyzer could not flag this as a problem.

Actual behavior

error CA1801: Parameter count of method TheMethod is never used. Remove the parameter or use it in the method body.

@mavasani
Copy link
Contributor

I think there is an existing IOperation bug for this.

@mavasani
Copy link
Contributor

Dupe of dotnet/roslyn#8884 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants