About csharpsquid:S2368 and extensions methods

I have noticed this rule is triggered by the following extension method, which I implemented specifically to work with matrices:

public static void MatrixForEach<T>(this T[,] dataMatrix, Action<T, int, int> action) {
  // code

I’m not sure whether it would be sensible / worth the effort to make this rule ignore specifically the this parameter of extensions methods.

1 Like

Hey @m-gallesio

That’s a really good point.
I agree that if your extension method is specifically made for multi-dimensional matrices, S2368 should not raise.

I made a ticket in the sonar-dotnet repo, which can be found here

This means that it will be taken care of during an hardening sprint some time in the future.
Feel free to track the progress from the github issue.

Thanks a lot for the suggestion!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.