CA1859: false positive if the value is changed by await #6904
Labels
Area-Microsoft.CodeAnalysis.NetAnalyzers
Bug
The product is not behaving according to its current intended design
False_Positive
A diagnostic is reported for non-problematic case
Milestone
Analyzer
Diagnostic ID: CA1859:
Use concrete types when possible for improved performance
Analyzer source
SDK: Built-in CA analyzers in .NET 8 SDK or later
Version: SDK 8.0.100
OR
NuGet Package: Microsoft.CodeAnalysis.NetAnalyzers
Version: 8.0.0 (Latest 2023-11-17)
Describe the bug
A property or field with an interface type is initialized with a concrete implementation. In an
async
method another implementation is assigned usingawait
. CA1859 is generated.Steps To Reproduce
Expected behavior
No errors reported
Actual behavior
Error reported:
Class1.cs(3,15): error CA1859: Change type of property 'Prop' from 'I' to 'Impl1' for improved performance (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1859)
Additional context
The text was updated successfully, but these errors were encountered: