-
Notifications
You must be signed in to change notification settings - Fork 484
Open
dotnet/sdk
#50461Labels
Area-Microsoft.CodeAnalysis.NetAnalyzersFalse_NegativeNo diagnostic is reported for a problematic caseNo diagnostic is reported for a problematic casehelp wantedThe issue is up-for-grabs, and can be claimed by commentingThe issue is up-for-grabs, and can be claimed by commenting
Description
Analyzer
Diagnostic ID: CA1860
Describe the improvement
An interface such as IReadOnlyList<> inherits its Count
property from IReadOnlyCollection<>.
I believe it makes sense for the CA1860 diagnostic to apply to these types as well?
Describe suggestions on how to achieve the rule
Update the HasEligible*Property
methods to also inspect AllInterfaces
/ BaseType
s, similar to the UseCountProperly analyzer.
Additional context
namespace Test;
public class Class1 {
public void Foo() {
IReadOnlyList<int> list = [];
IReadOnlyCollection<int> collection = list;
if( list.Any() || collection.Any() ) {
return;
}
}
}
andrewimcclement, buyaa-n and verdie-g
Metadata
Metadata
Assignees
Labels
Area-Microsoft.CodeAnalysis.NetAnalyzersFalse_NegativeNo diagnostic is reported for a problematic caseNo diagnostic is reported for a problematic casehelp wantedThe issue is up-for-grabs, and can be claimed by commentingThe issue is up-for-grabs, and can be claimed by commenting