A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/SonarSource/sonar-dotnet/issues/7508 below:

Should not fire in expressions · Issue #7508 · SonarSource/sonar-dotnet · GitHub

Description

As I understand, rule S6605 suggests the use of the collection-specific "Exists" method for performance reasons. It becomes a problem when the "Any" extension method is used in an expression because switching to the "Exists" method changes the expression (e. g. the C# MongoDb Driver supports Any but not Exists). There are also no performance benefits unless the expression is compiled and executed which should not be done anyways when performance is important.

Repro steps

Expression<Func<List<int>, bool>> containsThree = list => list.Any(el => el == 3);

Expected behavior

The rule should not fire.

Actual behavior

The rule fires.

Related information

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4