You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe this rule for code targeting .NET 8.0 or below, and a new rule "Any" method should be used instead of the "Exists" for code targeting .NET 9.0 or above?
The text was updated successfully, but these errors were encountered:
sebastien-marichal
changed the title
Fix S6605: "Collection-specific 'Exists' method should be used instead of the 'Any' extension" shouldn't be used in .NET 9.0
Fix S6605 FP: Any is faster than Exists in .NET 9
Sep 18, 2024
I think advising the other way around does not make sense. We're dealing with a difference of 2 nanoseconds. You could consider report to Microsoft thought, as it is strange that a native method (.Exists) turns out to be slower than an extension method.
Hello,
The rule S6605 may no longer be applicable for projects targeting .NET 9.0.
Recent benchmarks indicate that starting with .NET 9.0,
Any
is actually faster thanExists
. Below are the benchmark results.Code:
Results:
Maybe this rule for code targeting .NET 8.0 or below, and a new rule
"Any" method should be used instead of the "Exists"
for code targeting .NET 9.0 or above?The text was updated successfully, but these errors were encountered: