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

1 Like

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.

1 Like

Hi @Corniel
This is also fixed in version 10.18 of our analyzers.

2 Likes

I’m still getting this FP on SonarCloud. Will this fix eventually make its way there or is that a separate process?

Hi,

That analyzer version was released yesterday, and we’re headed into a freeze ahead of the annual company off-site next week. Can you check again around the 21st?

 
Thx,
Ann

2 Likes

Thanks, will do! (No rush, just wondered how the process worked.)

Hope your off-site was great.

We are still getting this marked as a FP on SonarCloud

Hi,

Welcome to the community and thanks for checking back in @UrsKroell. We’ll look (back) into this.

 
Ann

Hi @UrsKroell,

Are you able to provide a code snippet/simple reproducer?

I just ran a scan on a test project on sonarcloud.io (see this analysis) using the reproducer provided.

No issues were raised on the relevant lines.