CA1859 fails to show in IDE in specific scenarios #7496
Labels
Area-Microsoft.CodeAnalysis.NetAnalyzers
Bug
The product is not behaving according to its current intended design
Analyzer
Diagnostic ID: CA1859:
Use concrete types when possible for improved performance
Analyzer source
SDK: Built-in CA analyzers in .NET 5 SDK or later
Version: SDK 9.0.101
OR
NuGet Package: Microsoft.CodeAnalysis.NetAnalyzers
Version: 9.0.0
Describe the bug
The CA1859 inspection fails to get shown in the IDE when certain criteria are met. The inspection will still be shown on build if set to warning or error level.
Steps To Reproduce
Make sure CA1859 is enabled and will show in the IDE, e.g. by setting
dotnet_diagnostic.CA1859.severity = warning
in the.globalconfig
file.Create two files.
File 1:
File 2:
Expected behavior
The variable
exampleList
should get annotated, suggesting me to use theList<string>
type instead ofIList<string>
.Actual behavior
There is no CA1859 annotation and the warning will only be shown when building. This also means that having the inspection on
suggestion
level will silence it completely.Additional context
Referencing a variable from another definition of a partial class seems to break the CA1859 inspection, even if the variables are not related in any way. It seems to also be required for the variable to be in an actual different file, not just another part of the class in the same file. In the example above, the inspection can be easily toggled by commenting the
Console.WriteLine(ABC);
line.The text was updated successfully, but these errors were encountered: