Static Analysis Rule Changes in .NET 9

  • Operating system: Windows 11
  • Visual Studio version: 17.12.0
  • SonarLint plugin version: 8.6.0.10679
  • Programming language you’re coding in: C#
  • Is connected mode used: No

In .NET 9, new performance enhancements were introduced for the LINQ methods that make them perform better than the collection-specific methods. Running the benchmarks listed in the rule help in .NET 9 shows that this is the case.

The following warnings (and possibly others) should be disabled by default when using .NET 9:

  • S6603: The collection-specific “TrueForAll” method should be used instead of the “All” extension
  • S6605: Collection-specific “Exists” method should be used instead of the “Any” extension

Hi there @bobcat9374, welcome to the community!

Thank you for reporting this.

We have just updated our analyzers to support .NET9 (among other things) and we did take this change into account. We moved those rules out of SonarWay as there is effectively no way to know which runtime the app is going to run on, so the rules are not pertinent in the general case anymore.

You can read more about all the changes in the announcement.

Denis.

1 Like

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