CA1859 versus S3242

We recently upgraded to .NET 8 and with it came new checks from the Roslyn Engine.

But now we have two rules competing with each other:
Roslyn: Use concrete types when possible for improved performance(external_roslyn:CA1859)

SonarQube: S3242 Method parameters should be declared with base types

We now change private methods according to CA1859 and public methods according to S3242.

Here is an example:

What would you recommend? How will SonarSource handle this in the future?


I find this post from DominikTouring very thoughtful and I am grateful it was brought up!

We too have hit this.

It be great if Sonar could alter S3242 to only trigger on public methods or make it configurable.

In the future, Microsoft and/or Sonar could/may create a complimenting rule for CA1859 (or enhance that rule) to work on arguments of private methods to prefer concrete types. I think this would be great for IEnumerable/ICollection use, for example. The performance boost may collectively prove interesting.

Curious and hopeful someone from Sonar has some thoughts.