CA1820 incorrectly fires in LINQ expressions #1508
Labels
Area-Microsoft.CodeAnalysis.NetAnalyzers
Bug
The product is not behaving according to its current intended design
help wanted
The issue is up-for-grabs, and can be claimed by commenting
Milestone
Analyzer package
Microsoft Code Analysis, version 2.6.0.6241303
Analyzer
CA1820
Repro steps
Consider the following program:
Expected behavior
CA1820 is not raised. Indeed, the comparison to
""
happens in a LINQ expression.Actual behavior
CA1820 is raised:
Given that the comparison happens in a LINQ expression, there is no way to tell if using string.Length will be faster or not. In fact, it is very much possible that the LINQ provider will not be able to translate a comparison to String.Length.
Note that U2U1100 from the U2U Consult Performance Analyzers for C# 7 does not have this problem.
The text was updated successfully, but these errors were encountered: