dotnet / roslyn-analyzers

MIT License
1.6k stars 467 forks source link

CA1019 Incorrectly Reported #7442

Open TonyValenti opened 1 month ago

TonyValenti commented 1 month ago

Analyzer

Diagnostic ID: CA1019: CA1019: Define accessors for attribute arguments

Analyzer source

SDK: .NET 8.0 Version: .NET 8.0

<LangVersion>preview</LangVersion>

Describe the bug

CA1019 looks for a property that matches the Name AND Type of the member. It should just look for the name and ignore the type.

Steps To Reproduce

    [AttributeUsage(validOn: AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
    public class DynamicallyIncludesAttribute : Attribute {

        public ImmutableArray<Type> Types { get; }

        public DynamicallyIncludesAttribute(params IEnumerable<Type> Types) {
            this.Types = [.. Types];
        }
    }

Expected behavior

CA1019 is not reported in the above code.

Actual behavior

CA1019 is reported in the above code.