Skip to content

CA1822 False positive/conflict with new Extension syntax #78858

Open
@AlgorithmsAreCool

Description

@AlgorithmsAreCool

Version Used:
dotnet 10.0.100-preview.4.25258.110
VS2022 Version 17.14.4 Preview 1.0

Steps to Reproduce:

public static class MyExtensions
{
    extension (string s)
    {
        public int CountProp => s.Length; //Member 'CountProp' does not access instance data and can be marked as static
        public int CountMeth() => s.Length; //Member 'CountMeth' does not access instance data and can be marked as static
    }
}

Diagnostic Id:

CA1822

Expected Behavior:

No CA1822 since this property/method is accessing the receiver as if it was an instance method or whatever the right word is in compiler speak

Actual Behavior:
CA1822

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions