FP: S2325 does report on C# 14 extensions

Rule S2325 warns when members can be static as they do not access instance data.

With C#14 a new way of defining extensions has been introduced. The rule does not recognize its syntax yet (apparently). I assume that the team is working on the new language features, but you might have missed this.

public static class Extensions
{
    extension(int number)
    {
        public bool IsEven => number % 2 == 0; //  FP, number is instance data.

        public bool IsOdd() => number % 2 != 0; // FP, number is instance data.
    }
}

Reported by SonarAnalyzer.CSharp v10.15.0.120848

Anyone?

Hi,

This is flagged for the language experts. Hopefully they’ll be along soon.

 
Ann

1 Like

Hey @Corniel ,
Thanks for the report!

This is definitely an FP.
I’ve created a ticket and we hope to tackle it soon.